Chapter 7: Deadlocks.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 7: Deadlocks Adapted by Donghui Zhang from the original version by Silberschatz et al.
ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
DEADLOCK. Contents  Principles of deadlock  Deadlock prevention  Deadlock detection.
Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 27 CPU Simulator III.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
1 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
02/18/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Chapter 7.1: 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.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bridge Crossing Example Traffic only in one direction. Each section.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling 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.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 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.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
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.
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.
Deadlocks - System Model - Deadlock characterization - Methods for handling deadlocks - Deadlock prevention,avoidance - Deadlock detection and recovery.
Deadlock. Chapter 7: Deadlocks 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 Chapter 6: 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 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
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);
Thursday, February 23, 2012 Chapter 6 homework questions?
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Operating Systems (CS 340 D)
Chapter 7: Deadlocks.
Operating System: DEADLOCKS
Chapter 7 Deadlocks.
Process Deadlocks.
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
DPNM Lab. Dept. of CSE, POSTECH
Chapter 8: Deadlocks.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
Chapter 7: Deadlocks.
Lecture 26 Syed Mansoor Sarwar
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:

Chapter 7: Deadlocks

Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks

Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To present methods for Handling Deadlocks

Introduction

Introduction 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 waiting state. Sometimes, a waiting process is never again able to change state, because the resources it has requested are held by other waiting processes. This situation is called a DEADLOCK.

The Deadlock Problem What is a deadlock problem?? A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set Example System has 2 disk drives P1 and P2 each hold one disk drive and each needs another one Note :– Most OSs do not prevent or deal with deadlocks

Bridge Crossing Example Traffic only in one direction Each section of a bridge can be viewed as a resource If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback) Several cars may have to be backed up if a deadlock occurs Starvation is possible

System Model

System Model The resources are partitioned into several types (R1, R2, . . ., Rm ) E.g.: CPU cycles, memory space, I/O devices Each resource type Ri has Wi instances. Examples: If a system has (2) CPUs, then the resource type CPU has (2) instances. The resource type printer may have (5) instances. Each process utilizes a resource as follows: Request >> If the request cannot be granted immediately ,then the requesting process must wait until it can acquire the resource. Use Release Instances are identical

System Model (cont.) A set of processes is in a deadlocked state when every process in the set is waiting for an event that can be caused only by another process in the set. Resource forms: Physical resources e.g. printers, DVD drives, memory space, and CPU cycles Logical resources e.g. files Example: consider a system with one printer and one DVD drive. Suppose that process Pi is holding the DVD and process Pj is holding the printer. If Pi requests the printer and Pj requests the DVD drive, a deadlock occurs.

Deadlock Characterization

Deadlock Characterization Deadlock can arise if four conditions hold simultaneously: Mutual exclusion: only one process at a time can use a resource…(i.e. No recourse sharing) 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 {P0, P1, …, Pn} of waiting processes such that : P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, Pn is waiting for a resource that is held by P0.

Resource-Allocation Graph Deadlocks can be described in terms of a directed graph called a system resource-allocation graph. This graph consists of a set of vertices V and a set of edges E. V is partitioned into two types: P = {P1, P2, …, Pn}, the set consisting of all the processes in the system R = {R1, R2, …, Rm}, the set consisting of all resource types in the system E is partitioned into two types: Request edge – directed edge Pi  Rj Assignment edge – directed edge Rj  Pi

Resource-Allocation Graph (Cont.) Process Resource Type with 4 instances Pi requests instance of Rj Pi is holding an instance of Rj Pi Rj Pi Rj

Example of a Resource Allocation Graph The sets P, R, and E: P = {P1, P2, P3} R = {R1, R2, R3, R4} E = {P1 → R1, P2 → R3, R1 → P2, R2 → P2, R2 → P1, R3 → P3} Resource instances: (1) instance of resource type R1 (2) instances of resource type R2 (1) instance of resource type R3 (3) instances of resource type R4 Process states: Process P1 is holding an instance of resource type R2 and is waiting for an instance of resource type R1. Process P2 is holding an instance of R1 and an instance of R2 and is waiting for an instance of R3. Process P3 is holding an instance of R3.

Basic Facts How we recognize deadlock by using a Resource Allocation Graph?? If graph contains no cycles  no deadlock If graph contains a cycle  If only one instance per resource type, then there is a deadlock If several instances per resource type, possibility of deadlock .

Resource Allocation Graph With NO Deadlock Example (1): The graph contains NO cycles  NO deadlock is occurred.

Resource Allocation Graph With a Deadlock Example (2): The graph contains (2)cycles  may be a deadlock is occurred. Cycle (1) : P1 → R1 → P2 → R3 → P3 → R2 → P1 Cycle (2) :P2 → R3 → P3 → R2 → P2 It ‘s a dead lock situation >>> Processes P1, P2, and P3 are deadlocked…….why?? There is no chance to break the cycle.

Graph With A Cycle But No Deadlock Example (3): The graph contains (1)cycle  may be a deadlock Cycle : P1 → R1 → P3 → R2 → P1 NO dead lock situation .....WHY???? process P4 may release its instance of resource type R2…… That resource can then be allocated to P3, breaking the cycle.

Methods for Handling Deadlocks

Methods for Handling Deadlocks OS can deal with the deadlock problem in one of three ways: Use a protocol to prevent or avoid deadlocks, ensuring that the system will never enter a deadlocked state. Allow the system to enter a deadlocked state, detect it, and recover. Ignore the problem altogether and pretend that deadlocks never occur in the system. Used by most operating systems, including Unix & windows This method is cheaper than the prevention, avoidance, or detection and recovery methods. Solution: The system must be restarted manually.

End of Chapter 7