0% found this document useful (0 votes)
108 views6 pages

Gate Deadlock With Answers

The document describes a resource allocation problem involving three processes (P0, P1, P2) and three resource types (X, Y, Z). It presents the current allocation of resources to each process and considers requests from P0 and P1 for additional resources. It analyzes whether each request could be permitted without causing a deadlock. It determines that request REQ2 from P1 can be permitted, but request REQ1 from P0 would cause a deadlock due to insufficient resources, so only REQ2 is permitted. The key points are: 1) It presents the current safe state of resource allocations; 2) It analyzes whether each new request would still leave the system in a safe state;

Uploaded by

Priya Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views6 pages

Gate Deadlock With Answers

The document describes a resource allocation problem involving three processes (P0, P1, P2) and three resource types (X, Y, Z). It presents the current allocation of resources to each process and considers requests from P0 and P1 for additional resources. It analyzes whether each request could be permitted without causing a deadlock. It determines that request REQ2 from P1 can be permitted, but request REQ1 from P0 would cause a deadlock due to insufficient resources, so only REQ2 is permitted. The key points are: 1) It presents the current safe state of resource allocations; 2) It analyzes whether each new request would still leave the system in a safe state;

Uploaded by

Priya Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

GATE | GATE-CS-2014-(Set-1) | Question 65

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,

0 units of Y and 2 units of Z

REQ2: P1 requests 2 units of X,

0 units of Y and 0 units of Z

Which one of the following is TRUE?


(A) Only REQ1 can be permitted.
(B) Only REQ2 can be permitted.
(C) Both REQ1 and REQ2 can be permitted.
(D) Neither REQ1 nor REQ2 can be permitted

Answer: (B) 

Explanation: This is the current safe state.


AVAILABLE X=3, Y=2, Z=2

MAX ALLOCATION

XYZ XYZ

P0 843 001
P1 620 320

P2 333 211
 
Now, if the request REQ1 is permitted, the state would become :

AVAILABLE X=3, Y=2, Z=0

MAX ALLOCATION NEED

XYZ XYZ XYZ

P0 843 003 840

P1 620 320 300

P2 333 211 122


 
Now, with the current availability, we can service the need of P1. The state
would become :

AVAILABLE X=6, Y=4, Z=0

MAX ALLOCATION NEED

XYZ XYZ XYZ

P0 843 003 840

P1 620 320 000

P2 333 211 122


 
With the resulting availability, it would not be possible to service the need of
either P0 or P2, owing to lack of Z resource.
Therefore, the system would be in a deadlock.
⇒ We cannot permit REQ1.
 
Now, at the given safe state, if we accept REQ2 :

AVAILABLE X=1, Y=2, Z=2

MAX ALLOCATION NEED

XYZ XYZ XYZ


P0 843 001 842

P1 620 520 100

P2 333 211 122


 
With this availability, we service P1 (P2 can also be serviced). So, the state is :

AVAILABLE X=6, Y=4, Z=2

MAX ALLOCATION NEED

XYZ XYZ XYZ

P0 843 001 842

P1 620 520 000

P2 333 211 122


 
With the current availability, we service P2. The state becomes :

AVAILABLE X=8, Y=5, Z=3

MAX ALLOCATION NEED

XYZ XYZ XYZ

P0 843 001 842

P1 620 520 000

P2 333 211 000


 
Finally, we service P0. The state now becomes :

AVAILABLE X=8, Y=5, Z=4

MAX ALLOCATION NEED

XYZ XYZ XYZ

P0 843 001 000

P1 620 520 000

P2 333 211 000


The state so obtained is a safe state. ⇒ REQ2 can be permitted.
So, only REQ2 can be permitted.
Hence, B is the correct choice.
 
Please comment below if you find anything wrong in the above post.

GATE | GATE-CS-2009 | Question 60


Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3
units), R4 (2 units). A non-preemptive resource allocation policy is used. At any
given instance, a request is not entertained if it cannot be completely satisfied.
Three processes P1, P2, P3 request the sources as follows if executed
independently.
Process P1:
t=0: requests 2 units of R2
t=1: requests 1 unit of R3
t=3: requests 2 units of R1
t=5: releases 1 unit of R2
and 1 unit of R1.
t=7: releases 1 unit of R3
t=8: requests 2 units of R4
t=10: Finishes

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.

GATE | GATE-CS-2014-(Set-3) | Question 65


A system contains three programs and each requires three tape units for its
operation. The minimum number of tape units which the system must have such that
deadlocks never arise is _________.
(A) 6
(B) 7
(C) 8
(D) 9

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.

GATE | GATE-CS-2016 (Set 1) | Question 60


Consider the following proposed solution for the critical section problem. There
are n processes: P0 …Pn−1. In the code, function pmax returns an integer not
smaller than any of its arguments. For all i, t[i] is initialized to zero.

Which one of the following is TRUE about the above solution?


(A) At most one process can be in the critical section at any time
(B) The bounded wait condition is satisfied
(C) The progress condition is satisfied
(D) It cannot cause a deadlock

Answer: (A) 

Explanation: 

You might also like