Deadlocks in Operating System
Deadlocks in Operating System
OPERATING SYSTEM
1. The Deadlock Problem
2. Deadlock Characterization
3. Deadlock Modeling
4. Resource Allocation Graph
5. Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
WHAT ARE DEADLOCKS???
o Example
Process-1 requests the printer, gets it
Process-2 requests the tape unit, gets it Process-1 and
Process-1 requests the tape unit, waits Process-2 are
Process-2 requests the printer, waits deadlocked!
FOUR CONDITIONS FOR DEADLOCKS???
3. No Preemption Condition
CIRCLES
represents processes
SQUARE
represents classes of identical resources
If there is a cycle
o If there is only one instance per resource type than there is a deadlock
o If there is more than once instance for some resource type than there may
or may not be a deadlock
EXAMPLE OF A RESOURCE ALLOCATION GRAPH
HOW TO HANDLE DEADLOCKS???
- Deadlock Prevention
- Deadlock Avoidance
- Deadlock Detection
- Deadlock Recovery
DEADLOCK PREVENTION???
• Maximum requirements of
each resource must be stated
in advance by each process.
• Two Approaches
• Two Algorithms
o Resource Allocation Algorithms
o The Banker’s Algorithm
DEADLOCK DETECTION???
• Process Termination
o Abort all deadlocked processes.
o Abort one process at a time until
the deadlock cycle is eliminated.
• Resource Preemption
o Selecting a victim
o Rollback
o Starvation