www.bookspar.com | Website for students | VTU NOTES
1). What is a deadlock?
A deadlock is a situation wherein two or more competing actions are waiting for the other
to finish, and thus neither ever does.
In computer science, deadlock refers to a specific condition when two or more processes are
each waiting for each other to release a resource, or more than two processes are waiting
for resources in a circular chain.
Deadlock is a common problem in multiprocessing where many processes share a specific
type of resource.
2).What are the necessary and sufficient conditions for
a deadlock to occur?
Mutual exclusion condition :- a resource that cannot be used by more than one
process at a time
Hold and wait condition:- processes already holding resources may request new
No preemption condition:- No resource can be forcibly removed from a process
holding it, resources can be released only by the explicit action of the process
Circular wait condition:-two or more processes form a circular chain where each
process waits for a resource that the next process in the chain holds.
3).How can we prevent the occuring of deadlocks?
Ans:-Elimination of “Mutual Exclusion” Condition:- The mutual exclusion condition must
hold for non-sharable resources. That is, several processes cannot simultaneously share a single
www.bookspar.com | Website for students | VTU NOTES
resource. Removing the mutual exclusion condition means that no process may have exclusive
access to a resource.
-Elimination of “Hold and Wait” Condition:- The "hold and wait" conditions may be
removed by requiring processes to request all the resources they will need before starting up.
Another way is to require processes to release all their resources before requesting all the resources
they will need. The system must grant resources on “all or none” basis. If the complete set of
resources needed by a process is not currently available, then the process must wait until the
complete set is available. While the process waits, however, it may not hold any resources. Thus the
“wait for” condition is denied and deadlocks simply cannot occur.
-Elimination of “No-preemption” Condition:- A "no preemption" (lockout) condition
may also be difficult or impossible to avoid as a process has to be able to have a resource for a
certain amount of time, or the processing outcome may be inconsistent or thrashing may occur. This
strategy require that when a process that is holding some resources is denied a request for
additional resources. The process must release its held resources and, if necessary, request them
again together with additional resources. Implementation of this strategy denies the “nopreemptive” condition effectively.
-Elimination of “Circular Wait” Condition:- The last condition, the circular wait, can be
denied by imposing a total ordering on all of the resource types and than forcing, all processes to
request the resources in order (increasing or decreasing). This strategy impose a total ordering of all
resources types, and to require that each process requests resources in a numerical order
(increasing or decreasing) of enumeration. With this rule, the resource allocation graph can never
have a cycle.
4).What is deadlock detection and how do you recover
from it?
Ans:Deadlock detection is the process of actually determining that a deadlock exists and identifying
the processes and resources involved in the deadlock.
The basic idea is to check allocation against resource availability for all possible allocation sequences
to determine if the system is in deadlocked state a. Of course, the deadlock detection algorithm is
only half of this strategy. Once a deadlock is detected, there needs to be a way to recover several
alternatives exists:
Temporarily prevent resources from deadlocked processes.
Back off a process to some check point allowing preemption of a needed resource and restarting the
process at the checkpoint later.
www.bookspar.com | Website for students | VTU NOTES
Successively kill processes until the system is deadlock free.
These methods are expensive in the sense that each iteration calls the detection algorithm until the
system proves to be deadlock free.
5).what are the two options of breaking a dead
-Prevention :
Set of methods for ensuring that at least one of the condition cannot hold.
-Avoidance :
OS be given information about the resources request used in advance.
For preventionif you have to explain then you can write the whole 3rd answer........
For avoidance you can write:-Requires additional information about how resources are to be used.
-Simplest and most useful model requires that each process declare the maximum number of
resources of each type that it may need.
-The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure
that there can never be a circular-wait condition.
-Resource-allocation state is defined by the number of available and allocated resources, and the
maximum demands of the processes.
6).what is wait-for-graph?xplain.
Ans:- A Wait-For Graph in computer science is a directed graph used for deadlock detection in
operating systems and relational database systems.
www.bookspar.com | Website for students | VTU NOTES
In Computer Science, a system that allows concurrent operation of multiple processes and locking of
resources and which does not provide mechanisms to avoid or prevent deadlock must support a
mechanism to detect deadlocks and an algorithm for recovering from them.
One such deadlock detection algorithm makes use of a Wait-For Graph to track which other
processes a process is currently blocking on. In a Wait-for Graph, processes are represented as
nodes, and an edge from process Pi to Pj implies Pj is holding a resource that Pi needs and thus Pi is
waiting for Pj to release its lock on that resource.
7).what is resource request algorithm?

www.bookspar.com | Website for students | VTU NOTES