Many systems have one part producing work and another consuming it through a fixed-size buffer, like a print queue or a logging pipeline. The producer must wait when the buffer is full, and the consumer when it is empty. This problem shows how to combine counting semaphores with a mutex to solve that. Order matters here: taking the mutex before the counting semaphore can deadlock both sides.