Dear aspirants,
Welcome to visit here, we are discussing here most important topic i.e. Deadlock.
When two or more operations are waiting for each other in an arrangement called deadlock.
Deadlock exists among a set of processes if
–
Every process is waiting for an event
–
This event can be caused only by another process
in the set
•
Event is the acquire of release of another
resource.
–
Mutual Exclusion
•
At least one resource must be held is in
non-sharable mode
–
Hold and wait
•
There exists a process holding a resource, and
waiting for another
–
No preemption
•
Resources cannot be preempted
–
Circular wait
•
There exists a set of processes {P1,
P2, … PN}, such that
–
P1 is waiting for P2, P2
for P3, …. and PN for P1
–
All four conditions cited above must hold for deadlock to
occur.
Once deadlock has been detected, some strategy is
needed for recovery.
The various
approaches of recovering from deadlock are:
1.PROCESS TERMINATION
2.RESOURCE
PREEMPTION
Process termination” it is one method to recover from
deadlock. We uses 2 methods for process termination, these are:
a) ABORT
ALL DEADLOCKED PROCESS : It means release all the processes in the
deadlocked state, and start the allocation from the starting point. It is a
great expensive method.
ABORT ONE BY ONE PROCESS UNTIL THE DEADLOCK CYCLE IS
ELIMINATED : In this method first abort the one of the processes in the
deadlocked state, and allocated the resources to some other process in the
deadlock state then check whether the deadlock breaked or not. If no, abort the
another process from the deadlock state. Continue this process until we recover
from deadlock. This method is also expensive but compare with first one it is
better.
To eliminate deadlocks using resource preemption, preempt
some resources
from processes and give these resources to other processes
until the deadlock cycle is broken.
There are 3 methods to eliminate the deadlocks using
resource preemption.These are :
a) SELECTING
A VICTIM : Select a victim resource from the deadlock state, and
preempt that one.
b) ROLLBACK
: If a resource from a process is preempted, what should be done with that
process. The process must be roll backed
to some safe state and restart it from that state.
c) STARVATION
: It must be guaranteed that resource will not always be preempted from the same
process to avoid starvation problem.
No comments:
Post a Comment