A counting semaphore S starts at 7. Then 10 wait (P) operations and 4 signal (V) operations are performed. Under the definition where the value can go negative, what is the final value of S?
Correct answer D. 1
Each wait decrements S and each signal increments it, so the final value is 7 - 10 + 4 = 1. During the sequence S may have become negative, with the absolute value counting blocked processes, but the net result does not depend on the order. The value -3 ignores the signals, and 11 adds them to the starting value while ignoring the waits.
Answer checked How we write and check questions
Discussion