0% found this document useful (0 votes)
23 views10 pages

Deadlock Questions

The document contains a series of questions and answers related to deadlock scenarios in computer systems. It discusses conditions for avoiding deadlocks, resource allocation, and safe states for processes sharing resources. Key answers include the minimum number of tape units required to prevent deadlocks, necessary conditions for avoiding deadlock, and the maximum number of processes that can operate without deadlock given certain resource constraints.

Uploaded by

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

Deadlock Questions

The document contains a series of questions and answers related to deadlock scenarios in computer systems. It discusses conditions for avoiding deadlocks, resource allocation, and safe states for processes sharing resources. Key answers include the minimum number of tape units required to prevent deadlocks, necessary conditions for avoiding deadlock, and the maximum number of processes that can operate without deadlock given certain resource constraints.

Uploaded by

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

Deadlock Questions

Question
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 _________.

Ans:7
Question
Consider the following snapshot of a system running n processes. Process i is
holding Xi instances of a resource R, 1 <= i <= n. currently, all instances of R are
occupied. Further, for all i, process i has placed a request for an additional Yi
instances while holding the Xi instances it already has. There are exactly two
processes p and q such that Yp = Yq = 0. Which one of the following can serve
as a necessary condition to guarantee that the system is not approaching a
deadlock?

(A)min (Xp, Xq) < max (Yk) where k != p and k != q


(B) Xp + Xq >= min (Yk) where k != p and k != q
(C) max (Xp, Xq) > 1
(D) min (Xp, Xq) > 1

Answer:B
Question
Suppose n processes, P1, …. Pn share m identical resource units, which
can be reserved and released one at a time. The maximum resource
requirement of process Pi is Si, where Si > 0. Which one of the following
is a sufficient condition for ensuring that deadlock does not occur?

Ans: C
Question
A computer has six tape drives, with n processes competing
for them. Each process may need two drives. What is the
maximum value of n for the system to be deadlock free?

(A) 6
(B) 5
(C) 4
(D) 3

Ans: B
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: Which request/s
can be granted?
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

Ans: Only Req 2 can be permitted


Consider a system with 4 processes and 5 resource classes. At a particular time t 0, the snapshot
for the various data structures involved in the system are as shown in the table below

Allocation MAX Available

Process
ABCDE ABCDE ABCDE
P0 10211 11213 00X11
P1 20110 22210
P2 11011 21311
P3 11110 11221

a) Compute the smallest value of X for which the system is in safe state. Write the safe sequence
too.
b) After computing the values for X above, assume that a request of (00110) resources from P3
arrives in the system. Describe by showing the values of various data-structures, the feasibility
for granting the said request immediately.
c) This is in continuation of part b above) Now, comment on the feasibility for granting the
request of (00001) resources initiated by P0.
d) Give the count for the total (maximum) available instances of all the resource classes present
in the system.
The smallest value is x = 2. The order of finishing is P 3 P2 P1 P0 or P3 P2 P0 P1.

Process Allocated Maximum Need Resources


Resources Resources
ABCDE ABCDE ABCDE
P0 10211 11213 01002
P1 20110 22210 02100
P2 11011 21311 10300
P3 11110 11221 00111

FIRST, let us show that the problem is not safe when x = 1: only P 3 can finish. The
available vector is now (1 1 2 2 1). But then no other process can finish. NEXT, if x =
2, then we can can again let P3 finish first. Then the available vector is (1 1 3 2 1).
Now Process P2 can finish, and the available vector becomes (2 2 3 3 2). Now both
P1 or P0 can finish (in either order).
(b) Can be granted immediately Available is 00101.The order of finishing is
P3 P2 P1 P0 or P3 P2 P0 P1.
Process Allocated Maximum Need Resources
Resources Resources
ABCDE ABCDE ABCDE
P0 10211 11213 01002
P1 20110 22210 02100
P2 11011 21311 10300
P3 11220 11221 00001
(c) New Available is 00101-00001=00100. Deadlock can be there

Process Allocated Maximum Need Resources


Resources Resources

ABCDE ABCDE ABCDE


P0 10212 11213 01001
P1 20110 22210 02100
P2 11011 21311 10300
P3 11220 11221 00001

d) Max resources = 52653

You might also like