Question:

Consider a system consisting of \(k\) instances of a resource \(R\), being shared by 5 processes. Assume that each process requires a maximum of two instances of resource \(R\) and a process can request or release only one instance at a time. Further, a process can request the second instance of the resource only after acquiring the first instance.
The minimum value of \(k\) for the system to be deadlock-free is __________. (answer in integer)

Show Hint

Use the standard deadlock-free bound for a single resource type, \(k \ge p(m-1)+1\), where \(p\) is the number of processes and \(m\) is the maximum instances each process may need; here \(p=5\) and \(m=2\).
Updated On: Jul 22, 2026
Show Solution
collegedunia
Verified By Collegedunia

Correct Answer: 6

Solution and Explanation

Step 1: Identify the general result this question is built on.

For a system with a single resource type having \(k\) instances shared among \(p\) processes, where each process needs a maximum of \(m\) instances and requests or releases only one instance at a time, the system is guaranteed to be deadlock-free for every possible interleaving of requests exactly when \(k \ge p(m-1) + 1\).

Step 2: Understand why this bound is necessary.

Consider the worst case where every one of the \(p\) processes has already been granted \(m-1\) instances and is now blocked, waiting for its final, \(m\)-th instance. If the total number of instances is exactly \(k = p(m-1)\), this fully blocked configuration can actually be reached, since it uses up all \(k\) instances with \(m-1\) going to each process, and once every process is stuck waiting for one more unit that never becomes free, the system is deadlocked with no process able to proceed.

Step 3: Understand why the bound is sufficient.

If instead \(k = p(m-1) + 1\), then even if every process tries to hold \(m-1\) instances at once, that only consumes \(p(m-1)\) instances out of the \(k\) available, leaving at least 1 instance still free. That spare instance can always be handed to some waiting process, letting it reach its full requirement of \(m\) instances, finish its work, and release all \(m\) instances it was holding back to the pool. Those newly released instances are then enough to push the next process over its own threshold, and this chain continues until every process eventually completes, so the system can never get permanently stuck.

Step 4: Substitute the given values.

Here there are \(p = 5\) processes and each needs a maximum of \(m = 2\) instances. So the minimum deadlock-free value is \(k = 5(2-1) + 1 = 5(1) + 1 = 6\).

Step 5: Sanity check with \(k = 5\).

With only 5 instances, all 5 processes could each be granted exactly 1 instance, using up every available unit, and every process would then be blocked waiting for a second instance that can never be freed by anyone else. This is a genuine deadlock, confirming that \(k = 5\) is not enough and \(k = 6\) really is the smallest value that keeps the system deadlock-free.
\[ \boxed{6} \]
Was this answer helpful?
0
0

Top GATE CS Operating System Questions

View More Questions