CS FundamentalsHardGATE CS (PYQ pattern)

Semaphores a = 1, b = 0, c = 0. P1: wait(a); print x; signal(b). P2: wait(b); print y; signal(c). P3: wait(c); print z; signal(a). P4: print w. Every process runs once. How many different outputs can the program print?

  1. A. 4
  2. B. 5
  3. C. 7
  4. D. 3

Correct answer: A. 4

The semaphores force the chain x, y, z; w is unconstrained and can appear in any of the 4 positions: 4 strings.

More Operating Systems questions

Exams that ask this topic