CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

Semaphores x = y = z = 0. T1: print A; signal(x); wait(y); print D. T2: wait(x); print B; signal(y); signal(z). T3: wait(z); print C. Which outputs are possible?

  1. A. ABCD and ABDC
  2. B. ABCD only
  3. C. ABCD, ABDC and ACBD
  4. D. ABDC only

Correct answer: A. ABCD and ABDC

A must precede B (x), and B precedes both C and D because T2 signals y and z only after printing B. After that, T1's D and T3's C can come in either order.

More Operating Systems questions

Exams that ask this topic