CS FundamentalsVery hardGATE CS (PYQ pattern)

A bounded buffer has 3 slots: empty = 3, full = 0, mutex = 1 (classic implementation where a blocked wait leaves the semaphore negative). Five producers each try to insert one item and all five run before any consumer. Afterwards two consumers each remove one item, and every blocked producer woken completes its insertion. What are the final values of (empty, full) once everything settles?

  1. A. (0, 3)
  2. B. (1, 2)
  3. C. (2, 1)
  4. D. (-2, 5)

Correct answer: A. (0, 3)

Five producers: three succeed (empty 0, full 3) and two block (empty = -2). Each consumer does wait(full) then signal(empty), waking a blocked producer who then signals full again: after both, empty = 0, full = 3 (3 items in the buffer).

More Operating Systems questions

Exams that ask this topic