Bird
Raised Fist0

What typically occurs if a thread tries to unlock a mutex that it has not previously locked?

easy📖 Theory Q3 of Q15
Operating Systems - Semaphore vs Mutex - When to Use Which
What typically occurs if a thread tries to unlock a mutex that it has not previously locked?
AThe system throws an error or undefined behavior occurs
BThe mutex is unlocked successfully
CThe thread is blocked until it acquires the mutex
DThe mutex count is incremented
Step-by-Step Solution
Solution:
  1. Step 1: Understand mutex ownership

    Mutexes enforce ownership; only the locking thread can unlock.
  2. Step 2: Behavior on unlocking by non-owner

    Unlocking by a non-owner usually causes an error or undefined behavior.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Mutex ownership violation triggers error [OK]
Quick Trick: Only owner thread can unlock mutex [OK]
Common Mistakes:
MISTAKES
  • Assuming mutex unlock always succeeds
  • Confusing mutex with semaphore behavior
  • Thinking thread blocks on unlock
Trap Explanation:
PITFALL
  • Unlocking by non-owner is not allowed, unlike semaphore post
Interviewer Note:
CONTEXT
  • Tests knowledge of mutex ownership and error handling
Master "Semaphore vs Mutex - When to Use Which" in Operating Systems

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Operating Systems Quizzes