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.
| Process | Allocation E | Allocation F | Allocation G | Max E | Max F | Max G |
|---|---|---|---|---|---|---|
| P0 | 1 | 0 | 1 | 4 | 3 | 1 |
| P1 | 1 | 1 | 2 | 2 | 1 | 4 |
| P2 | 1 | 0 | 3 | 1 | 3 | 3 |
| P3 | 2 | 0 | 0 | 5 | 4 | 1 |
From the perspective of deadlock avoidance, which one of the following is true?
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 for each process:
Currently Available resources: .
Trace safety sequence:
- Process requires . can finish and release its allocation .
. - Process requires . can finish and release its allocation .
. - Process requires . can finish and release its allocation .
. - Process requires . can finish.
Since a complete safe sequence exists, the system is in a safe state, matching option A.
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.