Washington WASHINGTON UNIVERSITY IN ST LOUIS Concurrency: Deadlock Detection Fred Kuhns Department.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

1 Thursday, June 29, 2006 "If you really think there's a bug you should report a bug. Maybe you're not using it properly. Have you ever considered that?"
Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks (Continuation). 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
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 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
03/09/2007CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 8: Deadlocks System Model Deadlock Characterization
03/07/2007CSCI 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.
03/03/2004CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
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  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention, Avoidance, and Detection Recovering from Deadlock Combined Approach.
1 Deadlock Definition of deadlock Condition for its occurrence Solutions for avoiding and breaking deadlock –Deadlock Prevention –Deadlock Avoidance –Deadlock.
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
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
1 Advanced Operating Systems - Spring 2009 Lecture 10 – February 11, 2009 Dan C. Marinescu Office: HEC 439 B. Office.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
Lecture 12 Handling Deadlock – Prevention, avoidance and detection.
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 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.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
國立台灣大學 資訊工程學系 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.
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 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.
CSE Operating System Principles Deadlocks. CSE – Operating System Principles2 Overview System Model Deadlock Characterization Methods for.
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.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 7: Deadlocks.
Deadlock Detection & recovery
Chapter 7: Deadlocks.
Process Deadlocks.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
Deadlocks Session - 14.
Lecture 29 Syed Mansoor Sarwar
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Presentation transcript:

Washington WASHINGTON UNIVERSITY IN ST LOUIS Concurrency: Deadlock Detection Fred Kuhns Department of Computer Science and Engineering Washington University in St. Louis

2 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Deadlock Detection Allow system to enter deadlock state Detection algorithm Recovery scheme

3 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization 1 Instance of each Resource Type Maintain wait-for graph –Nodes are processes. –P i P j if P i is waiting for P j to release some resource R k Periodically invoke an algorithm that searches for a cycle in the graph. An algorithm to detect a cycle in a graph requires an order of n 2 operations, where n is the number of vertices in the graph.

4 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Wait-for Graph R1R1 R2R2 P1P1 P2P2 P3P3 R3R3 R4R4 P4P4 P0P0 Resource Allocation Graph P1P1 P2P2 P3P3 P4P4 P0P0 Wait-For Graph

5 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization >1 Instance of each Resource Type Assume m resource types and n processes Available[i]: A vector of length m indicates the number of available resources of each type. Allocation[i,j]: An n x m matrix defines the number of resources of each type currently allocated to each process. –Allocation[i, j] = number of resources of type j currently allocated to Process i. –Allocation i = allocation vector for Process i Request[i,j]: An n x m matrix indicates the current per process requist vector. –Request[i,j] = number of resources of type j requested by Process i. –Request i = request vector for Process i

6 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Detection Algorithm 0. Work and Finish are vectors of length m and n, respectively. Initialize: (a) Work = Available (b) if Allocation i 0, then Finish[i] = false; else Finish[i] = true. 1. Find an index i such that both: (a) Finish[i] == false// has allocated resources (b) Request i Work// request can be filled If no such i exists, go to step Work = Work + Allocation i ; Finish[i] = true; go to step 1 3. If Finish[i] == false, for some i, 1 i n, then the system is in deadlock state. Moreover, if Finish[i] == false, then P i is deadlocked.

7 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Detection Algorithm (Cont.) Algorithm requires an order of O(m x n 2) operations to detect whether the system is in deadlocked state.

8 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Example of Detection Algorithm Five processes P 0 through P 4 three resource types A (7), B (2), and C (6). Snapshot at time T 0 : AllocationRequestAvailable A B C A B C A B C P P P P P Sequence will result in Finish[i] = true for all i.

9 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Step 0 Total Resource {A = 7, B = 2, C = 6} AllocationRequestAvailable A B C A B C A B C P P P P P Step 0: –Work = Available = {0, 0, 0} –Finish = {false, false, false, false, false}

10 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Steps 1, 2 and 3 AllocationRequest A B C P P P P P Steps 1 & 2: Request 0 < work // {0 0 0} Work = {0 1 0} Finish = {true, false, false, false, false} Request 2 < work // {0 1 0} Work = {3 1 3} Finish = {true, false, true, false, false} Request 1 < work // {3 1 3} Work = {5 1 3} Finish = {true, true, true, false, false} Request 3 < work // {5 1 3} Work = {7 2 4} Finish = {true, true, true, true, false} Request 4 < work // {7 2 4} Work = {7 2 6} Finish = {true, true, true, true, true} Step 3: No deadlock since all elements of Finish = true

11 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization P 2 requests an additional instance of type C AllocationRequestAvailable A B C A B C A B C P P P P P State of system? –Can reclaim resources held by process P 0, but insufficient resources to fulfill other processes; requests. –Deadlock exists, consisting of processes P 1, P 2, P 3, and P 4. New Request from P 2

12 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Detection-Algorithm Usage When, and how often, to invoke depends on: –How often a deadlock is likely to occur? –How many processes will need to be rolled back? one process for each disjoint cycle If detection algorithm is invoked arbitrarily, there may be many cycles in the resource graph and so we would not be able to tell which of the many deadlocked processes caused the deadlock.

13 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Recovery: Process Termination Abort all deadlocked processes. Abort one process at a time until the deadlock cycle is eliminated. In which order should we choose to abort? –Priority of the process. –How long process has computed, and how much longer to completion. –Resources the process has used. –Resources process needs to complete. –How many processes will need to be terminated. –Is process interactive or batch?

14 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Recovery: Resource Preemption Selecting a victim – minimize cost. Rollback – return to some safe state, restart process for that state. Starvation – same process may always be picked as victim, include number of rollback in cost factor.

15 Fred Kuhns (6/13/2014)Cs422 – Operating Systems Organization Combined Approach Combine the three basic approaches –prevention –avoidance –detection allowing the use of the optimal approach for each resource type in the system. Partition resources into hierarchically ordered classes. Use most appropriate technique for handling deadlocks within each class.