Consider a system with 3 processes that share 4 instances of the same resource…

20182025

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

Attempted by 155 students.

Show answer & explanation

Correct answer: 2

Key insight: prevent a situation where every process holds K−1 resources and waits for one more.

Derivation:

  • If each of the 3 processes holds at most K−1 resources, the total held could be 3*(K−1). To guarantee progress there must be at least one free resource: 4 ≥ 3*(K−1) + 1.

  • Solve for K: 4 ≥ 3K − 3 + 1 ⇒ 4 ≥ 3K − 2 ⇒ 3K ≤ 6 ⇒ K ≤ 2.

  • Thus the largest integer K that always avoids deadlock is 2.

Quick check: If K = 2, at worst each process holds 1 resource (3 used), leaving one free so some process can finish and release resources. If K > 2, a deadlock can be constructed.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir