UNIT-III PPT Os
UNIT-III PPT Os
Unit-3 DEADLOCKS
Dr. B. Rebecca
Department of Computer Science and
Engineering(Data Science)
Deadlocks
• The Deadlock Problem
• System Model
• Deadlock Characterization
• Deadlock Prevention
• Deadlock Avoidance
• Deadlock Detection
• Recovery from Deadlock
The Deadlock Problem
• 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
Methods for Handling Deadlocks
• Circular Wait
• That is:
– If Pi resource needs are not immediately available, then Pi
can wait until all Pj have finished.
– When Pj is finished, Pi can obtain needed resources,
execute, return allocated resources, and terminate.
– When Pi terminates, Pi +1 can obtain its needed resources,
and so on.
• If a system is in safe state no deadlocks.
• Multiple instances.
Need
ABC
P0 743
P1 122
P2 600
P3 011
P4 431
• Detection algorithm
• Recovery scheme
Single Instance of Each Resource Type
Resource-Allocation Graph
Corresponding wait-for graph
Several Instances of a Resource Type