Deadlocks
Deadlocks
DEADLOCKS
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
OBJECTIVES
Process
Pi requests instance of Rj
Pi
Rj
Pi is holding an instance of Rj
Pi
Rj
EXAMPLE OF A RESOURCE ALLOCATION GRAPH
RESOURCE ALLOCATION GRAPH WITH A DEADLOCK
GRAPH WITH A CYCLE BUT NO DEADLOCK
BASIC FACTS
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
DEADLOCK AVOIDANCE
Requires that the system has some additional a priori information
available
Multiple instances
Need
ABC
P0 743
P1 122
P2 600
P3 011
P4 431
Detection algorithm
Recovery scheme
SINGLE INSTANCE OF EACH RESOURCE TYPE
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
DETECTION-ALGORITHM USAGE