Bird
Raised Fist0

In a system where multiple threads need to access a limited number of identical resources concurrently, which synchronization primitive is most appropriate to control access?

easy🔍 Pattern Recognition Q11 of Q15
Operating Systems - Semaphore vs Mutex - When to Use Which
In a system where multiple threads need to access a limited number of identical resources concurrently, which synchronization primitive is most appropriate to control access?
AMutex, because it ensures exclusive ownership and prevents simultaneous access
BSpinlock, because it busy-waits until the resource is free
CBinary semaphore, because it allows only one thread at a time
DCounting semaphore, because it can track and limit access to multiple identical resources
Step-by-Step Solution
  1. Step 1: Understand resource sharing scenario

    Multiple identical resources mean more than one thread can access simultaneously but limited by resource count.
  2. Step 2: Evaluate synchronization primitives

    Mutex and binary semaphore allow only one thread at a time, unsuitable for multiple identical resources.
  3. Step 3: Counting semaphore suitability

    Counting semaphore maintains a count of available resources, allowing multiple threads up to the count.
  4. Step 4: Spinlock consideration

    Spinlocks are low-level and busy-wait, not ideal for managing multiple identical resources efficiently.
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    Counting semaphore matches the scenario of multiple identical resources.
Quick Trick: Counting semaphore counts resources; mutex/binary semaphore allow only one.
Common Mistakes:
MISTAKES
  • Confusing mutex with counting semaphore for multiple resources
  • Assuming binary semaphore can handle multiple identical resources
  • Believing spinlocks are suitable for resource counting
Trap Explanation:
PITFALL
  • Mutex and binary semaphore limit access to one thread, tempting candidates to pick them for simplicity. Spinlocks are low-level and not designed for resource counting, but may seem plausible.
Interviewer Note:
CONTEXT
  • Tests candidate's ability to recognize appropriate synchronization primitive based on resource sharing pattern.
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