Intermediate
Operating Systems
Q68 / 100
In the producer-consumer (bounded-buffer) problem, why are two counting semaphores ("empty" and "full") needed in addition to a mutex?
Correct! Well done.
Incorrect.
The correct answer is D) They track how many buffer slots are available versus occupied, so producers block when the buffer is full and consumers block when it is empty, while the mutex only protects the buffer access itself
D
Correct Answer
They track how many buffer slots are available versus occupied, so producers block when the buffer is full and consumers block when it is empty, while the mutex only protects the buffer access itself
Explanation
"empty" counts free slots and "full" counts filled slots, coordinating when producers/consumers must wait. The mutex separately ensures only one thread manipulates the shared buffer indices at a time — the three together prevent both races and incorrect blocking.
Progress
68/100