Unit 4 Deadlocks
Unit 4 Deadlocks
Course Coordinator
Dr. Anup Gade
1
Department of Information Technology
Chapter 3: Deadlocks
• System Model
• Deadlock Characterization
• Methods for Handling Deadlocks
• Deadlock Prevention
• Deadlock Avoidance
• Deadlock Detection
• Recovery from Deadlock
• Combined Approach to Deadlock Handling
The Deadlock Problem
• A set of blocked processes each holding a resource and
waiting to acquire a resource held by another process in the
set.
• Example
– System has 2 tape drives.
– P1 and P2 each hold one tape drive and each needs another one.
• Example
– semaphores A and B, initialized to 1
P0 P1
wait (A); wait(B)
wait (B); wait(A)
Bridge Crossing Example
• Pi requests instance of Rj
Pi
Rj
• Pi is holding an instance of Rj
Pi
Rj
Example of a Resource Allocation Graph
• Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources that Pi can
still request can be satisfied by currently available resources + resources
held by all the Pj, with j<I.
– 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.
Basic Facts
• Detection algorithm
• Recovery scheme