CS FundamentalsModerateGATE CS

A semaphore S starts at 7. Over time 20 wait() and 15 signal() operations complete on it, in some order, with no process left blocked at the end. What is the final value of S?

  1. A. 2
  2. B. 0
  3. C. 12
  4. D. −2

Correct answer: A. 2

Each completed wait subtracts 1 and each signal adds 1: 7 − 20 + 15 = 2. Since nobody is left blocked, every wait did complete, so the value is simply the net count.

More Operating Systems questions

Exams that ask this topic