Deadlocks

References:

  1. Abraham Silberschatz, Greg Gagne, and Peter Baer Galvin, "Operating System Concepts, Ninth Edition ", Chapter 7

7.1 System Model

7.2 Deadlock Characterization


New Sidebar in Ninth Edition

7.2.1 Necessary Conditions

7.2.2 Resource-Allocation Graph


Figure 7.1 - Resource allocation graph


Figure 7.2 - Resource allocation graph with a deadlock


Figure 7.3 - Resource allocation graph with a cycle but no deadlock

7.3 Methods for Handling Deadlocks

7.4 Deadlock Prevention

7.4.1 Mutual Exclusion

7.4.2 Hold and Wait

7.4.3 No Preemption

7.4.4 Circular Wait

7.5 Deadlock Avoidance

7.5.1 Safe State


Figure 7.6 - Safe, unsafe, and deadlocked state spaces.

  Maximum Needs Current Allocation
P0
10
5
P1
4
2
P2
9
2

7.5.2 Resource-Allocation Graph Algorithm


Figure 7.7 - Resource allocation graph for deadlock avoidance


Figure 7.8 - An unsafe state in a resource allocation graph

7.5.3 Banker's Algorithm

7.5.3.1 Safety Algorithm

7.5.3.2 Resource-Request Algorithm ( The Bankers Algorithm )

7.5.3.3 An Illustrative Example

7.6 Deadlock Detection

7.6.1 Single Instance of Each Resource Type


Figure 7.9 - (a) Resource allocation graph. (b) Corresponding wait-for graph

7.6.2 Several Instances of a Resource Type

7.6.3 Detection-Algorithm Usage

7.7 Recovery From Deadlock

7.7.1 Process Termination

7.7.2 Resource Preemption

7.8 Summary