Similar questions 1 more →
Deadlocks
![Question 66, GATE 2006: There are n processes; process i holds xᵢ instances of a resource and requests yᵢ additional instances. All resource instances are allocated. Exactly two processes p,q have yₚ=y_q=0. Which can be a necessary condition for avoiding impending deadlock? Max/min below range over k≠p,q. GFG prints max in B; GateForum prints min, a materially different condition.
Options:
(A) min(xₚ,x_q)<max yₖ
(B) xₚ+x_q≥max yₖ [GFG]; xₚ+x_q≥min yₖ [GateForum]
(C) max(xₚ,x_q)>1
(D) min(xₚ,x_q)>1](../../assets/questions/CS-2006-Q66-1.webp)
Answer & solution
Answer: As printed, no listed condition is universally necessary (no official key was published)
1. Only p and q can initially finish without another allocation. After both finish, available resources equal W=xp+xq.
2. To make any further progress, at least one remaining process must have yk≤W; therefore W≥mink≠p,qyk is necessary (not sufficient for eventual completion of all processes).
3. The paper instead prints max in B: W≥max yk is sufficient, assuming these are remaining completion needs, but is not necessary. Counterexample: allocations (1,1,2,1), additional requests (0,0,1,3) have a safe sequence p,q,r,s: W grows 2→4→5, yet initial W=2<3.
4. No other the paper option is universally necessary: with all four allocations 1 and remaining requests (0,0,1,1), a safe sequence exists while A (1<1), C (1>1), and D (1>1) are false.
5. Teaching check: A necessary condition need not guarantee full completion. Once p and q release their holdings, at least one remaining process must be able to obtain its requested resources. Requiring enough for the largest request is stronger than necessary; a smaller request may finish first and release more resources.