Professional Documents
Culture Documents
Ch7 Deadlocks
Ch7 Deadlocks
P0 P1
wait (A); wait(B)
wait (B); wait(A)
Bridge Crossing Example
R = {R1, R2, …, Rm}, the set consisting of all resource types in the
system
request edge – directed edge Pi Rj
assignment edge – directed edge Rj Pi
Resource-Allocation Graph (Cont.)
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
Ignore the problem and pretend that deadlocks never occur in the
system; used by most operating systems, including UNIX
Deadlock Prevention
Multiple instances
Need
ABC
P0 743
P1 122
P2 600
P3 011
P4 431
The system is in a safe state since the sequence < P1, P3, P4, P2, P0>
satisfies safety criteria
Example: P1 Request (1,0,2)
Detection algorithm
Recovery scheme
Single Instance of Each Resource Type
Rollback – return to some safe state, restart process for that state