Suppose a system has 12 instances of some resource with 𝑛 processes competing…
2018
Suppose a system has 12 instances of some resource with 𝑛 processes competing for that resource. Each process may require 4 instances of the resources. The maximum value of 𝑛 for which the system never enters into deadlock is
- A.
3
- B.
4
- C.
5
- D.
6
Attempted by 273 students.
Show answer & explanation
Correct answer: A
Key idea: consider the worst-case where every process has acquired one fewer than its maximum required resources.
If each process may require up to R resources and there are n processes, in the worst case each process could be holding R − 1 resources. The total resources held then would be n*(R − 1). To guarantee that deadlock cannot occur, there must be at least one free resource so one process can obtain its remaining needed resource and complete. Thus:
m − n*(R − 1) ≥ 1 ⇒ n ≤ (m − 1)/(R − 1)
Apply the formula with m = 12 and R = 4:
n ≤ (12 − 1)/(4 − 1) = 11/3 ≈ 3.66
Maximum integer n that guarantees no deadlock is 3.
Check: with 4 processes each holding 3 resources there would be 12 resources held and none free, so deadlock can occur. Therefore 3 is the largest safe value.
A video solution is available for this question — log in and enroll to watch it.