Discussion
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 :
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.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development