Deadlock
Deadlock
Deadlock
• System Model
• Deadlock Characterization
• Methods for Handling Deadlocks
• Deadlock Prevention
• Deadlock Avoidance
• Deadlock Detection
• Recovery from Deadlock
• Combined Approach to Deadlock Handling
P0 P1
wait (A); wait(B)
wait (B); wait(A)
• Process
• Pi requests instance of Rj
Pi
Rj
• Pi is holding an instance of Rj
Pi
Rj
• No Preemption –
– If a process that is holding some resources
requests another resource that cannot be
immediately allocated to it, then all resources
currently being held are released.
– Preempted resources are added to the list of
resources for which the process is waiting.
– Process will be restarted only when it can regain
its old resources, as well as the new ones that it
is requesting.
• Circular Wait – impose a total ordering of all resource
types, and require that each process requests
resources in an increasing order of enumeration.
• Multiple instances.
• Each process must a priori claim maximum use.
• When a process requests a resource it may have to
wait.
• When a process gets all its resources it must return
them in a finite amount of time.
• The system is in a safe state since the sequence < P1, P3,
P4, P2, P0> satisfies safety criteria.
• Executing safety algorithm shows that sequence <P1, P3, P4, P0, P2>
satisfies safety requirement.
• Sequence <P0, P2, P3, P1, P4> will result in Finish[i] = true for
all i.
• State of system?
– Can reclaim resources held by process P0, but insufficient
resources to fulfill other processes; requests.
– Deadlock exists, consisting of processes P1, P2, P3, and P4.