CS FundamentalsHardGATE CS

Semaphores s = 0 and t = 0. P1: print A; signal(s); wait(t); print B. P2: wait(s); print C; signal(t); wait(s); print D. P3: print E; signal(s). Which output can NOT occur?

  1. A. ECABD
  2. B. ACBED
  3. C. AECDB
  4. D. ACDEB

Correct answer: D. ACDEB

D needs s to be signalled twice, once by P1 after A and once by P3 after E, so E must come before D; ACDEB violates this. ECABD is possible because P3's signal can let C run before A.

More Operating Systems questions

Exams that ask this topic