Practice mode Operating Systems

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

Explanation

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.