CLASS SCRIBE – 19.4.2013 PREPARED BY – SHUSHMAN CHOUDHURY (11CS10061) DEADLOCK AVOIDANCE.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Deadlock 2.
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.
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.
Lecture 11 “Banker ’ s algorithm”.  Multiple instances.  Each process must a priori knowledge claim maximum use.  When a process requests a resource.
7.5 Deadlock Avoidance The algorithm is simply to ensure that the system will always remain in safe state. Therefore, if a process requests a resource.
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 ©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.
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.
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.
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.
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.
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.
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.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
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.
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.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
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.
Deadlock A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. Example : “When.
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.
OPERATING SYSTEM CONCEPTS AND PRACTISE
CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
Deadlocks Session - 14.
Lecture 28 Syed Mansoor Sarwar
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
CSCI 315 Operating Systems Design
Banker’s Algorithm Anawil
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

CLASS SCRIBE – PREPARED BY – SHUSHMAN CHOUDHURY (11CS10061) DEADLOCK AVOIDANCE

AVOIDANCE WITH A SINGLE RESOURCE The Resource Allocation Graph must be used. It will be similar to that shown previously, but with an additional edge called Claim Edge that represents the potential requirements of the process. The process lets the system know what it may require right from the beginning. Resources must be claimed apriori. A cycle in this augmented resource allocation graph will imply the possibility of a deadlock in the near future.

THE RESOURCE ALLOCATION GRAPH WITH CLAIM EDGE The assignment edge shows that R1 has been assigned to P1, and the request edge shows that P2 has requested resource R1, as has been explained before. Furthermore, the claim edges (dotted lines) show that both P1 and P2 may request R2 in the near future. R1 P1 R2 P2 Claim Edge Assignment Edge Request Edge

CYCLES WITH CLAIM EDGES The claim edge will become the resource edge when the process requests that resource. This in turn becomes an assignment edge when the resource is granted to the process. Therefore, just as a cycle with request and assignment edges indicates a deadlock, the same with a claim edge indicates a possible deadlock, and consequently, an unsafe state. Thus, the request can be granted only if such a cycle does not exist, i.e the state is safe.

EFFECT OF INCORRECT HANDLING R1 P1 R2 P2 R1 P1 R2 P2 As can be observed here, this is what will happen if the cycles with claim edges are not taken care of. Over time, a deadlock may arise if the claim edge becomes a request edge before the other resource is let go. POTENTIAL DEADLOCK ACTUAL DEADLOCK

AVOIDANCE - MULTIPLE RESOURCES The Bankers Algorithm is used for this purpose. The algorithm is principally similar to the previously studied deadlock detection method, albeit with a few modifications. Processes must inform the system of their maximum resource usage apriori. As soon as a set of resources is requested, the system must gauge the safety of the potential allocation. It will not proceed otherwise. Furthermore, resources must be returned in a finite time.

DATA STRUCTURES Available Vector – A vector of length m where m is the number of resources, indicating the number of available resources of each type. Allocation Matrix – As described before. Maximum Matrix – An nXm matrix where M ij is the number of maximum instances of resource R j needed by process P i Need Matrix – An nXm matrix where N ij indicates that P i may need R j more resources to complete its task.

RESOURCE REQUEST ALGORITHM Request represents 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, an error is thrown, since the process has exceeded its maximum claim. 2.If Request i Available, go to step 3. Otherwise P i must wait, since its desired resources are not available at that moment. 3.Hypothetically 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 ; l If safe the resources are allocated to Pi l If unsafe Pi must wait, and the old resource-allocation state is restored

SAFETY ALGORITHM 1.Let Work and Finish be vectors of length m and n, respectively. Initialize: Work = Available Finish [i] = false for i = 0, 1, …, n- 1 2.Find an 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