Bird
Raised Fist0

In a scenario where a mutex-protected resource must be accessed by multiple processes (not threads) across different machines, which synchronization primitive and approach is most appropriate, and why?

hard🎤 Interviewer Follow-up Q15 of Q15
Operating Systems - Semaphore vs Mutex - When to Use Which
In a scenario where a mutex-protected resource must be accessed by multiple processes (not threads) across different machines, which synchronization primitive and approach is most appropriate, and why?
AUse a binary semaphore implemented via a distributed lock service to enforce mutual exclusion across processes
BUse a distributed counting semaphore to limit concurrent access across machines
CUse a local mutex on each machine, since mutexes enforce ownership and prevent race conditions
DUse spinlocks on each machine to busy-wait until the resource is free
Step-by-Step Solution
  1. Step 1: Identify cross-machine synchronization needs

    Local mutexes cannot synchronize across machines.
  2. Step 2: Evaluate distributed synchronization primitives

    Distributed lock services provide mutual exclusion across processes/machines.
  3. Step 3: Binary semaphore vs counting semaphore

    Binary semaphore (or mutex) semantics needed for mutual exclusion; counting semaphore allows multiple concurrent accesses, unsuitable if exclusive access required.
  4. Step 4: Spinlocks impractical across network due to busy-wait and latency

  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    Distributed binary semaphore or lock service enforces mutual exclusion across machines.
Quick Trick: Distributed mutual exclusion requires distributed lock (binary semaphore), not local mutex or counting semaphore.
Common Mistakes:
MISTAKES
  • Assuming local mutexes work across machines
  • Choosing counting semaphore for exclusive access
  • Using spinlocks in distributed environment
Trap Explanation:
PITFALL
  • Candidates may incorrectly assume local primitives suffice or confuse counting semaphore with mutual exclusion in distributed context.
Interviewer Note:
CONTEXT
  • Tests advanced understanding of synchronization primitives in distributed systems and their limitations.
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