GATE / CS ARCHIVE

SUBJECT COLLECTION

Operating Systems · Deadlocks

38 questions, newest first

GATE CSE has asked 38 questions on Deadlocks (Operating Systems) from 1992 to 2026, in 29 of the 46 papers; the most recent is in GATE CSE 2026 Set 1. In the last five years it carried 0.9 marks per 100-mark paper on average, against 1.1 since 2003. Since 2014 the questions have been 8 MCQ, 5 MSQ and 3 NAT. 7 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
1 mark · MSQ
Report issue

Distinguishing deadlock avoidance from prevention

Deadlocks

Question 29, GATE 2026: Select the false statements: A Banker’s algorithm is deadlock prevention; B disallowing hold-and-wait prevents deadlock; C an assignment edge in a resource-allocation graph goes from process to resource; D a safe state permits every process to finish without deadlock.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, C

Givens and goal

Select the false statements: A Banker’s algorithm is deadlock prevention; B disallowing hold-and-wait prevents deadlock; C an assignment edge in a resource-allocation graph goes from process to resource; D a safe state permits every process to finish without deadlock.

Approach

Distinguish the standard algorithm categories, recall graph edge direction, and interpret safety as existence of a safe completion sequence.

Step-by-step solution

1. Deadlock prevention structurally rules out at least one necessary condition, such as hold-and-wait. Avoidance instead examines potential grants and declines those that would leave the system unsafe.
2. Banker’s algorithm is an avoidance algorithm: it checks whether a safe completion sequence remains after a proposed allocation. Calling it prevention in the standard technical taxonomy is false, so select A.
3. If no process may hold resources while waiting for more, the hold-and-wait condition cannot hold. Since that condition is necessary for resource deadlock, B is true and must not be selected.
4. A request edge goes process→resource; an assignment edge goes resource-instance→process to indicate ownership. C reverses assignment direction, so select C.
5. A safe state means there is an order in which each process can obtain its remaining declared maximum need, finish, and release resources for later processes. That establishes D in the conventional safe-allocation sense.
6. Therefore the false statements are A and C. “Safe” asserts a feasible completion sequence under controlled allocation, not that arbitrary future grants can never make the system unsafe.

Original paper, page 22 · Answer key

1 mark · NAT
Report issue

Resources needed to rule out deadlock

Deadlocks

Question 35, GATE 2026: Five processes share k identical resource instances. Each process needs at most two, requests or releases only one at a time, and can request its second only after receiving its first. Find the smallest k guaranteeing freedom from resource deadlock.
Tap to enlarge
Answer & solution

Official answer: 6

Givens and goal

Five processes share k identical resource instances. Each process needs at most two, requests or releases only one at a time, and can request its second only after receiving its first. Find the smallest k guaranteeing freedom from resource deadlock.

Approach

Show an unsafe allocation for too few resources and prove that one additional resource always lets some process finish.

Step-by-step solution

1. With k=5, allocate one instance to each process. If all five then request a second, all five available instances are held and every process is waiting. No process can reach its maximum claim and finish: this is a possible deadlock.
2. Smaller positive capacities also fail to give a universal guarantee: the available instances can each be held by a different process waiting for its second, while the others wait for their first. Thus merely showing failure at five is consistent with the lower-capacity cases.
3. Now let k=6. If some process holds two instances, it has its complete maximum resource requirement and can finish without waiting for another instance, then release what it holds.
4. Otherwise each of the at most five processes holds at most one instance, so at most five are allocated. At least one of the six remains free. It can be granted as a second instance to a waiting holder, enabling that process to finish and release two.
5. Repeating the reasoning gives a safe sequence of completions, so a resource deadlock cannot arise. The smallest required capacity is 6.

This is the standard resource-deadlock model, assuming a process eventually completes when its maximum resource need is satisfied. It does not guarantee fair scheduling or rule out starvation caused by a scheduler.

Original paper, page 24 · Answer key

2 marks · MSQ
Report issue

Deadlocks

Question 48, GATE 2025: There are processes P1,…,P4 and one instance each of resources R1,…,R4. Ri is assigned to Pi. Current waits are P1→R2, P2→R3, P3→R1, P2→R4, P4→R2. The question calls these wait edges “claim edges.” Which actions make the system deadlock-free?
A. Abort P1 alone. B. Abort P3 alone. C. Abort P2 alone. D. Abort P1 and P4.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C, D

Step through it (5 checks)

Convert each wait on a resource into a wait on its current owner. The wait-for graph has edges P1→P2, P2→P3, P3→P1, P2→P4, P4→P2. It contains the cycles P1→P2→P3→P1 and P2→P4→P2. With one instance of each resource and actual blocking waits, such cycles characterize deadlock.

Aborting P1 removes the first cycle but leaves P2↔P4, so A fails. Aborting P3 has the same problem, so B fails. Aborting P2 removes a vertex common to both cycles. Remaining waits can be satisfied as resources are released, with no cycle left; C works. Aborting P1 and P4 removes one vertex from each cycle, leaving only P2→P3 among the surviving wait edges, so D also works.

The question asks which listed sets suffice, not which set uses the minimum number of abortions. Hence D remains correct even though C resolves the problem with fewer abortions. Use the question's explicit interpretation of “claim” as a current wait; a future potential-claim edge in deadlock-avoidance terminology would not imply the same present deadlock. Select C,D.

Original paper, page 37 · Answer key

2 marks · MSQ
Report issue

A semaphore ordering that can deadlock

Deadlocks

Question 46, GATE 2024: Threads share s1=1,s2=0,x=0. T1: wait(s1); x++; print(x); wait(s2); signal(s1). T2: wait(s1); x++; print(x); signal(s2); signal(s1). Possible outcomes? A T1 prints 1 then T2 prints 2; B T2 prints 1 then T1 prints 2; C T1 prints 1 then deadlock without T2 printing; D T2 prints 1 then deadlock without T1 printing.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Approach: Branch on which thread acquires s1 first, since this excludes the other thread from its increment.

1. Derivation. The first successful wait(s1) excludes the other thread. If T1 acquires it first, T1 increments and prints 1, then blocks on initially zero s2 while still holding s1; T2 cannot reach its signal(s2), so this deadlocks, giving C. If T2 acquires first, it prints 1 and signals s2 and s1. T1 can then acquire s1, print2, consume s2, and finish, giving B. Thus B, C.

2. Explanation and checks. In the T1-first branch the wait-for chain is T1 waiting for s2, which only T2 signals; T2 waits for s1, which T1 will not signal until its s2 wait finishes. In the T2-first branch signal(s2) either stores a permit or satisfies a waiting thread, so T1’s later wait(s2) cannot deadlock. The mutual exclusion around x prevents a lost increment, but it does not prevent the circular wait caused by the semaphore ordering.

Original paper, page 32 · Answer key

1 mark · MSQ
Report issue

Deadlocks

Question 26, GATE 2022: Select true deadlock statements: A circular wait is necessary; B with multiple instances per resource a wait-for cycle guarantees deadlock; C an unsafe allocation necessarily leads to deadlock; D if all resource-allocation edges are assignment edges, there is no deadlock.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A,D

Circular wait is a necessary Coffman condition, so A is true. With multiple instances per resource, a cycle alone need not imply deadlock: an external holder can release an instance and let a waiting process proceed. An unsafe state means some future demands may deadlock, not that deadlock must occur, so C is false. If every resource-allocation edge is an assignment, there are no request edges and therefore no waiting cycle, making D true. Thus A, D under the usual resource-allocation interpretation of the question’s wait-for terminology.

An unsafe state lacks a guaranteed completion sequence for all declared maximum demands; it need not be currently deadlocked. Processes may request less than their maxima or release resources. Without request edges no process is represented as waiting, so assignment-only graphs cannot contain the alternating request/assignment cycle needed for deadlock.

Original paper, page 20 · Answer key

2 marks · MSQ
Report issue

Deadlocks

Question 43, GATE 2021: One instance per resource type, exclusive ownership. OWNRESOURCE(R) acquires global lock L; if free, acquire R and release L; else if owned by another P, terminate P after freeing its resources, acquire R, restart P, release L. Select: A prevents deadlocks; B may livelock; C may starve; D violates mutual exclusion.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A; B; C

Under the intended atomic termination/resource-release model, a requester never waits for another process to release its resource: it terminates that owner and takes the resource while holding L. Thus no circular resource wait develops, giving A. Two restarted processes can repeatedly take resources from and restart each other without completing, giving livelock B. An unfair execution can repeatedly kill the same process before it finishes, giving starvation C. The global lock and removal of the previous owner preserve exclusive ownership, so D is false. This assumes requests concern resources not already owned by the requester and that termination/restart do not themselves block on L; those implementation details are abstracted by the pseudocode.

For a livelock witness, let P hold A and Q hold B. P requests B, kills and restarts Q; later restarted Q requests a resource now held by P and kills/restarts P. Repeating such interference can prevent either from completing despite activity. A lock provides mutual exclusion, not fairness or progress. The answer depends on treating termination and resource release as atomic successful operations in the model.

Original paper, page 80 · Answer key

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

1 mark · NAT
Report issue

Resource bound preventing deadlock

Deadlocks

Question 24, GATE 2018: Three processes share four identical resource instances. Each can need at most K, requesting and releasing one at a time. Find the largest K guaranteeing no deadlock.
Tap to enlarge
Answer & solution

Official answer: 2

Method

If every unfinished process has fewer than its maximum requirement, each may hold at most K−1 while waiting for another instance. With K=2, three such waiting processes can hold at most three resources, leaving the fourth available to let one finish. Releasing its resources then enables the others. For K=3, a feasible allocation (2,1,1) consumes all resources while each process can still request one; no request can be granted. This supplies both safety and a tight counterexample.

Solution

For n=3 processes each requiring at most K identical resources, a sufficient and tight universal bound is R≥n(K−1)+1: for K=2, any allocation in which all three processes still need another instance leaves at least one of the four resources free; for K=3 the allocation (2,1,1) can instead exhaust all resources with all processes waiting. With R=4, K=2 satisfies 4≥4, while K=3 permits holdings2, 1, 1 and all waiting. Thus the largest guaranteed-safe K is 2, assuming completed processes release their resources.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

A Banker safety sequence

Deadlocks

Question 39, GATE 2018: Available (E,F,G)=(3,3,0). Allocation rows P0…P3 are (1,0,1),(1,1,2),(1,0,3),(2,0,0); Max rows are (4,3,1),(2,1,4),(1,3,3),(5,4,1). Choose A safe already; B unsafe but safe with one extra E; C likewise extra F; D likewise extra G.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (6 steps)

Method

Banker’s safety test asks whether there exists an order in which each process can obtain all its remaining need and release its allocation. Need=Max−Allocation, computed component by component. After hypothetically finishing a process, Work increases by its original Allocation, not by its Max: any temporary extra resources lent from Work are returned, cancelling out. Initially P0 and P2 are both eligible. Exhibiting one complete order suffices; the algorithm need not show that every arbitrary request order is safe.

Solution

Subtract Allocation from Max to obtain remaining needs P0=(3, 3, 0), P1=(1, 0, 2), P2=(0, 3, 0), P3=(3, 4, 1). Starting Work=(3, 3, 0), complete P0 to get(4, 3, 1), then P2 to get(5, 3, 4), then P1 to get(6, 4, 6), then P3. This safe sequence proves A.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 27, GATE 2017: A program has x threads and y non-reentrant locks. A thread cannot reacquire a lock it holds, and blocks if acquisition fails. Find minimum x,y allowing deadlock. A (1,2); B (2,1); C (2,2); D (1,1).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Consider a single thread and one initially free non-reentrant lock L. The thread acquires L successfully.

2. Before releasing L, let the same thread request L again. The non-reentrancy rule blocks it because L is already held, even though the holder is itself.

3. Only this blocked thread could release L, so it cannot progress: self-deadlock. At least one thread and one lock are needed to discuss this failure, and this example achieves both minima. Answer D.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 42, GATE 2017: Transactions receive unique Lamport timestamps. T1 holds resource R; T2 requests a conflicting lock. If TS(T2)<TS(T1), kill T1; otherwise T2 waits. Killed transactions restart with the same timestamp; any transaction not killed eventually terminates. A both deadlock-free and starvation-free; B deadlock-free only; C starvation-free only; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Smaller timestamps denote older transactions. An older requester wounds a younger holder; a younger requester waits rather than aborting the older holder. This is wound-wait.

2. Every actual waiting edge points from a younger transaction to an older one, so timestamps strictly decrease along waits. A directed cycle would require returning to the original timestamp after strict decreases, impossible. Hence no deadlock.

3. A restarted transaction keeps its old timestamp, so it does not repeatedly become youngest. With the stated eventual-termination assumption and finitely many older predecessors, those predecessors finish and it ultimately becomes able to proceed. This is the intended starvation-free guarantee, A.

Original paper, page 19 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 33, GATE 2017: A system has 9 tape drives. Processes (current allocation,maximum requirement) are P1:(3,7), P2:(1,6), P3:(3,5). Classify the state. A:safe,deadlocked. B:safe,not deadlocked. C:not safe,deadlocked. D:not safe,not deadlocked.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (5 steps)

1. Current allocations total 3+1+3=7, leaving 9-7=2 drives available. Remaining maximum needs are P1:7-3=4, P2:6-1=5, P3:5-3=2.

2. P3 can receive its remaining two drives and finish. It then returns all five drives, leaving five available to the other processes. Equivalently, in the safety simulation add its existing allocation 3 to the current available count 2.

3. Now P1 can finish and release its three previously allocated drives, raising available to 8; P2 can then finish. Thus P3,P1,P2 is a safe sequence (P3,P2,P1 also works). Existence of a safe sequence establishes safe and not deadlocked, B.

Original paper, page 13 · Answer key

1 mark · MCQ
Report issue

Deadlocks

Question 30, GATE 2015: A system has 6 identical resources, N processes, each claiming at most 2 resources. Which N could deadlock? A1, B2, C3, D4. Published answer D conflicts with literal total-claim premises.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Our answer: None under maximum-total-claim reading; official D

With maximum claim 2, a blocked process can hold at most 1 resource. If all N≤4 processes are blocked, at most 4 of the 6 resources are held, leaving enough to satisfy at least one pending request. Hence deadlock is impossible for every listed N. Six processes each holding 1 and requesting 1 provide the first possible deadlock. Official D (N=4) conflicts with the stated 6 resources/max 2 total claim; do not silently change either premise.

If a process has obtained both resources it needs, it can finish and release them. A blocked unfinished process therefore holds at most one unit. With N≤4, even if every process holds one, at most 4 of 6 units are occupied, leaving spare units to let a process finish. In general, R≥N(maxclaim−1)+1 guarantees this progress for identical reusable units. For maxclaim 2, the first deadlock configuration is 6 processes each holding 1 and waiting for 1. None of the four offered counts realizes it; preserve the published D only as a conflicting score, not the mathematical conclusion.

Original paper, page 36 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 45, GATE 2015: For mutually exclusive resources, which policies can prevent deadlock? I: A process acquires all resources at the start; if any is unavailable, it releases those acquired so far. II: Resources have unique numbers and requests occur only in increasing number order. III: Resources have unique numbers and requests occur only in decreasing number order. IV: Resources have unique numbers and a process may request only a resource numbered higher than all resources it currently holds. Options: (A) any one of I and III, but not II or IV; (B) any one of I,III,IV, but not II; (C) any one of II and III, but not I or IV; (D) any one of I,II,III,IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. I removes hold-and-wait by releasing partial acquisitions if all cannot be obtained.

2. II and III each impose a strict global resource order, excluding circular wait. IV likewise permits only requests larger than every held resource, so any wait cycle would require strictly increasing numbers around a loop, impossible. Each policy individually prevents deadlock, D; this does not promise starvation freedom.

Original paper, page 69 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 31, GATE 2014: Banker’s algorithm manages resources X,Y,Z for P0,P1,P2. Allocation rows are P0=(0,0,1), P1=(3,2,0), P2=(2,1,1); maximum-demand rows are P0=(8,4,3), P1=(6,2,0), P2=(3,3,3). Available=(3,2,2), and the current state is safe. Consider independent requests: REQ1 P0 asks (0,0,2); REQ2 P1 asks (2,0,0). Which may be granted safely? A: REQ1 only. B: REQ2 only. C: both. D: neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (2 checks)

1. Method and setup. Compute Need=Max−Allocation. For each request separately, tentatively decrease Available and increase the requester’s Allocation, then try to find a complete safe sequence. Sufficient available resources for the immediate grant is necessary but not sufficient; the updated state must still permit every process to finish.

2. Work through the result and its assumptions. Initial needs are P0=(8, 4, 2), P1=(3, 0, 0), P2=(1, 2, 2). Grant REQ1: available=(3, 2, 0); only P1 can finish, releasing(3, 2, 0) to give(6, 4, 0). Neither remaining process can finish, so unsafe. Grant REQ2: available=(1, 2, 2), P1 need=(1, 0, 0); finish P1 to get(6, 4, 2), then P2 to get(8, 5, 3), then P0. Only REQ2 is safe, B.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

Deadlocks

Question 31, GATE 2014: Three programs each require three tape units to operate. What is the minimum number of tape units that guarantees no resource deadlock?
Tap to enlarge
Answer & solution

Official answer: 7

Step 1: Exhibit a deadlock with six units: each program holds two and waits for a third, leaving no free unit and no program able to finish. Thus six is insufficient. Step 2: With seven units, if no program yet holds its full requirement, each holds at most two and together they hold at most six. At least one unit remains available to let some program reach three and finish. Step 3: Its release permits the others to progress. Hence the minimum is 3(3−1)+1=7 under the usual reusable-resource model, maximum demand of three, and eventual completion/release once the demand is met.

Original paper, page 60 · Answer key

1 mark · MCQ
Report issue

Deadlock-free semaphore acquisition

Deadlocks

Question 16, GATE 2013: Binary semaphores a, b, c, d start at 1. X acquires a, b, c; Y acquires b, c, d; Z acquires c, d, a, then each releases its three locks after work. Which acquisition ordering is deadlock-free? A X:abc, Y:bcd, Z:cda; B X:bac, Y:bcd, Z:acd; C X:bac, Y:cbd, Z:acd; D X:abc, Y:cbd, Z:cda.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Option B respects a single global order b<a<c<d in every process: X takes b, a, c; Y takes b, c, d; Z takes a, c, d. A circular wait would require strictly increasing lock ranks around a cycle, which is impossible. The other choices admit contradictory acquisition orders and circular-wait executions. Thus B.

Assign ranks b=1, a=2, c=3, d=4. In B every process acquires strictly increasing ranks, so a process holding one lock can wait only for a higher-ranked lock. A circular chain would require rank to increase all the way back to its starting value, which is impossible. For contrast, A permits X holding a while Z holds c, d and waits for a, with X eventually waiting for c. C permits X holding b and Y holding c, each waiting for the other. D permits X holding a, b and Z holding c, d, with X waiting for c and Z for a. These are concrete circular waits, not merely inconvenient orderings.

Original paper, page 4 · Answer key

2 marks · MCQ
Report issue

Deadlock from opposite resource orders

Deadlocks

Question 46, GATE 2010: There are n single-instance resources R₀,…,Rₙ₋₁ and k processes P₀,…,Pₖ₋₁. Each process Pᵢ requests resources using:
if(i%2==0) {
 if(i<n) request Rᵢ;
 if(i+2<n) request Rᵢ₊₂;
} else {
 if(i<n) request Rₙ₋ᵢ;
 if(i−2<n) request Rₙ₋ᵢ₋₂;
}
For which offered n,k is deadlock possible? The odd-branch subscripts are faint in the scan; the explicit reading above preserves the inherited interpretation. The second odd-branch guard is printed i−2<n, not silently repaired.
Options: (A) n=40,k=26; (B) n=21,k=12; (C) n=20,k=10; (D) n=41,k=19.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Read the code as even i requesting Ri followed by R(i+2), and odd i requesting R(n−i) followed by R(n−i−2), subject to the printed guards. For n=21,k=12, P10 requests R10 then R12, while P9 requests R12 then R10. If each obtains its first resource, they wait on each other: deadlock is possible, B. For even n (A and C), even processes use only even-indexed resources in increasing order, while odd processes use only odd-indexed resources in decreasing order. Each parity class has a consistent order, so neither can cycle. For D, n=41,k=19: even processes use resources 0 through 20, whereas odd processes use even resources 22 through 40, so these opposite-order sets do not overlap and cannot form a cycle. This uses single-instance, non-preemptive resources held until completion, the standard deadlock model. The low-quality scan has faint minus signs/subscripts in the odd branch; the relevant R(n−i),R(n−i−2) reading is recorded explicitly.

The deadlocking B execution can be written explicitly: P10 acquires R10; P9 acquires R12; P10 blocks requesting R12; P9 blocks requesting R10. The resource-allocation graph now has a cycle with single-instance resources. Consistent increasing or decreasing order prevents cycles within one resource set, but opposing orders on overlapping resources can create the exhibited cycle.

Original paper, page 11

2 marks · MCQ
Report issue

Concurrent resource requests and completion

Deadlocks

Question 30, GATE 2009: Resources R1, R2, R3, R4 have totals 3, 2, 3, 2. Requests are nonpreemptive and all-or-nothing. Independent progress timelines: P1 t0 requests 2R2, t1 requests 1R3, t3 requests 2R1, t5 releases 1R2+1R1, t7 releases 1R3, t8 requests 2R4, t10 finishes. P2 t0 requests 2R3, t2 requests 1R4, t4 requests 1R1, t6 releases 1R3, t8 finishes. P3 t0 requests 1R4, t2 requests 2R1, t5 releases 2R1, t7 requests 1R2, t8 requests 1R3, t9 finishes. Starting together, choose A all finish; B only P1/P2 deadlock; C only P1/P3 deadlock; D all deadlock.
Tap to enlarge
Your answer
Answer & solution

Answer: A under blocked-process local time (no official key was published)

Initially P1 holds both R2 units, P2 two R3 units, and P3 one R4. P1 obtains its R3 at 1; P2 obtains its R4 and P3 two R1 at 2. P1 then waits for two R1 at 3 because only one is free. P2 can take that last R1 at 4. At 5 P3 releases its two R1, allowing P1 to resume. Its local-time 5 releases now occur at wall time 7, providing the R2 requested by P3. P2 releases R3 at 6 and finishes at 8, so P3 can obtain R3 at 8 and finish at 9. P1’s later two-R4 request can be satisfied after those completions, and it finishes. No circular wait persists; A. The timeline treats each listed time as progress time in an independently running process, with blocked execution delayed.

A temporary wait is not sufficient evidence of deadlock: check whether another process can still progress and release the needed resource. At time 3, P1 lacks its two R1 units, but P3 will release two at time 5 without needing anything from P1 first. That release allows P1 to resume. P1’s later release of R2 lets P3 progress; P2 independently releases R3 and finishes. The dependency chain therefore has an escape. Using progress times delayed during blocking gives the timeline above and all processes eventually finish, A. Treating delayed operations as occurring retroactively at their original wall times would be inconsistent.

Original paper, page 7

2 marks · MCQ
Report issue

Deadlock prevention versus avoidance

Deadlocks

Question 65, GATE 2008: Which is NOT true of deadlock prevention and avoidance?

(A) Prevention always grants a request if the resulting state is safe
(B) Avoidance always grants a request if the resulting state is safe
(C) Avoidance is less restrictive than prevention
(D) Avoidance needs resource requirements known in advance
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Prevention breaks a necessary condition for deadlock, for example by requiring a fixed acquisition order or all-at-once requests. It may deny a request even though granting it would leave a safe state.
2. Avoidance explicitly tests safety using declared maximum needs and grants an otherwise valid request if safety is preserved.
3. Thus A incorrectly attributes avoidance’s rule to prevention. The conventional comparison makes B,C,D true: avoidance is less structurally restrictive but needs advance resource information.

Original paper, page 13

2 marks · MCQ
Report issue

Safe completion order from available resources

Deadlocks

Question 57, GATE 2007: Three processes share resource types X,Y,Z, with 5 units of each. Allocated and additionally requested vectors (X,Y,Z) are: P0 alloc=(1,2,1), request=(1,0,3); P1 alloc=(2,0,1), request=(0,1,2); P2 alloc=(2,2,1), request=(1,2,0). Each request is needed to finish, after which resources are released. Which process finishes last?
Options:
(A) P0
(B) P1
(C) P2
(D) None; the system is deadlocked
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (5 steps)

1. Approach. Subtract all allocations from the total vector to obtain current availability. Repeatedly choose a process whose remaining request fits componentwise, then add its old allocation back to availability.

2. Derivation and interpretation. Allocated totals are (1,2,1)+(2,0,1)+(2,2,1)=(5,4,3), so the initial available vector is (0,1,2). Only P1's remaining request (0,1,2) can be met. After P1 completes and returns all its resources, availability becomes (0,1,2)+(2,0,1)=(2,1,3). P0's request (1,0,3) can now be met, while P2 still needs two Y units but only one is available. P0 finishes next, leaving availability (2,1,3)+(1,2,1)=(3,3,4), which permits P2's request (1,2,0). The forced safe order is P1,P0,P2, so P2 finishes last (C), assuming each request is the additional resource vector needed for completion as stated.

Original paper, page 14

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

2 marks · MCQ
Report issue

Sufficient condition preventing resource deadlock

Deadlocks

Question 71, GATE 2005: n processes share m identical reusable units, acquired/released one at a time. Process i has positive maximum need s_i. Which is sufficient to avoid resource deadlock? A every s_i<m; B every s_i<n; C Σs_i<m+n; D Σs_i<m·n.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

If no process can finish, every process can hold at most si−1 units while still needing another unit. Thus at most sum(si−1)=sum(si)−n units can be held in an all-unfinished configuration. If sum(si)<m+n, this total is less than m, so at least one resource is free; allocating available units eventually lets a process reach its maximum and finish. Release its resources and repeat. Equivalently m>sum(si−1) guarantees progress for the single resource type. This is option C.

Suppose every unfinished process is blocked below its maximum claim. It can hold at most si−1 units, so together they can hold at mostΣ(si−1). If m exceeds that bound, some units remain available and can be allocated until at least one process finishes; its release only improves the position. Rearranging m>Σsi−n gives option C. Individual small claims alone do not prevent circular waiting among multiple processes.

Original paper, page 9

2 marks · MCQ
Report issue

Common semaphore acquisition order

Deadlocks

Question 48, GATE 2004: Shared X,Y are protected by binary semaphores Sx,Sy, initially 1. P waits/decrements and V signals/increments. Fill L1,L2,L3,L4 to avoid deadlock:
P1: while true {
  L1; L2; X=X+1; Y=Y-1; V(Sx); V(Sy);
}
P2: while true {
  L3; L4; Y=Y+1; X=X-1; V(Sy); V(Sx);
}
GateForum prints X=Y−1 in P2; that arithmetic variant does not change the locking question.
Options:
(A) P(Sy),P(Sx),P(Sx),P(Sy)
(B) P(Sx),P(Sy),P(Sy),P(Sx)
(C) P(Sx),P(Sx),P(Sy),P(Sy)
(D) P(Sx),P(Sy),P(Sx),P(Sy)
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Both processes must acquire both Sx and Sy, exactly once, in the same global order. Option D supplies P(Sx),P(Sy) to both processes.

2. A process that has acquired Sx prevents its competitor from holding Sy while it waits for Sx, so the circular-wait condition is impossible. Options A/B use opposite acquisition orders and admit deadlock; C acquires the same binary semaphore twice and can block itself.

3. Different release orders do not invalidate the common acquisition order.

4. Teaching check: Construct an opposite-order deadlock: P1 holds Sx and waits for Sy while P2 holds Sy and waits for Sx. Requiring the same acquisition order eliminates this cycle. A release-order difference is harmless here because neither process waits while executing V.

Original paper, page 7

Descriptive
Report issue

Exhibit a deadlocking interleaving

Deadlocks

Question 19(b), GATE 2001: GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation.
Question 19(b), GATE 2001: GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation.
Tap to enlarge
Answer & solution

Answer: Yes: S1, S2, Q1, Q2, then P1 waits at S3 and P2 waits at Q3 (no official key was published)

Initially both flags are free. Let P1 pass S1 and execute S2, so R1 becomes busy. Let P2 pass Q1 and execute Q2, so R2 becomes busy. P1 now spins in S3 waiting for R2; P2 spins in Q3 waiting for R1. Neither can reach its use or release operations. The wait-for graph is P1→P2→P1: each holds its first resource while waiting for the other.

P2 then spins at Q3 on R1, the flag it set itself. P1 spins at S1 on R1. No process can reach a release. This is a self-wait plus a blocked competitor, rather than the intended two-resource circular wait.

Original paper, page 10

1 mark · MCQ
Report issue

Circular acquisition of binary semaphores

Deadlocks

Question 1.21, GATE 2000: Processes P[0]…P[4] use mutexes m[0]…m[4]. Each waits on m[i], then m[(i+1) mod4], before releasing them. Can this cause thrashing, deadlock, starvation without deadlock, or none?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Schedule P0,P1,P2,P3 so each acquires its first mutex before any attempts the second. They now hold m0,m1,m2,m3 respectively.

Step 2: P0 waits for m1, P1 for m2, P2 for m3, and P3 for m0. Each resource is held by the next blocked process, creating a circular wait.

Thus deadlock is possible, B. The printed modulus is 4 even though five processes/mutexes are named; the four-process cycle already proves the result without silently changing it to 5. P4 does not remove this cycle.

Original paper, page 3

2 marks · MCQ
Report issue

A rule that fails to prevent deadlock

Deadlocks

Question 2.23, GATE 2000: Which is not a valid general prevention policy: release all before requesting a new resource; request only in increasing resource-number order; never request after releasing any resource; acquire all required resources before execution?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Releasing all held resources before a new request removes hold-and-wait. A global increasing order removes circular wait. Atomic acquisition of the full required set before running also avoids partial hold-and-wait.

Step 2: Merely forbidding requests after the first release does not prevent deadlock during the initial acquisition phase. Process P can hold A and request B while Q holds B and requests A; neither has released anything, so both obey that rule.

Thus C is insufficient. The prevention interpretation presumes the usual nonreentrant-resource model and an all-or-nothing initial acquisition policy in the last option.

Original paper, page 6

1 mark · MCQ
Report issue

Deadlock-free tape-drive bound

Deadlocks

Question 1.32, GATE 1998: Six identical tape drives are shared by n processes, each needing at most two. Find the largest n guaranteeing no resource deadlock among 6, 5, 4, 3.
Tap to enlarge
Your answer
Answer & solution

Answer: B: 5 under unrestricted incremental allocation (no official key was published)

The dangerous state gives each process one drive while it waits for a second. With n≤5, at least one of six drives remains free, so some waiting process can receive its second, finish and release both; repeat to complete others. With n=6, all six can hold one and wait forever for a second, producing deadlock. Therefore the largest guaranteed-safe n is 5, B. This is a worst-case allocation guarantee, assuming eventual release and no other resources; an avoidance policy could safely serialize more processes.

Original paper, page 3

2 marks · MCQ
Report issue

Resource count excluding deadlock

Deadlocks

Question 6.7, GATE 1997: Three processes each may require two units of one resource. Minimum units guaranteeing no allocation deadlock among 3, 5, 4, 6?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 4 (no official key was published)

With only three units, each process can hold one and wait for a second, creating deadlock. With four units, if all unfinished processes hold at most one, at least one unit remains available to give some process its second. It can finish and release its units, after which the argument repeats. Therefore four is sufficient and three can fail, so C. This is the standard worst-case incremental-allocation guarantee with eventual completion and no other resources; a restrictive admission policy could safely serialize processes with fewer units.

Original paper, page 6

3 marks · Descriptive
Report issue

Deadlock freedom of wound-wait

Deadlocks

Question 75(a), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can deadlock ever arise? Prove your answer.
Question 75(a), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can deadlock ever arise? Prove your answer.
Tap to enlarge
Answer & solution

Answer: No resource deadlock: every wait-for edge points from a younger process to an older process, so a cycle is impossible. (no official key was published)

Form a wait-for graph whose vertices are active processes. Add an edge P→Q when P is blocked waiting for a resource currently held by Q. The rules allow that wait only when TS(Q)<TS(P). If the holder is younger, the requester does not wait; it wounds the holder, whose resources are released on restart. Therefore timestamps strictly decrease along every wait-for edge.

Suppose a resource deadlock existed. For ordinary exclusive resources, a finite set of processes each blocked on resources held within the set contains a directed cycle P1→P2→…→Pk→P1. The edge rule would imply
TS(P1)>TS(P2)>…>TS(Pk)>TS(P1),
which is impossible for distinct ordered timestamps. Thus the wait-for graph is acyclic and the stated resource protocol cannot create deadlock.

For intuition, an older process can force a younger holder to release its resources rather than becoming dependent on it. A younger process may depend on an older one, but dependencies can never turn back toward a younger timestamp to close a cycle. This is the wound-wait scheme, not wait-die: the older requester survives and restarts the younger holder.

The restart must release all resources of the victim, as the source explicitly states; retaining them while the victim cannot proceed would not implement this proof's protocol. Resource grants, victim removal and wait-queue updates are assumed to be performed consistently by the OS. The argument rules out resource deadlock, not every possible lack of progress. An unfair CPU scheduler or a process that never finishes could still delay other processes indefinitely; those are separate starvation/liveness issues addressed under additional assumptions in the next part.

Original paper, page 12

2 marks · Descriptive
Report issue

Starvation analysis with retained timestamps

Deadlocks

Question 75(b), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can a process be starved? Prove or qualify your answer.
Question 75(b), GATE 1997: Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can a process be starved? Prove or qualify your answer.
Tap to enlarge
Answer & solution

Answer: No protocol-induced starvation under finite older predecessors, finite terminating work, and fair execution; an unconditional guarantee without these progress assumptions is not justified. (no official key was published)

Fix a process P. When it begins there are only finitely many older processes in the usual finite-system model, and every later arrival has a larger timestamp. Because a restarted process keeps its original timestamp, repeated restarts do not move P behind newcomers. Only processes older than P can wound it or outrank it on a waiting queue.

First consider the oldest active process. It cannot be wounded, and it cannot be forced to wait for a younger holder: it wounds that holder and obtains the resource. Under fair CPU execution and the stated assumption that a process does finite work and exits, this oldest process eventually completes and releases its resources. Apply the same argument successively to the remaining older processes. Since P has finitely many older predecessors, eventually they have all completed.

P is then the oldest remaining process. New arrivals remain younger and cannot wound P. A resource held by a younger process is obtained by wounding that holder; if P is already waiting when a resource is released, smallest-timestamp selection gives it precedence over younger waiters. With finite resource requests/work and fair execution, P therefore finishes. This proves absence of starvation caused by the allocation protocol under the usual progress assumptions.

Retaining timestamps is crucial. Assigning a fresh, ever-larger timestamp after every restart would destroy the fixed finite-predecessor argument. Conversely, deadlock freedom by itself would not prove starvation freedom: an acyclic system could still repeatedly favor newcomers under a different queue rule.

The question's finite-use-and-exit wording motivates the normal no-starvation answer, but scheduler fairness is not explicitly specified. If the CPU never schedules P, or an older process never finishes, P may wait indefinitely despite the timestamp rules. Those countermodels violate the progress assumptions used in the proof; they do not exhibit a starvation defect in wound-wait itself. State the assumptions rather than claiming unconditional termination from timestamp ordering alone.

Original paper, page 12

2 marks · MCQ
Report issue

Breaking circular wait at dinner

Deadlocks

Question 2.19, GATE 1996: Which fork-taking rule prevents dining-philosopher deadlock: all left first, all right first, or one philosopher reversing the order used by everyone else?
Tap to enlarge
Your answer
Answer & solution

Answer: C: one reverses the order (no official key was published)

If every philosopher takes the same side first, all can hold one fork and wait for the next, forming a circular wait. Reversing one philosopher’s order breaks that directed cycle: the neighboring philosophers compete for a common first fork, so they cannot all simultaneously hold distinct first forks while each awaits the next. Consequently the full circular-wait deadlock is impossible in the standard ring model. This prevents deadlock, not necessarily starvation without a fairness assumption. The uniform-left and uniform-right rules both retain the circular wait.

Original paper, page 6

Descriptive
Report issue

Safety of the Banker state

Deadlocks

Question 22(a), GATE 1996: Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Show that this can be a state admitted by the Banker’s algorithm.
Question 22(a), GATE 1996: Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Show that this can be a state admitted by the Banker’s algorithm.
Tap to enlarge
Answer & solution

Answer: Safe sequence P1→P2→P0; Work evolves (2,2,0)→(2,5,1)→(3,5,3)→(4,5,5). (no official key was published)

Step through it (5 steps)

The table heading “Maximum Need” gives total claims, not outstanding requests. Subtract each allocation to obtain remaining Need: P0=(3,1,0), P1=(1,2,0), P2=(0,2,1). The total resource vector is Available plus all allocations, namely (4,5,5); every maximum is individually within this total.

Run the safety test with Work=(2,2,0). P0 cannot finish yet because it needs 3 units of R0 but only 2 are free. P2 cannot finish because it needs one R2 while none is free. P1 can finish since (1,2,0) is componentwise at most (2,2,0). After it finishes, Work increases by its current allocation (0,3,1), yielding (2,5,1). Adding allocation, rather than maximum, is correct: its extra temporary requests are returned too, leaving the net increase equal to the allocation it already held.

Now P2's need (0,2,1) fits, so its completion releases (1,0,2) and Work becomes (3,5,3). Finally P0's need (3,1,0) fits; releasing (1,0,2) yields (4,5,5). Thus P1,P2,P0 is a safe sequence, proving that all claims can be satisfied in a suitable order. Safety does not assert that every possible future request is immediately grantable; it establishes at least one completion schedule from the current allocations.

Original paper, page 10

Descriptive
Report issue

Testing a Banker resource request

Deadlocks

Question 22(b), GATE 1996: Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Determine what happens when P0 requests one unit of R1.
Question 22(b), GATE 1996: Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Determine what happens when P0 requests one unit of R1.
Tap to enlarge
Answer & solution

Answer: Defer P0’s request: tentative Available=(2,1,0) is unsafe although the unit is available. (no official key was published)

Step through it (4 steps)

The request vector is R=(0,1,0). First check R<=Need0=(3,1,0), so the request does not exceed P0's remaining claim. Also R<=Available=(2,2,0), so the requested unit is physically available. These necessary checks alone do not justify granting it.

Tentatively allocate the unit. Available becomes (2,1,0), P0's allocation becomes (1,1,2), and P0's remaining need becomes (3,0,0). The other needs remain P1=(1,2,0), P2=(0,2,1). Begin the safety test with Work=(2,1,0). P0 cannot finish because 3>2 in R0; P1 cannot finish because 2>1 in R1; P2 cannot finish because it needs 2 R1 and 1 R2, while only 1 R1 and 0 R2 are free. No process can be the first in a guaranteed completion sequence.

The tentative state is therefore unsafe. The Banker rolls back the tentative change and makes P0 wait, preserving Available=(2,2,0) and the original safe allocations. This is not a claim that the request is invalid or that an actual deadlock has already occurred. It is a refusal to enter a state from which completion under all declared maximum claims cannot be guaranteed. The one free unit's availability is precisely why a full safety test, rather than a simple availability check, is needed.

Original paper, page 10

Descriptive
Report issue

Deadlock detection with multiple resource instances

Deadlocks

Question 28(a), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. Does the depicted resource-allocation graph represent deadlock?
Question 28(a), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. Does the depicted resource-allocation graph represent deadlock?
Question 28(a), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. Does the depicted resource-allocation graph represent deadlock?
Tap to enlarge
Answer & solution

Answer: No, under the standard assumption that a process finishes and releases its holdings after its depicted requests are granted. (no official key was published)

Read each dot-to-process arrow as an allocated instance and each process-to-resource arrow as an outstanding request. In resource order (r1,r2,r3), total resources are (2,3,2). The allocation rows are P0=(1,0,1), P1=(1,1,0), P2=(0,1,0), P3=(0,1,0); their sum is (2,3,1), leaving Work=(0,0,1). The request rows are P0=(0,1,1), P1=(1,0,0), P2=(0,0,1), P3=(1,2,0). The two parallel P3→r2 arrows mean two requested instances, not a duplicated decorative edge.

Initially P2 is the process whose request vector is componentwise at most Work. Give it the free r3 instance. Under the standard graph-reduction model it completes, releasing that temporary grant and its held r2 instance. Consequently Work increases by its original allocation, from (0,0,1) to (0,1,1). P0 can now receive its requested r2 and r3 instances and complete, increasing Work to (1,1,2). P1 can then finish and increase Work to (2,2,2). Finally P3's request (1,2,0) is satisfiable, so it also completes.

All process nodes can be removed, so the current graph does not describe a deadlock. Cycles alone are insufficient to infer deadlock when resource types have multiple instances. This is a reduction of the displayed current requests, not a claim of Banker safety against unknown additional future maximum demands; no such maxima are supplied.

Original paper, page 7

Descriptive
Report issue

Constructing a resource completion order

Deadlocks

Question 28(b), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. If the system is not deadlocked, give a safe completion sequence.
Question 28(b), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. If the system is not deadlocked, give a safe completion sequence.
Question 28(b), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. If the system is not deadlocked, give a safe completion sequence.
Question 28(b), GATE 1994: Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. If the system is not deadlocked, give a safe completion sequence.
Tap to enlarge
Answer & solution

Answer: P2 → P0 → P1 → P3. (no official key was published)

Use the available-vector test in resource order (r1,r2,r3). Initially Work=(0,0,1). P2 requests (0,0,1), so its request fits. On completion its original holding (0,1,0) returns to the available pool, giving Work=(0,1,1). It is important not to count the temporarily granted r3 twice: allocation-based reduction adds only the allocation it held before this simulated completion.

Next P0 requests (0,1,1), exactly within Work. It finishes and releases original allocation (1,0,1), making Work=(1,1,2). P1's outstanding request (1,0,0) now fits; releasing its original allocation (1,1,0) gives Work=(2,2,2). P3 can finally receive (1,2,0); releasing its original holding (0,1,0) gives Work=(2,3,2), the complete resource inventory. Thus P2,P0,P1,P3 is a valid completion sequence.

Indeed the initial choices are forced by the displayed requests: P0 initially lacks r2, while P1 and P3 lack r1. After P2, P0 is the only remaining satisfiable process. After P0, P3 still needs two free r2 instances but only one is available, forcing P1 before P3. Under simultaneous satisfaction of the displayed request vectors this order is therefore unique. As in part (a), “safe” means all these displayed requests can be satisfied and the processes finish; the graph does not state maximum possible future claims, so a stronger Banker's-algorithm safety assertion is outside the supplied data.

Original paper, page 7

2 marks · MSQ
Report issue

Resource supply guaranteeing no deadlock

Deadlocks

Question 7.9, GATE 1993: Three processes have maximum same-resource demands 3,4,6. Among m=7,9,10,13,15,which supplies guarantee no resource deadlock?
Tap to enlarge
Select all that apply
Answer & solution

Answer: D,E: 13 and 15; exact threshold 11 (no official key was published)

If all three unfinished processes hold one less than their maxima, they can hold 2+3+5=10 units and still each request another. Thus ten units can deadlock, and smaller listed supplies can also be exhausted among unsatisfied processes. With eleven units, at least one additional unit is available whenever all processes are below their maxima, enabling some process to reach its demand, finish and release resources. Repeating resolves the rest. Therefore every supply at least eleven is safe under the standard completion model; the listed qualifying values are 13 and 15, not only the smaller of them.

Original paper, page 8

Report issue

Maximum process count with six drives

Deadlocks

Question 2(xi), GATE 1992: Six identical tape drives are shared by n processes, each possibly needing three. What maximum n guarantees no resource deadlock without restrictive allocation?
Question 2(xi), GATE 1992: Six identical tape drives are shared by n processes, each possibly needing three. What maximum n guarantees no resource deadlock without restrictive allocation?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A: n=2 (no official key was published)

A worst-case deadlock can have every process hold two drives and wait for its third. To rule that out for n processes, at least 2n+1 drives suffice under the standard completion model. With six drives, this requires n≤2. For three processes, each can hold two, exhausting all six and waiting forever. For two processes, their combined maximum demand is six, so both can be fully satisfied. The guarantee assumes eventual completion after required resources are granted and no additional resource types or faulty nontermination.

Original paper, page 3