The GATE Grind

GATE 2018 CS – Question 49

Operating System · Deadlock · 2 marks · Multiple choice

In a system, there are three types of resources: $E$, $F$ and $G$. Four processes $P_0$, $P_1$, $P_2$ and $P_3$ execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max$[P_2,F]$ is the maximum number of instances of $F$ that $P_2$ would require. The number of instances of the resources allocated to the various processes at any given state is given by a matrix named Allocation.

Consider a state of the system with the Allocation matrix as shown below, and in which 3 instances of $E$ and 3 instances of $F$ are the only resources available.

AllocationEFG
$P_0$101
$P_1$112
$P_2$103
$P_3$200
MaxEFG
$P_0$431
$P_1$214
$P_2$133
$P_3$541

From the perspective of deadlock avoidance, which one of the following is true?

  1. The system is in safe state.
  2. The system is not in safe state, but would be safe if one more instance of E were available
  3. The system is not in safe state, but would be safe if one more instance of F were available
  4. The system is not in safe state, but would be safe if one more instance of G were available

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) The system is in safe state.

Explanation

The available vector is $(3,3,0)$ and the needs are $P_0=(3,3,0)$, $P_1=(1,0,2)$, $P_2=(0,3,0)$, $P_3=(3,4,1)$. $P_0$ can run first and releases $(1,0,1)$, giving $(4,3,1)$ after it finishes with its full maximum $\to(4,3,1)$. Then $P_2$ needs $(0,3,0)$ and finishes, then $P_1$, then $P_3$. A safe sequence exists, so the state is safe.