Bird
Raised Fist0

Which of the following statements about the producer-consumer problem using semaphores is INCORRECT?

medium🐞 Bug Identification Q14 of Q15
Operating Systems - Producer-Consumer Problem Using Semaphores
Which of the following statements about the producer-consumer problem using semaphores is INCORRECT?
AMutex is optional if semaphores are used correctly
BThe 'full' semaphore is initialized to zero to track filled slots
CThe 'empty' semaphore is initialized to the buffer size to track available slots
DProducers and consumers block on semaphores to avoid busy-waiting
Step-by-Step Solution
  1. Step 1: Initialization of semaphores

    'empty' starts at buffer size; 'full' starts at zero -- both correct.
  2. Step 2: Role of mutex

    Mutex is essential to ensure mutual exclusion when accessing the buffer; semaphores alone do not provide this.
  3. Step 3: Blocking behavior

    Producers and consumers block on semaphores to avoid busy-waiting, which is correct.
  4. Step 4: Why 'Mutex is optional if semaphores are used correctly' is incorrect

    Claiming mutex is optional is a common misconception; without mutex, race conditions occur.
  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    Mutex is mandatory for mutual exclusion [OK]
Quick Trick: Mutex is mandatory; semaphores track counts
Common Mistakes:
MISTAKES
  • Believing semaphores alone guarantee mutual exclusion
  • Misinitializing semaphore counts
  • Thinking blocking is done by mutex
Trap Explanation:
PITFALL
  • Option A is tempting because semaphores do block threads, but they do not protect critical sections from concurrent access.
Interviewer Note:
CONTEXT
  • Tests candidate's ability to spot subtle misconceptions about synchronization primitives
Master "Producer-Consumer Problem Using Semaphores" 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