Professional Documents
Culture Documents
Deadlocks: Republic of Yemen Ministry of Higher Education and Scientific Research Al-Rasheed Smart University
Deadlocks: Republic of Yemen Ministry of Higher Education and Scientific Research Al-Rasheed Smart University
Operating System Concepts – 10h Edition Silberschatz, Galvin and Gagne ©2018
Outline
• Introduction to Deadlock.
• Deadlock Characterization.
• Methods for Handling Deadlocks.
• Deadlocks Avoidance.
• Deadlocks Detection and Recovery.
Operating System Concepts – 10th Edition 7.2 Silberschatz, Galvin and Gagne ©2018
Introduction (1/3)
Operating System Concepts – 10th Edition 7.3 Silberschatz, Galvin and Gagne ©2018
Introduction (2/3)
Operating System Concepts – 10th Edition 7.4 Silberschatz, Galvin and Gagne ©2018
Introduction (2/3)
Operating System Concepts – 10th Edition 7.5 Silberschatz, Galvin and Gagne ©2018
Introduction (3/3)
Operating System Concepts – 10th Edition 7.6 Silberschatz, Galvin and Gagne ©2018
Introduction (3/3)
Operating System Concepts – 10th Edition 7.7 Silberschatz, Galvin and Gagne ©2018
Introduction (3/3)
Operating System Concepts – 10th Edition 7.8 Silberschatz, Galvin and Gagne ©2018
Introduction (3/3)
Operating System Concepts – 10th Edition 7.9 Silberschatz, Galvin and Gagne ©2018
Introduction (3/3)
Operating System Concepts – 10th Edition 7.10 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (1/11)
• Mutual exclusion.
• Hold and wait.
• No preemption.
• Circular wait.
Operating System Concepts – 10th Edition 7.11 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (2/11)
Operating System Concepts – 10th Edition 7.12 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (3/11)
Operating System Concepts – 10th Edition 7.13 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (4/11)
Operating System Concepts – 10th Edition 7.14 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (4/11)
• Process
• Pi requests instance of Rj Pi
Rj
• Pi is holding an instance of Rj Pi
Rj
Operating System Concepts – 10th Edition 7.15 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (5/11)
Operating System Concepts – 10th Edition 7.16 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (6/11)
Operating System Concepts – 10th Edition 7.17 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (6/11)
Operating System Concepts – 10th Edition 7.19 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (7/11)
Operating System Concepts – 10th Edition 7.20 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (8/11)
Basic Facts
Operating System Concepts – 10th Edition 7.21 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (9/11)
Operating System Concepts – 10th Edition 7.22 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (10/11)
Operating System Concepts – 10th Edition 7.23 Silberschatz, Galvin and Gagne ©2018
Deadlock Characterization (11/11)
Operating System Concepts – 10th Edition 7.24 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (1/10)
Operating System Concepts – 10th Edition 7.25 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (2/10)
Operating System Concepts – 10th Edition 7.26 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (3/10)
Operating System Concepts – 10th Edition 7.27 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (4/10)
Operating System Concepts – 10th Edition 7.28 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (5/10)
Operating System Concepts – 10th Edition 7.29 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (6/10)
• No deadlock.
• Because 𝑃2 and 𝑃4 will finish their jobs
over time.
• Then, 1 instance from 𝑅1 and 1 instance
from 𝑅2 will be free for 𝑃1 and 𝑃3.
Operating System Concepts – 10th Edition 7.30 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (7/10)
Operating System Concepts – 10th Edition 7.31 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (8/10)
Operating System Concepts – 10th Edition 7.32 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (9/10)
Operating System Concepts – 10th Edition 7.33 Silberschatz, Galvin and Gagne ©2018
Example Deadlocks (10/10)
Operating System Concepts – 10th Edition 7.34 Silberschatz, Galvin and Gagne ©2018
Methods for Handling Deadlocks
Operating System Concepts – 10th Edition 7.35 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (1/8)
non-sharable
sharable
Operating System Concepts – 10th Edition 7.38 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (2/8)
Operating System Concepts – 10th Edition 7.39 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (3/8)
Operating System Concepts – 10th Edition 7.40 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (3/8)
Operating System Concepts – 10th Edition 7.41 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (3/8)
Operating System Concepts – 10th Edition 7.42 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (3/8)
1 2
Operating System Concepts – 10th Edition 7.44 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (5/8)
Operating System Concepts – 10th Edition 7.45 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (6/8)
Operating System Concepts – 10th Edition 7.46 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (7/8)
Operating System Concepts – 10th Edition 7.47 Silberschatz, Galvin and Gagne ©2018
Deadlock Prevention (8/8)
Operating System Concepts – 10th Edition 7.48 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (1/29)
Operating System Concepts – 10th Edition 7.49 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (2/29)
Operating System Concepts – 10th Edition 7.50 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (3/29)
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.
Operating System Concepts – 10th Edition 7.51 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (4/29)
Basic Facts
• If a system is in safe state no deadlocks.
• If a system is in unsafe state possibility of deadlock.
• Avoidance ensure that a system will never enter an unsafe
state.
Operating System Concepts – 10th Edition 7.52 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (5/29)
Avoidance Algorithms:
Operating System Concepts – 10th Edition 7.53 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (6/29)
Resource-Allocation Graph:
• Claim edge Pi Rj indicated that process Pi may request
resource Rj; represented by a dashed line.
Claim edge
𝑃𝑖 𝑅𝑗
Operating System Concepts – 10th Edition 7.54 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (7/29)
Operating System Concepts – 10th Edition 7.55 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (8/29)
Resource-Allocation Graph:
Operating System Concepts – 10th Edition 7.56 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (9/29)
Operating System Concepts – 10th Edition 7.57 Silberschatz, Galvin and Gagne ©2018
Deadlocks Avoidance (10/29)
Operating System Concepts – 10th Edition 7.58 Silberschatz, Galvin and Gagne ©2018
End of Chapter 7.1
Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018