MCQs City stays free thanks to ads. Please turn off your ad blocker for this site so content and features keep working.
Operating System
Semaphores 2
Q
At a particular time of computation the value of a counting semaphore is 7.Then 20 P operations and 15 V operations were completed on this semaphore. The resulting value of the semaphore is? (GATE 1987)
AA. 42
BB. 2
CC. 7
DD. 12
Correct Answer:
B. B. 2
Explanation:
P represents Wait and V represents Signal. P operation will decrease the value by 1 every time and V operation will increase the value by 1 every time.
In semaphore operations:P Operation (Wait/Down): Decrements the value of the semaphore ($S = S - 1$).V Operation (Signal/Up): Increments the value of the semaphore ($S = S + 1$).Step-by-step:Initial Value: $7$After 20 P operations: $7 - 20 = -13$After 15 V operations: $-13 + 15 = 2$