Consider a system with 4 types of resources R1(3 units), R2(2 units), R3(3…
2009
Consider a system with 4 types of resources R1(3 units), R2(2 units), R3(3 units), R4(2 units). A non-preemptive resource allocation policy is used. At any given instance, a request is not entertained if it cannot be completely satisfied. Three processes P1, P2,P3 request the resources as follows if executed independently.

Which one of the following statements is TRUE if all three processes run concurrently starting at time t = 0?
- A.
All processes will finish without any deadlock
- B.
Only P1 and P2 will be in deadlock
- C.
Only P1 and P3 will be in deadlock
- D.
All three processes will be in deadlock
Attempted by 11 students.
Show answer & explanation
Correct answer: A
Initially, available resources are R1=3, R2=2, R3=3, R4=2. At t=0, P1 gets 2 units of R2, P2 gets 2 units of R3, and P3 gets 1 unit of R4. At t=1, P1 gets 1 unit of R3. At t=2, P2 gets 1 unit of R4 and P3 gets 2 units of R1.
At t=3, P1 requests 2 units of R1 but only 1 is available (held by P3), so it waits. At t=4, P2 gets the remaining 1 unit of R1. At t=5, P1 releases resources and P3 releases its 2 units of R1. At t=6, P2 releases 1 unit of R3. At t=7, P3 gets the available 1 unit of R2.
At t=8, P1 requests 2 units of R4 but none are available. However, P2 finishes and releases its resources (including 1 unit of R4). At t=9, P3 finishes and releases all its resources (including 1 unit of R4). This makes a total of 2 units of R4 available.
P1's request for 2 units of R4 is now satisfied. P1 proceeds and finishes at t=10. Thus, all processes complete without deadlock.
A video solution is available for this question — log in and enroll to watch it.