Skip to content
Official PYQ · 2009

GATE CS 2009 Q30 — Deadlock

Explain with AI

Consider a system with 44 types of resources R1R1 (33 units), R2R2 (22 units), R3R3 (33 units), R4R4 (22 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 P1P1, P2P2, P3P3 request the resources as follows if executed independently.

Process P1:Process P2:Process P3:t=0: requests 2 units of R2t=0: requests 2 units of R3t=0: requests 1 unit of R4t=1: requests 1 unit of R3t=2: requests 1 unit of R4t=2: requests 2 units of R1t=3: requests 2 units of R1t=4: requests 1 unit of R1t=5: releases 2 units of R1t=5: releases 1 unit of R2t=6: releases 1 unit of R3t=7: requests 1 unit of R2and 1 unit of R1t=8: Finishest=8: requests 1 unit of R3t=7: releases 1 unit of R3t=9: Finishest=8: requests 2 units of R4t=10: Finishes\begin{array}{|l|l|l|}\hline \textbf{Process P1:} & \textbf{Process P2:} & \textbf{Process P3:} \\ \hline \text{$t=0$: requests $2$ units of $R2$} & \text{$t=0$: requests $2$ units of $R3$} & \text{$t=0$: requests $1$ unit of $R4$} \\ \text{$t=1$: requests $1$ unit of $R3$} & \text{$t=2$: requests $1$ unit of $R4$} & \text{$t=2$: requests $2$ units of $R1$}\\\text{$t=3$: requests $2$ units of $R1$} & \text{$t=4$: requests $1$ unit of $R1$} & \text{$t=5$: releases $2$ units of $R1$} \\ \text{$t=5$: releases $1$ unit of $R2$} & \text{$t=6$: releases $1$ unit of $R3$} & \text{$t=7$: requests $1$ unit of $R2$} \\ \text{and $1$ unit of $R1$}& \text{$t=8$: Finishes} & \text{$t=8$: requests $1$ unit of $R3$}\\ \text{$t=7$: releases $1$ unit of $R3$} && \text{$t=9$: Finishes} \\ \text{$t=8$: requests $2$ units of $R4$} & \text{} \\ \text{$t=10$: Finishes} & \text{} \\ \hline \end{array}
Which one of the following statements is TRUE if all three processes run concurrently starting at time t=0t = 0?

Choose one option
View worked solution

Answer: A

To determine if a deadlock occurs, we trace the concurrent execution of the three processes. Let eie_i denote the active execution time (excluding blocked states) of process PiP_i.

The total available resources initially are: R1=3R1 = 3, R2=2R2 = 2, R3=3R3 = 3, R4=2R4 = 2.

  1. At t=0t = 0:
    • P1P1 (at e1=0e_1=0) requests 22 units of R2R2 →\rightarrow Granted.
    • P2P2 (at e2=0e_2=0) requests 22 units of R3R3 →\rightarrow Granted.
    • P3P3 (at e3=0e_3=0) requests 11 unit of R4R4 →\rightarrow Granted.
    • Available: R1=3,R2=0,R3=1,R4=1R1=3, R2=0, R3=1, R4=1.
  2. At t=1t = 1:
    • P1P1 (at e1=1e_1=1) requests 11 unit of R3R3 →\rightarrow Granted.
    • Available: R1=3,R2=0,R3=0,R4=1R1=3, R2=0, R3=0, R4=1.
  3. At t=2t = 2:
    • P2P2 (at e2=2e_2=2) requests 11 unit of R4R4 →\rightarrow Granted.
    • P3P3 (at e3=2e_3=2) requests 22 units of R1R1 →\rightarrow Granted.
    • Available: R1=1,R2=0,R3=0,R4=0R1=1, R2=0, R3=0, R4=0.
  4. At t=3t = 3:
    • P1P1 (at e1=3e_1=3) requests 22 units of R1R1. Since only 11 unit of R1R1 is available, P1P1 is Blocked.
    • P2P2 and P3P3 continue executing (e2=3,e3=3e_2=3, e_3=3).
  5. At t=4t = 4:
    • P2P2 (at e2=4e_2=4) requests 11 unit of R1R1 →\rightarrow Granted.
    • Available: R1=0,R2=0,R3=0,R4=0R1=0, R2=0, R3=0, R4=0.
  6. At t=5t = 5:
    • P3P3 (at e3=5e_3=5) releases 22 units of R1R1.
    • Available: R1=2,R2=0,R3=0,R4=0R1=2, R2=0, R3=0, R4=0.
    • Since 22 units of R1R1 are now available, the blocked request of P1P1 is Granted, and P1P1 unblocks.
    • Available: R1=0,R2=0,R3=0,R4=0R1=0, R2=0, R3=0, R4=0.
  7. At t=6t = 6:
    • P2P2 (at e2=6e_2=6) releases 11 unit of R3R3.
    • Available: R1=0,R2=0,R3=1,R4=0R1=0, R2=0, R3=1, R4=0.
  8. At t=7t = 7:
    • P1P1 (at e1=5e_1=5) releases 11 unit of R2R2 and 11 unit of R1R1.
    • P3P3 (at e3=7e_3=7) requests 11 unit of R2R2 →\rightarrow Granted.
    • Available: R1=1,R2=0,R3=1,R4=0R1=1, R2=0, R3=1, R4=0.
  9. At t=8t = 8:
    • P2P2 (at e2=8e_2=8) finishes and releases all its held resources (1×R3,1×R4,1×R11 \times R3, 1 \times R4, 1 \times R1).
    • P3P3 (at e3=8e_3=8) requests 11 unit of R3R3 →\rightarrow Granted.
    • Available: R1=2,R2=0,R3=1,R4=1R1=2, R2=0, R3=1, R4=1.
  10. At t=9t = 9:
    • P1P1 (at e1=7e_1=7) releases 11 unit of R3R3.
    • P3P3 (at e3=9e_3=9) finishes and releases all its held resources (1×R4,1×R2,1×R31 \times R4, 1 \times R2, 1 \times R3).
    • Available: R1=2,R2=1,R3=3,R4=2R1=2, R2=1, R3=3, R4=2.
  11. At t=10t = 10:
    • P1P1 (at e1=8e_1=8) requests 22 units of R4R4 →\rightarrow Granted.
  12. At t=12t = 12:
    • P1P1 finishes successfully.

Since all three processes run to completion, no deadlock occurs.

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

Published
Report a correction
Keep exploringMore Deadlock questions