Skip to content
Official PYQ · 2018

GATE CS 2018 Q24 — Deadlock

Explain with AI
Consider a system with 33 processes that share 44 instances of the same resource type. Each process can request a maximum of KK instances. Resources can be requested and releases only one at a time. The largest value of KK that will always avoid deadlock is ___
View worked solution

Answer: 2

To ensure that a system is always free from deadlock, the total number of resources allocated in the worst-case scenario (where every process is holding one less than its maximum requirement) must be strictly less than the total available resources.

Let:

  • N=3N = 3 (Number of processes)
  • R=4R = 4 (Total instances of the resource)
  • K=K = Maximum demand of each process

In the worst-case state, each of the NN processes holds (K−1)(K - 1) resources and is waiting for one more resource. For a deadlock to be avoided, the total resources allocated in this state must be less than the total available resources RR:

∑i=1N(Maxi−1)<R\sum_{i=1}^{N} (Max_i - 1) < R

Substituting the given values:

3×(K−1)<43 \times (K - 1) < 4 3K−3<43K - 3 < 4 3K<73K < 7 K<73≈2.33K < \frac{7}{3} \approx 2.33

Since the maximum demand KK must be an integer, the largest integer value of KK that always avoids deadlock is 22.


Verification:

  • If K=2K = 2: The worst-case allocation is when each of the 33 processes holds 11 resource (total 33 allocated). Since 11 resource remains free (4−3=14 - 3 = 1), any of the processes can acquire it, complete its execution, and release its resources. Thus, deadlock is impossible.
  • If K=3K = 3: The processes could hold 22, 11, and 11 resources respectively (total 44 allocated, 00 free). Each process needs at least 11 more resource to finish, resulting in a deadlock.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Deadlock questions