Chapter06 Deadlocks
Chapter06 Deadlocks
Chapter 6
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Preemptable and Nonpreemptable Resources
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Resource Acquisition (1)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Conditions for Resource Deadlocks
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Modeling (1)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Detection with One Resource of Each
Type (1)
Example of a system – is it deadlocked?
1. Process A holds R, wants S
2. Process B holds nothing, wants T
3. Process C holds nothing, wants S
4. Process D holds U, wants S and T
5. Process E holds T, wants V
6. Process F holds W, wants S
7. Process G holds V, wants U
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Detection with One Resource of Each
Type (2)
Figure 6-5. (a) A resource graph. (b) A cycle extracted from (a).
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Algorithm to Detect Deadlocks (1)
1. For each node, N in the graph, perform following five steps
with N as starting node.
2. Initialize L to empty list, and designate all arcs as unmarked.
3. Add current node to end of L, check to see if node now
appears in L two times. If so, graph contains a cycle (listed in
L) and algorithm terminates
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Algorithm to Detect Deadlocks (2)
4. From given node, see if there are any
unmarked outgoing arcs. If so, go to step 5; if
not, go to step 6.
5. Pick unmarked outgoing arc at random, mark
it. Then follow to new current node and go to
step 3.
6. If this is initial node, graph does not contain
cycles, algorithm terminates. Otherwise,
dead end. Remove it and go back to the
previous node.
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Detection with Multiple Resources of
Each Type (1)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Detection with Multiple Resources of
Each Type (3)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Avoidance
Resource Trajectories
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Safe and Unsafe States (1)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Safe and Unsafe States (2)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Banker’s Algorithm for
Single Resource
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Banker’s Algorithm for
Multiple Resources (2)
1. Look for a row, R, whose unmet resource needs are
all smaller than or equal to A. If no such row exists,
system will eventually deadlock.
2. Assume the process of row chosen requests all
resources needed and finishes. Mark that process
as terminated, add its resources to the A vector.
3. Repeat steps 1 and 2 until either all processes are
marked terminated (safe state) or no process is left
whose resource needs can be met (deadlock)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Deadlock Prevention
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Attacking Circular Wait Condition (1)
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Communication Deadlocks
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
Livelock
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.
End
Chapter 6
Tanenbaum & Bos, Modern Operating Systems: 4th ed., Global Edition (c) 2015 Pearson Education Limited. All rights reserved.