# GATE - 2018 | OS | Consider a system with 3 processes that share 4 instances of the same ## Question:

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 _________.

 A 2 B 3 C 4 D 5

## Solution:

### Option (A) is correct.

No. of process = 3
No. of resources = 4
Let’s distribute each process one less than maximum demands i.e., (k-1) resources.
So, for three processes, 3(k – 1) resources.
For deadlock avoidance provide an additional resource to any one of the process.
∴ Total resources required to avoid deadlock in any case is 3(k – 1) + 1 = 3k – 2
Now this 3k – 2 should be less than equal to available no. of resources, i.e.,
3k – 2 ≤ 4
k ≤ 2
So maximum value of k = 2

------------------------------------------------

Given,
Number of processes (P) = 3
Number of resources (R) = 4

R ≥ P(N − 1) + 1


Where R is total number of resources,
P is the number of processes, and
N is the max need for each resource.

4 ≥ 3(N − 1) + 1
3 ≥ 3(N − 1)
1 ≥ (N − 1)
N ≤ 2


Therefore, the largest value of K that will always avoid deadlock is 2.

Thank You 