Question on deadlock


#1

In a system, there are three types of resources: E, F and G. Four processes P0, P1, P2 and P3 execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max[P2,F] is the maximum number of instances of F that P2 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 only resources available.

Allocation
E F G
P0 1 0 1
P1 1 1 2
P2 1 0 3
P3 2 0 0

Max
E F G
P0 4 3 1
P1 2 1 4
P2 1 3 3
P3 5 4 1
From the perspective of deadlock avoidance, which one of the following is true?

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


#2

Available Resources (E,F,G) = (3, 3, 0)
With the available resources either P0 or P2 can be satisfied.

After execution of P0 is completed, the available resources will be
(3, 3, 0) + (1, 0, 1) = (4, 3, 1)

With (4,3,1) the requirement of P2 can be satisfied. After execution of P2 is completed, the available resources will be

(4, 3, 1) + (1, 0, 3) = (5, 3, 4)

With (5, 3, 4) the requirement of P1 can be satisfied. After execution of P1 is completed, the available resources will be

(5, 3, 4) + (1, 1, 2) = (6, 4, 6)

With (6, 4, 6) the requirement of P3 can be satisfied. After execution of P3 is completed, the available resources will be

(6, 4, 6) + (2, 0, 0) = (8, 4, 6)

The system is in safe state with safe sequence: P0–>P2–>P1–>P3
Therefore, the correct answer is option (A) -First option