A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore is: A. 0 B. 8 C. 10 D. 12

GATE 1998 · Operating System · Semaphore · easy

Answer: The resulting value of the semaphore is 8. (Answer: B)

  1. Apply P operations: S = 10 - 6 = 4.
  2. Apply V operations: S = 4 + 4 = 8.