Skip to content
Official PYQ · 2025

GATE CS 2025 Set 2 Q38 — Deadlock

Explain with AI

P={P1,P2,P3,P4}P=\left\{P_{1}, P_{2}, P_{3}, P_{4}\right\} consists of all active processes in an operating system.

R={R1,R2,R3,R4}R=\left\{R_{1}, R_{2}, R_{3}, R_{4}\right\} consists of single instances of distinct types of resources in the system.

The resource allocation graph has the following assignment and claim edges.

Assignment edges: R1→P1,R2→P2,R3→P3,R4→P4R_{1} \rightarrow P_{1}, R_{2} \rightarrow P_{2}, R_{3} \rightarrow P_{3}, R_{4} \rightarrow P_{4} (the assignment edge R1→P1R_{1} \rightarrow P_{1} means resource R1R_{1} is assigned to process P1P_{1}, and so on for others)

Claim edges: P1→R2,P2→R3,P3→R1,P2→R4,P4→R2P_{1} \rightarrow R_{2}, P_{2} \rightarrow R_{3}, P_{3} \rightarrow R_{1}, P_{2} \rightarrow R_{4}, P_{4} \rightarrow R_{2} (the claim edge P1→R2P_{1} \rightarrow R_{2} means process P1P_{1} is waiting for resource R2R_{2}, and so on for others)

Which of the following statement(s) is/are CORRECT?

Select all correct options
View worked solution

Answer: C;D

In a Resource Allocation Graph (RAG) where each resource type has a single instance, the presence of a cycle is a necessary and sufficient condition for a deadlock.

Let's identify the cycles in the given system by tracing the assignment edges (Ri→PjR_i \rightarrow P_j) and request/claim edges (Pj→RkP_j \rightarrow R_k):

  • Cycle 1: P1→R2→P2→R3→P3→R1→P1P_1 \rightarrow R_2 \rightarrow P_2 \rightarrow R_3 \rightarrow P_3 \rightarrow R_1 \rightarrow P_1 (involves processes P1,P2,P3P_1, P_2, P_3)
  • Cycle 2: P2→R4→P4→R2→P2P_2 \rightarrow R_4 \rightarrow P_4 \rightarrow R_2 \rightarrow P_2 (involves processes P2,P4P_2, P_4)

To make the system deadlock-free, we must break both cycles:

  • Option A (Aborting P1P_1): Only breaks Cycle 1. Cycle 2 remains active, so the system is still deadlocked.
  • Option B (Aborting P3P_3): Only breaks Cycle 1. Cycle 2 remains active, so the system is still deadlocked.
  • Option C (Aborting P2P_2): Since P2P_2 is common to both Cycle 1 and Cycle 2, aborting P2P_2 breaks both cycles. The system becomes deadlock-free.
  • Option D (Aborting P1P_1 and P4P_4): Aborting P1P_1 breaks Cycle 1, and aborting P4P_4 breaks Cycle 2. Both cycles are broken, making the system deadlock-free.

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

Published
Report a correction
Keep exploringMore Deadlock questions