The GATE Grind

GATE 2018 CS – Question 34

Operating System · Deadlock · 1 mark · Numerical answer

Consider a system with 3 processes that share 4 instances of the same resource type. Each process can request a maximum of $K$ instances. Resource instances can be requested and released only one at a time. The largest value of $K$ that will always avoid deadlock is ________.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 2

Explanation

A system with $R$ identical resources and $n$ processes each needing at most $K$ is deadlock-free if and only if the resources are enough that at least one process can always complete. The worst case is each process holding $K-1$ units and waiting for 1 more; deadlock is impossible when
$$n(K-1)+1\le R.$$
With $n=3$ and $R=4$: $3(K-1)+1\le4\Rightarrow K-1\le1\Rightarrow K\le2$.

The largest $K$ is $\mathbf2$.

More Deadlock questions

All Deadlock questions →