Consider a system with 3 processes that share 4 instances of the same resource type. Each process can request a maximum of instances. Resource instances can be requested and released only one at a time. The largest value of that will always avoid deadlock is ____.
GATE 2018 CS Q.24: solution and answer
Answer and solution
ANSWER
The largest value of K that always avoids deadlock is 2.
Official answer: 2Source: Official answer key, GATE 2018 CS (IIT Guwahati)
Deadlock needs every process to hold some instances while waiting for one more, with no free instance left.
The worst case is that each of the 3 processes holds instances, one short of its maximum . The total held is then .
Deadlock is impossible if at least one instance is still free in that worst case. So we need , which is .
This gives , so .
Check : each process holds at most 1 instance while it still needs another, so at most 3 are held. The 4th instance is free. Some process gets its second instance, finishes and releases. The others can then finish too, so there is no deadlock.
Check : take the split 2, 1, 1 with 0 free. Each process needs one more instance to reach its maximum of 3, and none is available. Deadlock is possible, so does not always avoid deadlock.
The largest that always avoids deadlock is .
KEY IDEA
With processes, instances and a maximum need of each, deadlock is impossible when . Here gives .
WATCH OUT FOR
Setting and getting , which wrongly requires every process to be able to finish at once. The right test is that the worst case, each process holding , still leaves one instance free.
From the GATE 2018 CS paper. Every question of this paper · Download the full paper · All 6 Deadlock questions, with notes
More Deadlock questions
- GATE 2026 CS1 Q.29 · MSQ · 1 markWith respect to deadlocks in an operating system, which of the following statements is/are FALSE?
- GATE 2026 CS1 Q.35 · NAT · 1 markConsider a system consisting of k instances of a resource R, being shared by 5 processes.
- GATE 2025 CS2 Q.48 · MSQ · 2 marksP = P_1, P_2, P_3, P_4 consists of all active processes in an operating system.
