Deadlock Recovery Strategies
You'll learn the practical techniques for breaking an existing deadlock once it's been detected in your system.
Once your deadlock detection algorithm confirms that a deadlock exists (lesson 1326), you can't just ignore it—the blocked processes will wait forever. Recovery strategies actively break the deadlock by forcibly intervening in the system's resource allocation state.
Core Recovery Techniques
1. Process Termination
The most drastic approach: kill one or more processes to release their resources.
Two variants:
- Abort all deadlocked processes – Simple but wasteful; all progress is lost
- Abort one process at a time – Terminate processes individually, running detection after each termination until the cycle breaks. Choose victims based on criteria like priority, computation time completed, or how many resources they hold.
2. Resource Preemption
Instead of killing processes, forcibly take resources away from selected victims and give them to others.
Steps:
- Select a victim – Which process loses resources?
- Rollback – Return the victim to a safe earlier state (before it acquired the resource)
- Prevent starvation – Don't always pick the same victim
3. Rollback Techniques
Save process checkpoints periodically. When deadlock occurs, roll back one or more processes to a point before they entered the deadlock, then restart them hoping they take a different execution path.
Think of it like this: Deadlock recovery is like a traffic jam at an intersection. You can back up one car (rollback), tow away a car entirely (termination), or have a tow truck move a car out of the way temporarily (preemption).
Key Takeaway: Deadlock recovery involves either terminating deadlocked processes, preempting their resources for reallocation, or rolling processes back to safe checkpoints—trading immediate progress for system-wide forward progress.