Question

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 the only resources available.

ProcessAllocation EAllocation FAllocation GMax EMax FMax G
P0101431
P1112214
P2103133
P3200541

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

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2018 answer key

Solution

Compute the Need matrix and execute Banker's safety algorithm to discover a valid execution sequence.

Calculate Need=Max−Allocation\text{Need} = \text{Max} - \text{Allocation} for each process:

  • Need(P0)=[4−1,3−0,1−1]=[3,3,0]\text{Need}(P_0) = [4 - 1, 3 - 0, 1 - 1] = [3, 3, 0]
  • Need(P1)=[2−1,1−1,4−2]=[1,0,2]\text{Need}(P_1) = [2 - 1, 1 - 1, 4 - 2] = [1, 0, 2]
  • Need(P2)=[1−1,3−0,3−3]=[0,3,0]\text{Need}(P_2) = [1 - 1, 3 - 0, 3 - 3] = [0, 3, 0]
  • Need(P3)=[5−2,4−0,1−0]=[3,4,1]\text{Need}(P_3) = [5 - 2, 4 - 0, 1 - 0] = [3, 4, 1]

Currently Available resources: Available=[3,3,0]\text{Available} = [3, 3, 0].
Trace safety sequence:

  1. Process P0P_0 requires [3,3,0]≤[3,3,0][3, 3, 0] \le [3, 3, 0]. P0P_0 can finish and release its allocation [1,0,1][1, 0, 1].
    New Available=[3,3,0]+[1,0,1]=[4,3,1]\text{New Available} = [3, 3, 0] + [1, 0, 1] = [4, 3, 1].
  2. Process P2P_2 requires [0,3,0]≤[4,3,1][0, 3, 0] \le [4, 3, 1]. P2P_2 can finish and release its allocation [1,0,3][1, 0, 3].
    New Available=[4,3,1]+[1,0,3]=[5,3,4]\text{New Available} = [4, 3, 1] + [1, 0, 3] = [5, 3, 4].
  3. Process P1P_1 requires [1,0,2]≤[5,3,4][1, 0, 2] \le [5, 3, 4]. P1P_1 can finish and release its allocation [1,1,2][1, 1, 2].
    New Available=[5,3,4]+[1,1,2]=[6,4,6]\text{New Available} = [5, 3, 4] + [1, 1, 2] = [6, 4, 6].
  4. Process P3P_3 requires [3,4,1]≤[6,4,6][3, 4, 1] \le [6, 4, 6]. P3P_3 can finish.

Since a complete safe sequence ⟨P0,P2,P1,P3⟩\langle P_0, P_2, P_1, P_3 \rangle exists, the system is in a safe state, matching option A.

Final answer

A

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2018 Computer Science and Information Technology (CS)
Question
49 of 65, printed as CS Q.39
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.