Free Synchronization lessonsSynchronization · Stage 2 · The classic problems · Step 1
Producer and consumer
Solve the bounded-buffer problem with semaphores, and see how one wrong ordering causes deadlock. About 14 minutes.
In the bounded-buffer solution, what does the full semaphore count?
- AThe number of items currently in the buffer
- BThe number of free slots
- CThe number of waiting threads
Show the answer
The number of items currently in the buffer. Consumers wait on it; producers signal it after adding an item.
4 questions on this idea
Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.
Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve