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?"

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Washington WASHINGTON UNIVERSITY IN ST LOUIS Concurrency: Deadlock Detection Fred Kuhns Department.
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.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition 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/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.
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.
Chapter 7: Deadlocks Adapted to COP4610 by Robert van Engelen.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
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
 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.
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.
Lecture 12 Handling Deadlock – Prevention, avoidance and detection.
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.
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.
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.
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.
Chapter 7: Deadlocks.
Process Deadlocks.
Lecture 6: Deadlocks, Deadlock Risk Management
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.
Chapter 7: Deadlocks.
Presentation transcript:

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?" - Bill Gates, Microsoft

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

3 Resource-Request Algorithm for Process P i Request = request vector for process P i. If Request i [j] = k then process P i wants k instances of resource type R j. 1.If Request i Need i go to step 2. Otherwise, raise error condition, since process has exceeded its maximum claim. 2.If Request i Available, go to step 3. Otherwise P i must wait, since resources are not available.

4 Resource-Request Algorithm for Process P i 3.Pretend to allocate requested resources to P i by modifying the state as follows: Available = Available - Request i ; Allocation i = Allocation i + Request i ; Need i = Need i – Request i If safe the resources are allocated to P i. If unsafe P i must wait, and the old resource-allocation state is restored

5 Example of Bankers Algorithm §5 processes P 0 through P 4 ; §4 resource types: A (3 instances), B (14 instances), C (12 instances), D(12 instances). §Snapshot at time T 0 : AllocationMaxAvailable A B C D P P P P P

6 Example (Cont.) §The content of the matrix. Need is defined to be Max - Allocation. §Is the system in a safe state?

7 Example of Bankers Algorithm §5 processes P 0 through P 4 ; §4 resource types: A (3 instances), B (14 instances), C (12 instances), D(12 instances). §Snapshot at time T 0 : AllocationMaxNeedAvailable A B C D P P P P P Sanity check?

8 §Should a request from Process P1 for (0,4,2,0) be granted immediately? Available = Available – Request 1 ; Allocation 1 = Allocation 1 + Request 1 ; Need 1 = Need 1 – Request 1

9 Request from Process P1 for (0,4,2,0) §5 processes P 0 through P 4 ; §4 resource types: A (3 instances), B (14 instances), C (12 instances), D(12 instances). §Snapshot at time T 0 : AllocationMaxNeedAvailable A B C D P P P P P Sanity check?

10 Deadlock Avoidance Disadvantages: §Prior knowledge of number of resources by processes §Resources may break... §No of processes may change, algorithm must be able to dynamically change its data structures. §Overhead executing detection algorithm

11 Deadlock Detection §Allow system to enter deadlock state §Detection algorithm §Recovery scheme

12 Single Instance of Each Resource Type §Maintain wait-for graph l Nodes are processes. l P i P j if P i is waiting for P j. §Periodically invoke an algorithm that searches for a cycle in the graph.

13 Resource-Allocation Graph and Wait-for Graph

14 Several Instances of a Resource Type §Available: A vector of length m indicates the number of available resources of each type. §Allocation: An n x m matrix defines the number of resources of each type currently allocated to each process. §Request: An n x m matrix indicates the current request of each process. If Request [i j ] = k, then process P i is requesting k more instances of resource type. R j.

15 Detection Algorithm 1.Let Work and Finish be vectors of length m and n, respectively Initialize: (a) Work = Available (b)For i = 1,2, …, n, if Allocation i 0, then Finish[i] = false;otherwise, Finish[i] = true. 2.Find an index i such that both: (a)Finish[i] == false (b)Request i Work If no such i exists, go to step 4.

16 Detection Algorithm (Cont.) 3.Work = Work + Allocation i Finish[i] = true go to step 2. 4.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.

17 Example of Detection Algorithm §Three processes P 1 through P 3 ; Four resource types A (4 instances), B (2 instances), and C (3 instances), D (1 instance). §Snapshot at time T 0 : AllocationRequestAvailable A B C D P P P

18 Example (Cont.) §P 2 requests an additional instance of type D. State of system? AllocationRequestAvailable A B C D P P P

19 Example (Cont.) l Can reclaim resources held by process P 3, but insufficient resources to fulfill other processes; requests. l Deadlock exists, consisting of processes P 1 and P 2.

20 Detection-Algorithm Usage §When, and how often, to invoke depends on: l How often a deadlock is likely to occur? l How many processes will be affected by deadlock when it happens. §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.

21 Recovery from Deadlock: 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? l Priority of the process. l How long process has computed, and how much longer to completion. l Resources the process has used. l Resources process needs to complete. l How many processes will need to be terminated. l Is process interactive or batch?

22 Recovery from Deadlock: Resource Preemption §Selecting a victim – minimize cost. §Rollback – return to some safe state, restart process for that state. §Starvation.

23 Deadlock Detection Disadvantages: §Overhead of executing detection algorithm §Maintaining additional information §Losses may occur due to deadlock recovery

24 Ostrich Algorithm §Mathematicians vs. Engineers

25 §Quick review of midterm