Deadlock PPT Os
Deadlock PPT Os
DEADLOCK
WHAT IS DEADLOCK ?
Deadlock is a condition where a set of processes
each holding a resource is waiting to acquire a
resource held by another.
Example :
DEADLOCK
CHARACTERIZATION
NECESSARY CONDITIONS
FOR DEADLOCK
There are four necessary conditions that must hold
for a deadlock to be possible.
Mutual Exclusion : Only one process at a time may use a
resource.
Hold & Wait : A process may hold allocated resources while
waiting to acquire some more resources hold by other
processes at the same time.
No Preemption : A resource can be released only voluntarily
by the process holding it, after that process has completed
its task.
Circular Wait : There exists a set { P0,P1,P2,.....,Pn } of
waiting processes such that P0 is waiting for a resource that
is held by P1, P1 is waiting for a resource that is held by P2,
and so on.
RESOURCE ALLOCATION GRAPH
Resource Allocation Graph (RAG) is a graphical
representation of an algorithm for detecting a deadlock.
Each resource is shown as a square and each process is
shown as a circle.
Claim edge- process request to resource in future
Request edge- process request to resource
Assignment edge and allocated edge- resource allocate
to process
An edge from process to resource represents a Request
edge and an edge from resource to process represents
an Assignment edge.
Its is called as unsafe state.
RESOURCE ALLOCATION
GRAPH
DEADLOCK HANDLING
Deadlock handling can be done by :
Deadlock Prevention : Deadlock can be prevented by
preventing any one of the necessary 4 conditions to
occur.
Deadlock Avoidance : The idea of avoiding a deadlock is
simply not allow the system to enter an unsafe state that
may cause a deadlock.
Resource allocation graph
Bankers algorithm
○ Safe State : If deadlock does not occur, then safe state.
○ Unsafe State : If deadlock occurs, then unsafe state.
Deadlock Detection & Recovery : In this method it allows
deadlock to occur, detect the deadlock and then recover
the deadlock.
DEADLOCK PREVENTION
METHODS
Mutual Exclusion : It is not possible to prevent
deadlock by avoiding mutual exclusion as some
resources are basically non - sharable.