GATE 2018 CS – Question 49
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.
| Allocation | E | F | G |
|---|---|---|---|
| $P_0$ | 1 | 0 | 1 |
| $P_1$ | 1 | 1 | 2 |
| $P_2$ | 1 | 0 | 3 |
| $P_3$ | 2 | 0 | 0 |
| Max | E | F | G |
|---|---|---|---|
| $P_0$ | 4 | 3 | 1 |
| $P_1$ | 2 | 1 | 4 |
| $P_2$ | 1 | 3 | 3 |
| $P_3$ | 5 | 4 | 1 |
From the perspective of deadlock avoidance, which one of the following is true?
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.