Choose the correct alternatives (more than one may be correct) and write the corresponding letters only:
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 :
@pankajbelwal P and V were the terminology used by Dijkstra when he proposed this algorithm.
Answer is option B.
Currently semaphore is $7$ so, after $20$ $P$(wait) operation it will come to $-12$ then for $15$ V(signal) operation the value comes to $2.$
since P(S) decreases the counting semaphore value
The initial value of semaphore is 7
After finishing 20 P operations S=-13 (i.e 7-20 =-13)
V(S) increases the counting semaphore value
After finishing 15 V operations S=-13+15=2
Therefore Answer is 2 option B
S = 7 - 20 =-13(in suspended list)
S= -13+15 = 2
The resulting value of the semaphore is : 2 option b