Tanenbaum Ch 6 Silberschatz Ch 7

Slides:



Advertisements
Similar presentations
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Advertisements

Chapter 7: Deadlocks.
Chapter 3 Deadlocks TOPICS Resource Deadlocks The ostrich algorithm
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
5/25/2015Page 1 Deadlock Management B. Ramamurthy.
Chapter 7 Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks 7.1 System Model.
Chapter 3 Deadlocks - Αδιέξοδα 3.1. Resource
With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen
Deadlock Chapter 3 R1 R2 P2P1 Allocated Requested.
Deadlocks CS 3100 Deadlocks1. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
Deadlocks. 2 System Model There are non-shared computer resources –Maybe more than one instance –Printers, Semaphores, Tape drives, CPU Processes need.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlock Detection with One Resource of Each Type (1)
02/19/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Chapter 6 Deadlocks Resources Introduction Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks Modified.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention.
1 Deadlocks 2 Resources Examples of computer resources –printers –tape drives –tables Processes need access to resources in reasonable order Suppose.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
1 Deadlocks Chapter 3. 2 Resources Examples of computer resources –printers –tape drives –tables Processes need access to resources in reasonable order.
Operating Systems 软件学院 高海昌 Operating Systems Gao Haichang, Software School, Xidian University 22 Contents  1. Introduction** 
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance.
Chapter 7 Deadlocks. 7.2 Modified By Dr. Khaled Wassif Operating System Concepts – 7 th Edition Silberschatz, Galvin and Gagne ©2005 Chapter 7: Deadlocks.
Cosc 4740 Chapter 6, Part 4 Deadlocks. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held.
1 MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
CSC 322 Operating Systems Concepts Lecture - 28: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Chapter 7 Deadlocks Chapter 7: Deadlocks 7.1 System Model 7.2 Deadlock Characterization 7.3 Methods for Handling Deadlocks 7.4 Deadlock Prevention 7.5.
CS333 Intro to Operating Systems Jonathan Walpole.
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
Operating Systems Unit VI Deadlocks and Protection Department of Computer Science Engineering and Information Technology.
Chapter 7: Deadlocks. 7.2CSCI 380 – Operating Systems Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Deadlocks References –text: Tanenbaum ch.3. Deadly Embrace Deadlock definition –A set of process is dead locked if each process in the set is waiting.
Deadlocks CPE Operating Systems
Deadlocks Chapter 6 Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Sistem Operasi IKH311 Deadlock. 2 Resources Examples of computer resources printers tape drives tables Processes need access to resources in reasonable.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Deadlocks References text: Tanenbaum ch.3.
Lecture 18: Deadlock: Conditions, Detection and Avoidance (cont.)
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 7 Deadlocks.
Deadlocks References text: Tanenbaum ch.3.
Deadlocks Definition A set of processes is in a Deadlock state when every process in the set is waiting for an event that can only be caused by another.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
DPNM Lab. Dept. of CSE, POSTECH
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Lecture 19: Deadlock: Conditions, Detection and Avoidance
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Introduction to Deadlocks
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
Deadlocks References text: Tanenbaum ch.3.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Presentation transcript:

Tanenbaum Ch 6 Silberschatz Ch 7 Deadlock Tanenbaum Ch 6 Silberschatz Ch 7

The Deadlock Problem A Computing example: record scanned document 4/16/2017 The Deadlock Problem A Computing example: record scanned document System has 1 scanner and 1 CD Recorder 2 processes each need both devices. P0 acquires scanner and waits for CD P1 acquires CD and waits for scanner cs431-cotter cs431-cotter

Preemptable and Nonpreemptable Resources 4/16/2017 Preemptable and Nonpreemptable Resources Sequence of events required to use a resource: Request the resource. Use the resource. Release the resource. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Resource Acquisition (1) 4/16/2017 Resource Acquisition (1) Figure 6-1. Using a semaphore to protect resources. (a) One resource. (b) Two resources. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Resource Acquisition (2) 4/16/2017 Figure 6-2. (a) Deadlock-free code. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Resource Acquisition (3) 4/16/2017 Resource Acquisition (3) Figure 6-2. (b) Code with a potential deadlock. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Introduction To Deadlocks 4/16/2017 Introduction To Deadlocks Deadlock can be defined formally as follows: A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Deadlock Characterization: Necessary Conditions 4/16/2017 Deadlock Characterization: Necessary Conditions Mutual Exclusion: At least 1 resource must be held in a non-sharable mode. Hold and wait: There must be at least 1 process that is holding one resource and is waiting for another No preemption: Resources cannot be preempted Circular wait: There must be a cycle of dependency among a set of processes and resources. cs431-cotter cs431-cotter

Deadlock Strategies Strategies for dealing with deadlocks: 4/16/2017 Deadlock Strategies Strategies for dealing with deadlocks: Just ignore the problem. Detection and recovery. Let deadlocks occur, detect them, take action. Dynamic avoidance by careful resource allocation. Prevention, by structurally negating one of the four required conditions. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Ignore the Problem May not occur very often May not have serious consequences if it does happen May be difficult / expensive to detect. cs431-cotter

Resource Allocation Graphs Process Resource Request a Resource Hold a Resource Deadlock A R R A A R A R S B cs431-cotter 11

Resource Allocation Graph Multiple Resources with No Cycles 4/16/2017 Resource Allocation Graph Multiple Resources with No Cycles P2 P3 P1 cs431-cotter cs431-cotter

4/16/2017 Graph with Deadlock P2 P3 P1 cs431-cotter cs431-cotter

4/16/2017 Graph with Deadlock P2 P3 P1 cs431-cotter cs431-cotter

Graph with Cycle but no Deadlock 4/16/2017 Graph with Cycle but no Deadlock P2 P1 P3 P4 cs431-cotter cs431-cotter

Deadlock Detection with Multiple Resources of Each Type 4/16/2017 Deadlock Detection with Multiple Resources of Each Type Figure 6-6. The four data structures needed by the deadlock detection algorithm. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Deadlock Detection with Multiple Resources of Each Type (2) 4/16/2017 Deadlock Detection with Multiple Resources of Each Type (2) Deadlock detection algorithm: Look for an unmarked process, Pi , for which the i-th row of R is less than or equal to A. If such a process is found, add the i-th row of C to A, mark the process, and go back to step 1. If no such process exists, the algorithm terminates. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Deadlock Detection with Multiple Resources of Each Type (3) 4/16/2017 Figure 6-7. An example for the deadlock detection algorithm. cs431-cotter 18 Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter 18

Deadlock Avoidance The previous approach can be used to avoid a deadlock (rather than just detect one when it occurs). Declare the maximum number of resources of each type that will be required before the process starts. Before any resource allocation is made, ensure that the allocation will not leave the system in a state where a deadlock can occur. This will ensure that a process can always get access to its needed maximums. cs431-cotter 19

4/16/2017 Safe State A system is in a safe state if there exists a sequence of resource assignments such that each process can be allocated its maximum request, and then release the resources, and then allow remaining processes to do the same... cs431-cotter cs431-cotter

Safe State Process Max Needs Current Needs Total P0 10 5 12 4/16/2017 Safe State A system is in a safe state if there exists a sequence of resource assignments such that each process can be allocated its maximum request, and then release the resources, and then allow remaining processes to do the same... Process Max Needs Current Needs Total P0 10 5 12 P1 4 2 Avail P2 9 2 3 cs431-cotter cs431-cotter

Safe State Process Max Needs Current Needs Total P0 10 5 12 4/16/2017 Safe State A system is in a safe state if there exists a sequence of resource assignments such that each process can be allocated its maximum request, and then release the resources, and then allow remaining processes to do the same... Process Max Needs Current Needs Total P0 10 5 12 P1 4 24 Avail P2 9 2 31 cs431-cotter cs431-cotter

Safe State Process Max Needs Current Needs Total P0 10 5 12 4/16/2017 Safe State A system is in a safe state if there exists a sequence of resource assignments such that each process can be allocated its maximum request, and then release the resources, and then allow remaining processes to do the same... Process Max Needs Current Needs Total P0 10 5 12 P1 0 40 Avail P2 9 2 15 cs431-cotter cs431-cotter

Safe State Process Max Needs Current Needs Total P0 10 510 12 4/16/2017 Safe State A system is in a safe state if there exists a sequence of resource assignments such that each process can be allocated its maximum request, and then release the resources, and then allow remaining processes to do the same... Process Max Needs Current Needs Total P0 10 510 12 P1 0 0 Avail P2 9 2 50 cs431-cotter cs431-cotter

4/16/2017 Banker's Algorithm Use vectors and matrices to identify resource requirements Available[j] = k; //resource j has k members available Max[i,j] = k; //Process i may need k members of resource j Allocation [i,j] = k; //Process i is currently allocated k members of resource j Need[i,j] = k; // Process i may need as many as k more of resource j. cs431-cotter cs431-cotter

Banker's Example Request: P0 wants 0 2 0 4/16/2017 Banker's Example Request: P0 wants 0 2 0 Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 Safe order: ??? cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 3 0 2 3 2 2 2 3 0 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 3 2 2 3 2 2 2 3 0 P2 3 0 2 9 0 2 2 1 0 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 Safe Order: P1, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 0 0 0 3 2 2 2 3 0 P2 3 0 2 9 0 2 2 1 0 P3 2 1 1 2 2 2 5 3 2 P4 0 0 2 4 3 3 Safe Order: P1, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 0 0 0 3 2 2 2 3 0 P2 3 0 2 9 0 2 2 1 0 P3 2 2 2 2 2 2 5 3 2 P4 0 0 2 4 3 3 5 2 1 Safe Order: P1, P3, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 7 4 3 P1 0 0 0 3 2 2 2 3 0 P2 3 0 2 9 0 2 2 1 0 P3 0 0 0 2 2 2 5 3 2 P4 0 0 2 4 3 3 5 2 1 Safe Order: P1, P3, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 7 4 3 P1 0 0 0 3 2 2 2 3 0 3 1 2 P2 3 0 2 9 0 2 2 1 0 P3 0 0 0 2 2 2 5 3 2 P4 4 3 3 4 3 3 5 2 1 Safe Order: P1, P3, P4, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 7 4 3 P1 0 0 0 3 2 2 2 3 0 3 1 2 P2 3 0 2 9 0 2 2 1 0 7 4 5 P3 0 0 0 2 2 2 5 3 2 P4 0 0 0 4 3 3 5 2 1 Safe Order: P1, P3, P4, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 7 5 3 7 5 3 3 3 2 7 4 3 P1 0 0 0 3 2 2 2 3 0 3 1 2 P2 3 0 2 9 0 2 2 1 0 7 4 5 P3 0 0 0 2 2 2 5 3 2 0 0 2 P4 0 0 0 4 3 3 5 2 1 Safe Order: P1, P3, P4, P0, cs431-cotter cs431-cotter

Banker's Example (change 1) 4/16/2017 Banker's Example (change 1) P1 requests (1 0 2) Allocate Max Avail. A B C A B C A B C P0 0 0 0 7 5 3 3 3 2 7 4 3 P1 0 0 0 3 2 2 2 3 0 3 1 2 P2 3 0 2 9 0 2 2 1 0 7 4 5 P3 0 0 0 2 2 2 5 3 2 0 0 2 P4 0 0 0 4 3 3 5 2 1 7 5 5 Safe Order: P1, P3, P4, P0, P2 !!! OK cs431-cotter cs431-cotter

Banker's Example (change 2) 4/16/2017 Banker's Example (change 2) P4 requests (3 3 0) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 cs431-cotter cs431-cotter

Banker's Example (change 2) 4/16/2017 Banker's Example (change 2) P4 requests (3 3 0) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 0 0 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 3 3 2 4 3 3 cs431-cotter cs431-cotter

Banker's Example (change 2) 4/16/2017 Banker's Example (change 2) P4 requests (3 3 0) Allocate Max Avail. A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 0 0 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 No job can be completed. No Safe Order exists! cs431-cotter cs431-cotter

Recovery from Deadlock 4/16/2017 Recovery from Deadlock Recovery through preemption Recovery through rollback Recovery through killing processes cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Deadlock Prevention Attacking the mutual exclusion condition 4/16/2017 Deadlock Prevention Attacking the mutual exclusion condition Attacking the hold and wait condition Attacking the no preemption condition Attacking the circular wait condition cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Attacking the Circular Wait Condition 4/16/2017 Attacking the Circular Wait Condition Figure 6-13. (a) Numerically ordered resources. (b) A resource graph. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Approaches to Deadlock Prevention 4/16/2017 Approaches to Deadlock Prevention Figure 6-14. Summary of approaches to deadlock prevention. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Other Issues Two-phase locking Livelock Starvation cs431-cotter 4/16/2017 Other Issues Two-phase locking Livelock Starvation cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Locking Protocols Shared Locks (read but not write) 4/16/2017 Locking Protocols Shared Locks (read but not write) Exclusive Locks (read or write) A transaction may require a number of locks that must be applied consistently (same sequence..) 2 Phase locking protocol Growing Phase (obtain but not release locks) Shrinking Phase (release but not obtain locks) cs431-cotter cs431-cotter

Livelock Figure 6-16. Busy waiting that can lead to livelock. 4/16/2017 Livelock Figure 6-16. Busy waiting that can lead to livelock. cs431-cotter Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 cs431-cotter

Starvation Occurs when there is a priority based selection process. If there are many high priority tasks (in a continuous stream) and only one (or a few) low priority tasks, the low priority tasks will never be selected Starvation avoidance First-come, First-served Priority enhancement cs431-cotter

Summary Deadlock Characteristics Deadlock Strategies Mutual Exclusion: Hold and wait: No preemption: Circular wait: Deadlock Strategies Just ignore the problem. Detection and recovery. Let deadlocks occur, detect them, take action. Dynamic avoidance by careful resource allocation. Prevention, by structurally negating one of the four required conditions. Deadlock Tools and Techniques Other Issues cs431-cotter

Questions In the context of Operating System processes, what is a deadlock? What conditions are required for a deadlock to exist? How does a resource allocation graph help identify opportunities for deadlock? Please show an example of a resource allocation graph that includes a deadlock. Discuss how the Banker's algorithm ensures that each process that tries to get access to a critical section will eventually be guaranteed of getting in. The Banker’s algorithm only requires that there be at least 1 safe order to make a transaction safe, however there may be many different orders possible. Using the example shown on slide 34, how many safe orders exist given the request by P1? How might we handle deadlocks? Give at least 3 of the methods discussed in the book and provide examples of each. cs431-cotter