CS FundamentalsHardGATE CS

Semaphore s = 0. P1: print('a'); signal(s); print('b'). P2: wait(s); print('c'); print('d'). How many different output strings are possible?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 6

Correct answer: B. 3

'a' must come first; then 'b' may land before 'c', between 'c' and 'd', or after 'd': abcd, acbd, acdb.

More Operating Systems questions

Exams that ask this topic