Deadlocks Peng Lu In a multiprogramming environment, several processes may compete for a finite number of resources. A process requests resources; if the.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 7: Deadlocks.
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 - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks 7.1 System Model.
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.
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. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
Chapter 8: Deadlocks System Model Deadlock Characterization
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 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bridge Crossing Example Traffic only in one direction. Each section.
Operating System Concepts Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
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.
Operating Systems Part III: Process Management (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.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Deadlocks System Model RAG Deadlock Characterization
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.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Mi-Jung Choi Dept. of Computer and Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles 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.
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.
Deadlocks 12/02/2015. What is a deadlock ? System has a finite set of resources. Resource can have one or more instances. Processes compete for resources.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: 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.
CSE Operating System Principles Deadlocks. CSE – Operating System Principles2 Overview System Model Deadlock Characterization Methods for.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
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
Chapter 7: Deadlocks.
G.Anuradha Ref:- Galvin
Operating Systems (CS 340 D)
Chapter 7: Deadlocks.
Operating System: DEADLOCKS
Chapter 7 Deadlocks.
Chapter 7: Deadlocks.
Process Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Chapter 8: Deadlocks.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
Lecture 27 Syed Mansoor Sarwar
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
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Chapter 8: Deadlocks Deadlock Characterization
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

Deadlocks Peng Lu In a multiprogramming environment, several processes may compete for a finite number of resources. A process requests resources; if the resources are not available at that time, the process enters a wait state. Waiting processes may never again change state, because the resources they have requested are held by other waiting processes. This situation is called a deadlock. CSCI-6303 Dr. John P. Abraham

Deadlocks CSCI-6303 Dr. John P. Abraham

Deadlocks “When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone.” ---The Kansas legislature, early in the 20th century. Perhaps the best illustration of a deadlock is : CSCI-6303 Dr. John P. Abraham

Deadlocks 1.System Model 2.Deadlock Characterization 3.Methods for Handling Deadlocks 4.Deadlock Prevention 5.Deadlock Avoidance 6.Deadlock Detection 7.Recovery from Deadlock In deadlocks, we will disuses these topics. CSCI-6303 Dr. John P. Abraham

1. System Model Under the normal mode of operation, a process utilizes a resource as follows: Request Use Release A process must request a resource before using it, and must release the resource after using it. Request: If the request cannot be granted immediately (for example, the resource is being used by another process), then the requesting process must wait until it can acquire the resource. Use: the process can operate on the resource (for example, if the resource is a printer, the process can print on the printer). Release: the process releases the resource. CSCI-6303 Dr. John P. Abraham

2.Deadlock Characterization Necessary Conditions: Mutual exclusion Hold and wait No preemption Circular wait Mutual exclusion: only one process at a time can use a resource. Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes. No preemption:a resource can be released only voluntarily by the process holding it, after that process has completed its task. Circular wait: there exists a set CSCI-6303 Dr. John P. Abraham

Resource Allocation Graph With A Deadlock P = Process R = Resource CSCI-6303 Dr. John P. Abraham

3. Methods for Handling Deadlocks Ensure that the system will never enter a deadlock state Prevention Allow the system to enter a deadlock state and then recover Detection Ignore the problem and pretend that deadlocks never occur in the system Most operating systems CSCI-6303 Dr. John P. Abraham

4. Deadlock Prevention Mutual Exclusion Hold and Wait No Preemption Circular Wait CSCI-6303 Dr. John P. Abraham

5. Deadlock Avoidance Safe state Resource-Allocation Graph Algorithm Banker’s Algorithm Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. The deadlock-avoidance algorithm dynamically Examines the resource-allocation state to ensure that there can never be a circular-wait condition. Resource-allocation state Is defined by the number of available and allocated resources, and the maximum demands of the processes. CSCI-6303 Dr. John P. Abraham

Safe State CSCI-6303 Dr. John P. Abraham

Resource-Allocation Graph Algorithm CSCI-6303 Dr. John P. Abraham

Unsafe State In Resource-Allocation Graph CSCI-6303 Dr. John P. Abraham

Banker’s Algorithm Data Structures: Available: A vector of length m indicates the number of available resource of each type. Max: An n x m matrix defines the maximum demand of each process. Allocation: An n x m matrix defines the number of resources of each type currently allocated to each process. Need: An n x m matrix indicates the remaining resource need of each process. The name was chosen because this algorithm could be used in a banking system to ensure That the band never allocates it’s available Cash such that it can no longer satisfy the Needs of all it’s customers. CSCI-6303 Dr. John P. Abraham

6. Deadlock Detection Single Instance of Each Resource Type Several Instances of a Resource Type Detection-Algorithm Usage SIER Type: If all resources have only a single instance, the we can define a deadlock detection algorithm that uses a variant of the resource-allocation graph, called a wait-for graph. Detection-Algorithm Usage When should we invoke the detection algorithm? The answer depends on two factors: How often is a deadlocks likely to occur? How many processes will be affected by deadlock when it happens? CSCI-6303 Dr. John P. Abraham

7. Recovery from Deadlock Process Termination Resource Preemption When a detection algorithm detecting the deadlock Exists, one possibility is let the operator deal with The deadlock manually; the other possibility is to Let the system recover from the deadlock Automatically. There two option for breaking a Deadlock: CSCI-6303 Dr. John P. Abraham

Summary of the Deadlock Prevention or avoidance deadlocks, ensuring that the system will never enter a deadlock state. Allow the system to enter deadlock state, detect it, and then recover. Ignore the problem all together, and pretend that deadlocks never occur in the system. CSCI-6303 Dr. John P. Abraham

Thanks! CSCI-6303 Dr. John P. Abraham

Resource-Allocation Graph P = Process R = Resource CSCI-6303 Dr. John P. Abraham

Graph With A Cycle But No Deadlock CSCI-6303 Dr. John P. Abraham