This Time - Deadlock Definition Conditions for 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.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
DEADLOCK. Contents  Principles of deadlock  Deadlock prevention  Deadlock detection.
Chapter 7: Deadlocks.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Deadlock Emery Berger and Mark Corner University of Massachusetts.
1 CSC 539: Operating Systems Structure and Design Spring 2005 Process deadlock  deadlock prevention  deadlock avoidance  deadlock detection  recovery.
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:
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.
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
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.
The ‘deadlock’ conditions Reviewing some key points concerning the potential for ‘deadlock’ in an operating system.
Deadlock Prevention CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
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.
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.
Deadlock Characterization
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Deadlocks in resource allocation Fall 09. Deadlock Problem  A set of blocked processes each holding a resource and waiting to acquire a resource held.
Chapter 7 – Deadlock (Pgs 283 – 306). Overview  When a set of processes is prevented from completing because each is preventing the other from accessing.
Operating Systems Part III: Process Management (Deadlocks)
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 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.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
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.
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.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
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.
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);
Chapter 7: Deadlocks.
Process Management Deadlocks.
Synchronization Deadlocks and prevention
Chapter 7: Deadlocks.
CSE 120 Principles of Operating
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.
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Deadlocks Definition A set of processes is in a Deadlock state when every process in the set is waiting for an event that can only be caused by another.
G.Anuradha Ref:- Galvin
CSc 552 Advanced Unix Process deadlock deadlock prevention
Deadlocks Session - 13.
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Chapter 8: Deadlocks Deadlock Characterization
Presentation transcript:

This Time - Deadlock Definition Conditions for deadlocks Deadlock prevention & detection

Binary semaphore: printer, disk. Both initialized to be 1. Deadlocks Deadlock = condition where multiple threads/processes wait on each other thread A printer->wait(); disk->wait(); do stuffs … disk->signal(); printer->signal(); thread B disk->wait(); printer->wait(); do stuffs … printer->signal(); disk->signal(); Binary semaphore: printer, disk. Both initialized to be 1.

Deadlocks, Example II

Deadlocks - Terminology Can occur when several threads compete for finite number of resources simultaneously Deadlock prevention algorithms: Check resource requests & availability Deadlock detection: Finds instances of deadlock when threads stop making progress Tries to recover Note: Deadlock ≠ Starvation

When Deadlock Occurs All of below must hold: Mutual exclusion: An instance of resource used by one thread at a time Hold and wait One thread holds resource while waiting for another; other thread holds that resource No preemption Thread can only release resource voluntarily No other thread or OS can force thread to release resource Circular wait Set of threads {t1, …, tn}: ti waits on ti+1, tn waits on t1

Deadlock: Example If no way to free resources (preemption), deadlock

Deadlock Detection: Resource Allocation Graph Define graph with vertices: Resources = {r1, …, rm} Threads = {t1, …, tn} Request edge from thread to resource ti → rj Thread requested resource but not acquired it Assignment edge from resource to thread rj → ti OS has allocated resource to thread Deadlock detection No cycles → no deadlock Cycle → might be deadlock

Resource Allocation Graph: Example Deadlock or not? Request edge from thread to resource ti → rj Thread requested resource but not acquired it Assignment edge from resource to thread rj → ti OS has allocated resource to thread

Deadlock Detection: Multiple Resources What if there are multiple instances of a resource? Cycle → deadlock might exist If any instance held by thread outside cycle, progress is possible when thread releases resource

Deadlock Detection Deadlock or not?

Resource Allocation Graph: Example Draw a graph for the following event: Each car going straight Request edge from thread to resource ti → rj Thread: requested resource but not acquired it Assignment edge from resource to thread rj → ti OS has allocated resource to thread

Resource Allocation Graph : Example Draw a graph for the following event:

Detecting Deadlock (Single Instance of Resource) Scan resource allocation graph for cycles & break them! Different ways to break cycles: Kill all threads in cycle Kill threads one at a time Force each to give up resources Preempt resources one at a time Roll back thread state to before acquiring resource Common in database transactions

Detecting Deadlock (Single Instance of Resource) Detecting cycles takes O(n2)time n = |T| + |R| When to detect: When request cannot be satisfied On regular schedule, e.g. every hour When CPU utilization drops below threshold

Deadlock Prevention One way - instead of detection, ensure at least one of necessary conditions doesn’t hold Mutual exclusion Hold and wait No preemption Circular wait

Deadlock Prevention Mutual exclusion: Hold and wait Make resources shareable (but not all resources can be shared) Hold and wait Guarantee that thread cannot hold one resource when it requests another Make threads request all resources they need at once and release all before requesting new set

Deadlock Prevention, continued No preemption If thread requests resource that cannot be immediately allocated to it OS preempts (releases) all resources thread currently holds When all resources available: OS restarts thread Problem: not all resources can be preempted

Deadlock Prevention, continued Circular wait Impose ordering (numbering) on resources and request them in order These solutions are not entirely adequate...