Professional Documents
Culture Documents
Osppt
Osppt
Osppt
Outline:
Definition
Fundamental causes of deadlocks
Resource allocation graphs and wait for Graph
Approaches to handling deadlocks
Deadlock prevention
Deadlock avoidance
Deadlock detection and recovery
Conclusion
References
What is Deadlock?
1. Mutual Exclusion: At least one of the resources is non-sharable (i.e only a limited
number of processes can use it at a time and it is requested by a process while
it is being used by another one, the requesting process has to wait until the
resource is released).
2. Hold and Wait: There must be at least one process that is holding at least one
resource and waiting for other resources that are being hold by other
processes.
3. No preemption: No resource can be preempted before the holding process
completes its task with that resource.
If a process that is holding some resources requests another resource and
that resource cannot be allocated it, then it must release all resources that are
currently allocated to it.
4. Circular Wait: There exists a set of processes (p1,p2….pn) such that
P1 is waiting for a resource held by p2
P2 is waiting for a resource held by p3 ……….
Pn-1 is waiting for a resource held by pn.
Pn is waiting for a resource held by p1.
Deadlock in distributed systems
• If there is a cycle, and the cycle involves only resources which have a
single instance, then a deadlock has occurred.
Resource allocation Graphs
(contd..)
[reusable] resources with multiplicity 2
Pi Rj
Assignment edge from resource Rj to process Pi
Pi Rj
R1
P1 P1 holds 2 copies of resource R1, and P2
holds one copy of resource R1 and
request one copy of resource R2
R2
P2
There are three cycles, so a deadlock may exists.
Actually p1, p2 and p3 are deadlocked
P5 P5
R1 R3 R4
P2 P3 P1 P2 P3
P1
P4 P4
R2 R5
Wants Holds
resource Holds
resource Wants resource
resource
Young Old
process process Young Old
process process
It Dies
It will wait
Wait-die
Wait-die:
If an old process wants a resource held by a young process,
the old one will wait.
If a young process wants a resource held by an old process, the
young process will be killed.
Observation: The young process, after being killed, will then start up
again, and be killed again. This cycle may go on many times before
the old one release the resource.
Wound-wait