Q. UGC NET CS 2018 July – II
At a particular time of computation, the value of a counting semaphore is 10. Then 12 P operations and “x” V operations were performed on this semaphore. If the final value of the semaphore is 7, x will be:
(A) 8
(B) 9
(C) 10
(D) 11
Answer:
Given: counting semaphore = 10. (capacity of critical section)
12 P (Down) operations are performed. So right now capacity of critical section= 10 – 12 = -2
After that “x” V (Up) operations are performed then capacity of critical section = -2 + “x”.
Now final value of semaphore (capacity of critical section) = 7 (given)
So, -2 + x = 7
x = 7 + 2 = 9
Option: B is correct.
P and down are the same operation.
V and up are the same operation.
Q. Gate-92
A counting semaphore was initialized to 10, then 6p (wait) and 4v (signal) operations were computed on this semaphore. What is the result?
Answer:
Given: counting semaphore = 10. (capacity of the critical section).
Now 6p (wait or down) operation are completed, Then counting semaphore = 10 - 6= 4.
After 4v (signal or up) operation are completed. So, right now counting semaphore = 4 + 4 = 8
Answer: is 8.