Question
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 ____.
Official answer and solution
- Official answer
- 2
- From
- Official GATE 2018 answer key
Solution
Apply the pigeonhole principle to find the maximum demand per process that guarantees deadlock freedom.
Let be the number of processes and be the total number of resource instances. Each process has maximum claim .
In the worst-case allocation just before deadlock, each process holds instances without completing. Deadlock is guaranteed to be avoided if the total resources strictly exceeds the sum of these worst-case allocations:
If , the maximum total held by 3 processes without finishing is . With 4 resources available, at least 1 resource remains free, allowing at least one process to acquire its maximum and terminate.
If , each process can hold 1 resource (3 held) with 1 free; giving that free resource to any process leaves it with 2, still short of 3, leading to deadlock.
Thus, the largest value of that avoids deadlock is 2.
2
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2018 Computer Science and Information Technology (CS)
- Question
- 34 of 65, printed as CS Q.24
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.