Chapter 81 Deadlock is:  A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.  Example.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 12: Deadlocks (Chapter 7)
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Deadlocks  (How to Detect Them and Avoid Them) A:
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 30 Handling Deadlock.
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.
Chapter 7. Deadlocks.
1 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Lecture 14 Chapter 7: Deadlocks (cont)
Chapter 8: Deadlocks System Model Deadlock Characterization
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
02/19/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
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.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Objectives Understand the Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Chapter 7: Deadlocks Adapted to COP4610 by Robert van Engelen.
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.
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.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-6 Deadlocks Department of Computer Science and Software Engineering.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
Chapter 81 Deadlock Avoidance Technique  Resource Allocation Denial: Grant incremental resource requests if we can prove that this leaves the system in.
Deadlocks System Model RAG Deadlock Characterization
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Chapter 7: Deadlock Course Administration n Midterm exam next week in class l Closed book n Final exam time changed to during class.
Lecture 12 Handling Deadlock – Prevention, avoidance and detection.
Deadlocks Dec 11, 2007 CPE Operating Systems
Mi-Jung Choi Dept. of Computer and Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
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.
國立台灣大學 資訊工程學系 Chapter 7: Deadlocks. 資工系網媒所 NEWS 實驗室 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes.
Chap 7 Deadlocks. Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
Deadlocks Introduction to Operating Systems: Module 7.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter Objectives To develop a description of deadlocks, which.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
7.1 CSE Department MAITSandeep Tayal 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Deadlock. Examples You can't get a job without experience; you can't get experience without a job. A set of blocked processes each holding a resource.
Chapter 7: Deadlocks. The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

Chapter 81 Deadlock is:  A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.  Example (hardware resources): System has 2 tape drives. P 1 and P 2 each hold one tape drive and each needs another one.  Example (“software” resource:): semaphores A and B, initialized to 1 P 0 P 1 wait (A);wait(B) wait (B);wait(A) signal(B);signal(A) signal(A);signal(B)

Chapter 82 The (4) Conditions for Deadlock There are three policy conditions that must hold for a deadlock to be possible (the “necessary conditions”): 1.Mutual Exclusion only one process at a time may use a resource 2.Hold-and-Wait a process may hold allocated resources while awaiting assignment of others 3. No Preemption a resource can be released only voluntarily by the process holding it, after that process has completed its task ..and a fourth condition which must actually arise to make a deadlock happen

Chapter 83 The Conditions for Deadlock  In the presence of these necessary conditions,one more condition must arise for deadlock to actually occur:  4. Circular Wait a closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain

Chapter 84 The Conditions for Deadlock  Deadlock occurs if and only if the circular wait condition is unresolvable  The circular wait condition is unresolvable if the first 3 policy conditions hold  So the 4 conditions taken together constitute necessary and sufficient conditions for deadlock

Chapter 85 Resource Allocation Graph: A Cycle But No Deadlock Multiple instances of resources R 1 and R 2 : P 2 and P 4 can complete, freeing up resources for P 1 and P 3

Chapter 86 Approaches to Handling Deadlocks  Deadlock Prevention disallow 1 of the 3 necessary conditions of deadlock occurrence, or prevent the circular wait condition from happening  Deadlock Avoidance do not grant a resource request if this allocation might lead to deadlock  Deadlock Detection and Recovery grant resource requests when possible, but periodically check for the presence of deadlock and then take action to recover from it

Chapter 87 Deadlock Avoidance  We accept the 3 policy conditions but make judicious choices to assure that the deadlock point is never reached  Allows more concurrency than prevention  Two approaches: do not start a process if its total demand might lead to deadlock: (“Process Initiation Denial”), or do not grant an incremental resource request if this allocation could lead to deadlock: (“Resource Allocation Denial”)  In both cases: maximum requirements of each resource must be stated in advance

Chapter 88 Resource Allocation Denial  A Better Approach: Grant incremental resource requests if we can prove that this leaves the system in a state in which deadlock cannot occur. Based on the concept of a “safe state”  Banker’s Algorithm: Tentatively grant each resource request Analyze resulting system state to see if it is “safe”. If safe, grant the request if unsafe refuse the request (undo the tentative grant) block the requesting process until it is safe to grant it.

Data Structures for the Banker’s Algorithm Let n = number of processes, m = number of resource types  Available: Vector of length m. If Available [j] = k, there are k instances of resource type R j currently available  Max: n x m matrix. If Max [i,j] = k, then process P i will request at most k instances of resource type R j.  Alloc: n x m matrix. If Alloc[i,j] = k then P i is currently allocated (i.e. holding) k instances of R j.  Need: n x m matrix. If Need[i,j] = k, then P i may need k more instances of R j to complete its task. Need [i,j] = Max[i,j] – Alloc [i,j].

Chapter 810 Safety Algorithm 1. 1.Let Work and Finish be vectors of length m and n, respectively. Initialize: Work := Available Finish [i] == false for i = 1,2, …, n. 2.Find an i such that both: Finish [i] == false Need i  Work If no such i exists, go to step Work := Work + Allocation i (Resources freed when process completes!) Finish[ i ] := true go to step 2. 4.If Finish [ i ] = true for all i, then the system is in a safe state.

Chapter 811 Resource-Request Algorithm for Process P i Request i = request vector for P i. Request i [j] = k means process P i wants k instances of resource type R j. 1.If Request i  Need i go to step 2. Otherwise, error ( process exceeded its maximum claim). 2.If Request i  Available, go to step 3. Otherwise P i must wait, (resources not available). 3.“Allocate” requested resources to P i as follows: Available := Available - Request i Alloc i := Alloc i + Request i Need i := Need i – Request i If safe  the resources are allocated to P i. If unsafe  restore the old resource-allocation state and block P i

Chapter 812 Example of Banker’s Algorithm 5 processes P 0 through P 4 3 resource types A (10 units), B (5 units), and C (7 units). Snapshot at time T 0 : AllocationMaxAvailable A B CA B C A B C P P P P P

Chapter 813 Example (cont) Need = Max – Allocation Need A B C P P P P P The system is in a safe state since the sequence satisfies safety criteria.

Chapter 814 Now P 1 requests (1,0,2) Check that Request  Available (that is, (1,0,2)  (3,3,2))  true. AllocationNeedAvailable A B CA B CA B C P P P P P