CS FundamentalsHardGATE CS

Semaphores a = 1, b = 0. P: wait(a); print 1; signal(b); signal(b). Q: wait(b); print 2; signal(a). R: wait(b); print 3. Each runs once. Which outputs are possible?

  1. A. 123 only
  2. B. 123 and 132 only
  3. C. 123, 132 and 213
  4. D. Any permutation of 1, 2, 3

Correct answer: B. 123 and 132 only

1 must come first (only P can start); after its two signals both Q and R are released in either order: 123, 132.

More Operating Systems questions

Exams that ask this topic