Download presentation
Presentation is loading. Please wait.
Published byGlenna Hartanto Modified over 6 years ago
1
Lecture 18: Deadlock: Conditions, Detection and Avoidance (cont.)
2
Review: Deadlock Modeling
Modeled with directed graphs resource R assigned to process A process B is requesting/waiting for resource S process C and D are in deadlock over resources T and U
3
In this lecture Strategies for dealing with Deadlocks
just ignore the problem altogether detection and recovery dynamic avoidance careful resource allocation prevention negating one of the four necessary conditions
4
Ignore the problem
5
Deadlock Detection Suppose you were given
The resources currently held by each The additional resources each process wants Question: Is the system deadlocked?
6
Deadlock Detection One resource of each type
Multiple resources of each type
7
Detection with One Resource of Each Type
Note the resource ownership and requests A cycle can be found within the graph, denoting deadlock
8
Detection with multiple Resources of Each Type
Is there some order of execution of the processes which allows all of them to complete? If yes, then not deadlocked If no such order exists, then deadlocked After each process finishes, it releases resources back to the system
9
Example 1 Process Resources Held Resources Needed P1 A=1, B=1 1 of B
B=1, C=1 1 of C P3 C=1, A=1 none Resource Type Copies A 2 B C Not deadlocked, since P3 can run, releasing resources for P2, which releases resources to P1 upon finishing
10
Example 2 Process Resources Held Resources Needed P1 A=1, B=1 1 of B
B=1, C=1 1 of C P3 C=1, A=1 1 of A Resource Type Copies A 2 B C Deadlocked, since nobody can make progress
11
Example 3 Process Resources Held Resources Needed P1 A=1, B=1 1 of B
B=1, C=1 2 of A P3 C=1, A=1 None Resource Type Copies A 2 B C Deadlocked: Let P3 complete. P3 releases resources. But then, nobody else can proceed.
12
Detection with Multiple Resources of Each Type (1)
Data structures needed by deadlock detection algorithm
13
Detection with Multiple Resources of Each Type (2)
Look for an unmarked process, P_i, for which the ith row of R is less than or equal to A. If such a process is found, add the ith row of C to A, mark the process, and go back to 1 If no such process exists, the algorithm terminates.
14
Detection with Multiple Resources of Each Type (3)
An example for the deadlock detection algorithm
15
Recovery from Deadlock
Recovery through Preemption Recovery through Rollback Recover through Killing-process
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.