CS FundamentalsEasyGATE CS (PYQ pattern)

A one-slot buffer uses semaphores mutex = 1, empty = 1, full = 0. The producer runs twice: wait(mutex); wait(empty); print p; signal(full); signal(mutex). The consumer runs twice: wait(full); wait(mutex); print c; signal(empty); signal(mutex). They start together. Which statement is correct?

  1. A. No deadlock is possible, and the only complete output is pcpc
  2. B. A deadlock is possible, and the only complete output is pcpc
  3. C. A deadlock is possible, and both pcpc and ppcc are complete outputs
  4. D. No deadlock is possible, and the outputs pcpc and cpcp are both possible

Correct answer: B. A deadlock is possible, and the only complete output is pcpc

In the second iteration the producer can take mutex and then block on empty (the slot is still full), while the consumer, holding full, blocks on mutex: deadlock. In all completing runs the one-slot buffer forces strict alternation p c p c.

More Operating Systems questions

Exams that ask this topic