Gate Deadlock With Answers
Gate Deadlock With Answers
An operating system uses the Banker’s algorithm for deadlock avoidance when
managing the allocation of three resource types X, Y, and Z to three processes
P0, P1, and P2. The table given below presents the current system state. Here,
the Allocation matrix shows the current number of resources of each type
allocated to each process and the Max matrix shows the maximum number of
resources of each type required by each process during its execution.
There are 3 units of type X, 2 units of type Y and 2 units of type Z still available.
The system is
currently in a safe state. Consider the following independent requests for
additional resources in the
current state:
REQ1: P0 requests 0 units of X,
Answer: (B)
MAX ALLOCATION
XYZ XYZ
P0 843 001
P1 620 320
P2 333 211
Now, if the request REQ1 is permitted, the state would become :
Process P2:
t=0: requests 2 units of R3
t=2: requests 1 unit of R4
t=4: requests 1 unit of R1
t=6: releases 1 unit of R3
t=8: Finishes
Process P3:
t=0: requests 1 unit of R4
t=2: requests 2 units of R1
t=5: releases 2 units of R1
t=7: requests 1 unit of R2
t=8: requests 1 unit of R3
t=9: Finishes
Which one of the following statements is TRUE if all three processes run
concurrently starting at time t=0?
(A) All processes will finish without any deadlock
(B) Only P1 and P2 will be in deadlock.
(C) Only P1 and P3 will be in a deadlock.
(D) All three processes will be in deadlock
Answer: (A)
Explanation:
We can apply the following Deadlock Detection algorithm and see that there is
no process waiting indefinitely for a resource. See this for deadlock detection
algorithm.
Answer: (B)
Explanation: If 6 resources are there then it may be possible that all three process
have 2 resources and waiting for 1 more resource. Therefore, all of them will have to
wait indefinitely. If 7 resources are there, then atleast one must have 3 resources so
deadlock can never occur.
Answer: (A)
Explanation: