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.

Process P1: t=0: requests 2 units of R2 t=1: requests 1 unit of R3 t=3: requests 2 units of R1 t=5: releases 1 unit of R2 and 1 unit of R1. t=7: releases 1 unit of R3 t=8: requests 2 units of R4 t=10: Finishes | Process P2: t=0: requests 2 units of R3 t=2: requests 1 unit of R4 t=4: requests 1 unit of R1 t=6: releases 1 unit of R3 t=8: Finishes | Process P3: t=0: requests 1 unit of R4 t=2: requests 2 units of R1 t=5: releases 2 units of R1 t=7: requests 1 unit of R2 t=8: requests 1 unit of R3 t=9: Finishes |

Which one of the following statements is TRUE if all three processes run concurrently starting at time t = 0?

Option A. All processes will finish without any deadlock.

Option B. Only P1 and P2 will be in deadlock.

Option C. Only P1 and P3 will be in deadlock.

Option D. All three processes will be in deadlock.

True Answer A

##### Explanation :

Solution:

Available resouces: R1=3, R2=2, R3=3, R4=2 (initially)

At t=0:

P1 holds R2=2

P2 holds R3=2

P3 holds R4=1 ( all requests are successful because their all

instances are free)

Available resources after t=0: R1=3, R2=0, R3=1, R4=1

At t=1:

P1 holds R2=2, R3=1

P2 holds R3=2

P3 holds R4=1

Available resources after t=1: R1=3, R2=0, R3=0, R4=1

At t=2:

P1 holds R2=2, R3=1

P2 holds R3=2, R4=1

P3 holds R4=1, R1=2

Available resources after t=2: R1=1, R2=0, R3=0, R4=0.

At t=3:

P1 holds R2=2, R3=1, R1=1, and waiting for R1=1

P2 holds R3=2, R4=1

P3 holds R4=1, R1=2

Available resources after t=3: R1=0, R2=0, R3=0, R4=0.

At t=4:

P1 holds R2=2, R3=1, R1=1, and waiting for R1=1

P2 holds R3=2, R4=1, and waiting for R1=1

P3 holds R4=1, R1=2

Available resources after t=4: R1=0, R2=0, R3=0, R4=0.

At t=5:

P1 holds R2=1, R3=1, R1=1, Released R2=1

P2 holds R3=2, R4=1, R1=1, (P2 holds R1=1 which is released by P3, R1=2)

P3 holds R4=1 ( releases R1=2)

Available resources after t=5: R1=1, R2=1, R3=0, R4=0.

At t=6:

P1 holds R2=1, R3=1,R1=1.

P2 holds R3=1, R4=1, R1=1, (P2 releases R3=1).

P3 holds R4=1.

Available resources after t=6: R1=1, R2=1, R3=1, R4=0.

At t=7:

P1 holds R2=1, R1=1 (Releases R3=1).

P2 holds R3=1, R4=1, R1=1.

P3 holds R4=1, R2=1.

Available resources after t=7: R1=1, R2=0, R3=2, R4=0.

At t=8:

P1 holds R2=1, R1=1, R4=1 and waiting for R4=1.

P2 Finished so releases R3=1, R4=1, R1=1.

P3 holds R4=1, R2=1, R3=1.

Available resources after t=8: R1=2, R2=0, R3=2, R4=0.

At t=9:

P1 holds R2=1, R1=1, R4=2 (R4 one instance holds by taking the instance

from released P3).

P2 Finished.

P3 Finishes and hence releases R4=1(Now, holds by P1), R2=1, R3=1.

Available resources after t=9: R1=2, R2=1, R3=3, R4=0.

At t=10:

P1 Finishes and releases R2=1, R1=1, R4=2.

P2 Finished.

P3 Finished.

Available resources after t=10: R1=3, R2=3, R3=3, R4=2

All process finish without any dead lock.

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.

Process P1: t=0: requests 2 units of R2 t=1: requests 1 unit of R3 t=3: requests 2 units of R1 t=5: releases 1 unit of R2 and 1 unit of R1. t=7: releases 1 unit of R3 t=8: requests 2 units of R4 t=10: Finishes | Process P2: t=0: requests 2 units of R3 t=2: requests 1 unit of R4 t=4: requests 1 unit of R1 t=6: releases 1 unit of R3 t=8: Finishes | Process P3: t=0: requests 1 unit of R4 t=2: requests 2 units of R1 t=5: releases 2 units of R1 t=7: requests 1 unit of R2 t=8: requests 1 unit of R3 t=9: Finishes |

Which one of the following statements is TRUE if all three processes run concurrently starting at time t = 0?