June 11, 2002Serguei A. Mokhov, 1 Deadlock COMP346 - Operating Systems Tutorial 5 Edition 1.1, June 15, 2002.

Slides:



Advertisements
Similar presentations
Deadlock and Starvation
Advertisements

DEADLOCK. Contents  Principles of deadlock  Deadlock prevention  Deadlock detection.
5/25/2015Page 1 Deadlock Management B. Ramamurthy.
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:
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.
DPNM Lab. Dept. of CSE, POSTECH
Deadlock Chapter 3 R1 R2 P2P1 Allocated Requested.
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.
Deadlocks. 2 System Model There are non-shared computer resources –Maybe more than one instance –Printers, Semaphores, Tape drives, CPU Processes need.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
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.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Deadlock and Starvation Deadlock – two or more processes are waiting indefinitely for.
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 ©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.
System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention, Avoidance, and Detection Recovering from Deadlock Combined Approach.
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.
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.
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 28 Handling Deadlock.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Chapter 8: Deadlocks Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
June 6, 2002Serguei A. Mokhov, 1 Salsa Theory Debrief 2 COMP346 - Operating Systems Tutorial 6 Edition 1.1, June 19, 2002.
CS 346 – Chapter 7 Deadlock –Properties –Analysis: directed graph Handle –Prevent –Avoid Safe states and the Banker’s algorithm –Detect –Recover.
Chapter 7 Deadlocks. 7.1 Introduction Deadlock Common approaches to deal with deadlock – Prevention – Avoidance – Detection and recovery.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
1 Module 6: Deadlocks Reading: Chapter 7 Objective:  To develop a description of deadlocks, which prevent sets of concurrent processes from completing.
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.
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
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.
Operating Systems Unit VI Deadlocks and Protection Department of Computer Science Engineering and Information Technology.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
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.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks.
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.
Process Management Deadlocks.
Operating System: DEADLOCKS
Chapter 7: Deadlocks.
Process Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Deadlocks Peng Lu In a multiprogramming environment, several processes may compete for a finite number of resources. A process requests resources; if the.
Chapter 8: Deadlocks.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
DEADLOCK.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
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:

June 11, 2002Serguei A. Mokhov, 1 Deadlock COMP346 - Operating Systems Tutorial 5 Edition 1.1, June 15, 2002

June 11, 2002Serguei A. Mokhov, 2 Topics Deadlock Debrief –Simplest Example –Necessary Deadlock Conditions –Resource Allocation Graph –Deadlock Handling Deadlock and Starvation with Semaphores Examples

June 11, 2002Serguei A. Mokhov, 3 Deadlock Simplest example: –Two processes require two resources to complete (and release the resources) –There are only two instances of these resources –If they acquire one resource each, they block indefinitely waiting for each other to release the other resource => DEADLOCK, one of the biggest problems in multiprogramming. R1 P1P2 R2

June 11, 2002Serguei A. Mokhov, 4 Necessary Deadlock Conditions Recall which conditions must hold (p. 245): –ME: at least one process exclusively uses a resource –Hold and wait: a process possesses at least one resources and requires more, which are held by others –No preemption: resources are released only in voluntary manner by processes holding them –Circular wait: P 1  P 2  P 3  …  P N  P 1

June 11, 2002Serguei A. Mokhov, 5 Resource-Allocation Graph An easy way to illustrate resource allocation and visually detect the deadlock situation(s) Example: –N+1 resources –N processes –Every process needs 2 resources –Upon acquiring 2 resources, a process releases them –Is there a deadlock? P1P2P3 ?

June 11, 2002Serguei A. Mokhov, 6 More Examples Example from Salsa Theory Review Resource Allocation Graph Is the following true or false? –Deadlock cannot happen in a system with two processes. One CPU Two CPUs

June 11, 2002Serguei A. Mokhov, 7 Handling Deadlocks Deadlock Ignorance Deadlock Prevention Deadlock Avoidance Deadlock Detection and Recovery

June 11, 2002Serguei A. Mokhov, 8 Deadlock Ignorance As system designers we may pretend that deadlocks don’t happen :-). If they do happen, they don’t happen very often. Most common approach because it’s cheap (in terms of human labor, complexity of the system and system’s performance). Highest resource utilization. Sysadmin can simply kill deadlocked processes or restart the system if it’s not responding.

June 11, 2002Serguei A. Mokhov, 9 Deadlock Prevention Recall necessarily deadlock conditions Deadlock prevention algorithms assure at least one these conditions do not hold, thus preventing occurrence of the deadlock. Possible Disadvantages: –Low device utilization –Reduced system’s throughput [1] p. 250

June 11, 2002Serguei A. Mokhov, 10 Deadlock Avoidance Unlike in deadlock prevention, deadlock avoidance algorithms do not watch for necessary deadlock conditions, but use additional a priori info about future resource requests. This info will help the system to avoid entering the unsafe state. Disadvantages: again, lower resource utilization (because resources may not be granted sometimes even if they are unused). [1] P. 253

June 11, 2002Serguei A. Mokhov, 11 Deadlock Detection and Recovery Instead of preventing or avoiding deadlocks we allow them to happen and also provide mechanisms to recover. Problems: –How often do we run detection algorithms? –How do we recover? –What is the cost of detection and recovery? [1] P. 260, p. 264

June 11, 2002Serguei A. Mokhov, 12 Deadlocks and Starvation with Semaphores Semaphores act like resources in this case, which can be acquired and (never) released. One example as book suggests: [1] P. 204 P1 wait(sem1) wait(sem2) … signal(sem1) signal(sem2) P2 wait(sem2) wait(sem1) … signal(sem2) signal(sem1)

June 11, 2002Serguei A. Mokhov, 13 Deadlocks and Starvation with Semaphores (2) Starvation, or indefinite blocking, is when a process is waiting on a semaphore where nobody is ever going to release it. Another example of both deadlock and starvation: process A { process B { wait(mutex) wait(mutex) wait(synch) signal(synch) wait(synch) signal(mutex) signal (mutex) } For this case assume: mutex = 1 synch = 0 Try starting processes in any order and see where they block.

June 11, 2002Serguei A. Mokhov, 14 Deadlocks and Starvation with Semaphores (3) Yet another example :-) a)semaphore S = -2; P1 {P2 {P3 { V(S) V(S) V(S) P(S) P(S) P(S) }} } b)semaphore S = -2, S1 = 0, S2 = 0; P1 {P2 {P3 { V(S) V(S) V(S) P(S) P(S) P(S) V(S1) P(S1) P(S2) V(S2) }

June 11, 2002Serguei A. Mokhov, 15 Deadlocks and Starvation with Semaphores (4) Things to note: –Assume the P2, P3, P1 order in the starvation example; –Assume the P1, P3, P2 order in the deadlock example; –Blocking means getting out from the running state to the waiting state, so a context switch to the next process in the queue happens; –In these example there are no multiple instances of these processes.

June 11, 2002Serguei A. Mokhov, 16 Deadlocks and Starvation with Semaphores (5) Starvation scenario (in b): 1) P2: 2) V(S) (S = -1) 3) P(S) (blocked->switch to P3) 4) P3: 5) V(S) (S = 0) 6) P(S) (blocked->switch to P1) 7) P1: 8) V(S) (S = 1) 9) P(S) (S = 0) 10) V(S1) (S1 = 1) 11) 12) terminates 13) ??? Deadlock Scenario: 1) P1: 2) V(S) (S = -1) 3) P(S) (blocked->switch to P3) 4) P3: 5) V(S) (S = 0) 6) P(S) (blocked->switch to P2) 7) P2: 8) V(S) (S = 1) 9) P(S1) (blocked) 10) ???