Consider a non-negative counting semaphore S. The operation P(s) decrements S, and V(s) increments S. During an execution, 20 P(s) operations and 12 V(s) operations are issued in some order. The largest initial value of S for which at least one P(s) operation will remain blocked is :
MH SET - 2024, SET Exam - 2024,
Answer: D
The largest initial value is 7.
Each P(s) consumes one unit and each V(s) supplies one. Starting from S, at most S + 12 of the P operations can ever complete. For at least one of the 20 P operations to remain blocked, that must be fewer than 20:
\[ \begin{aligned} S + 12 &\lt 20 \\ S &\lt 8 \end{aligned} \]
So S = 7 is the largest value. With S = 8, the 8 initial units plus 12 V operations are enough for all 20 P operations in a suitable order; 4, 5 and 6 also leave a P blocked but are not the largest.
Please log in or register to report this question.