GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Analyze resource-snapshot deadlock conditions

2 questions solved the same way, newest first. Back to Operating Systems

How these are solved

2006 asks a necessary condition for avoiding deadlock when processes already request Yi; 2019 asks a condition guaranteeing no process other than p,q can complete with requests of at most Yi.

2 marks · MCQ
Report issue

Resources required before another completion

Deadlocks

Question 39, GATE 2019: All instances of resource R are allocated. Process i holds Xi and may request at most Yi additional instances. Exactly p and q have Yp=Yq=0. Which condition guarantees no other process completes? A Xp+Xq<min other Yk; B Xp+Xq<max other Yk; C min(Xp,Xq)≥min other Yk; D min(Xp,Xq)≤max other Yk.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A under actual-remaining-demand interpretation

1. First solve the intended resource-demand model, where Yi is the amount process i still needs in order to finish. Because no resource instances are currently free, only p and q have enough resources to finish immediately.
2. Once both finish and release what they hold, the total available pool is A=Xp+Xq. No other process has released anything yet.
3. If A<min{Yk:k≠p,q}, then A is smaller than every remaining demand. There is no possible next finishing process, so the system cannot enlarge its free pool by further completions. This yields option A under that model.
4. Comparing A with the maximum demand, as in B, blocks only at least one large-demand process; a smaller-demand process may finish and release resources. C and D similarly do not establish insufficiency for every remaining process.
5. The literal wording is weaker: each Yi is an upper bound on additional requests, not a necessary demand. A process with positive Yi could actually need zero more instances and finish. For example, with Xp=Xq=1 and another process's bound Yk=3, A holds, yet that process may finish without requesting anything.
6. Thus the keyed A needs the actual-remaining-demand interpretation. Under upper bounds alone, the claimed guarantee is not justified. Preserve this model caveat rather than presenting A as unconditional.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Necessary resource-release condition

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
Tap to enlarge
Your answer
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.

Original paper, page 10