GATE CS 2025 Set 2 | Question 48

MSQ · 2 marks

\(P = \{P_1, P_2, P_3, P_4\}\) consists of all active processes in an operating system.
\(R = \{R_1, R_2, R_3, R_4\}\) 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: \(R_1 \to P_1,\ R_2 \to P_2,\ R_3 \to P_3,\ R_4 \to P_4\) (the assignment edge \(R_1 \to P_1\) means resource \(R_1\) is assigned to process \(P_1\), and so on for others)

Claim edges: \(P_1 \to R_2,\ P_2 \to R_3,\ P_3 \to R_1,\ P_2 \to R_4,\ P_4 \to R_2\) (the claim edge \(P_1 \to R_2\) means process \(P_1\) is waiting for resource \(R_2\), and so on for others)

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

  1. Option A: Aborting \(P_1\) makes the system deadlock free.
  2. Option B: Aborting \(P_3\) makes the system deadlock free.
  3. Option C: Aborting \(P_2\) makes the system deadlock free. (correct)
  4. Option D: Aborting \(P_1\) and \(P_4\) makes the system deadlock free. (correct)

Answer

(C), (D)

Explanation

Every resource has a single instance, so a cycle means deadlock. Turn each edge pair into a waits-for edge between processes: \(P_1 \to P_2\) (for \(R_2\)), \(P_2 \to P_3\) (for \(R_3\)), \(P_2 \to P_4\) (for \(R_4\)), \(P_3 \to P_1\) (for \(R_1\)) and \(P_4 \to P_2\) (for \(R_2\)). That gives two cycles, \(P_1 \to P_2 \to P_3 \to P_1\) and \(P_2 \to P_4 \to P_2\), and both pass through \(P_2\).

  • Aborting \(P_1\) leaves the cycle \(P_2 \to P_4 \to P_2\) (A false).
  • Aborting \(P_3\) leaves the same cycle (B false).
  • Aborting \(P_2\) breaks both cycles (C true).
  • Aborting \(P_1\) and \(P_4\) removes a process from each cycle; only \(P_2 \to P_3\) remains (D true).

Answer: C, D