Handling Deadlocks n definition, wait-for graphs n fundamental causes of deadlocks n resource allocation graphs and conditions for deadlock existence n.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Distributed Deadlocks
CS3771 Today: deadlock detection and election algorithms  Previous class Event ordering in distributed systems Various approaches for Mutual Exclusion.
1 Deadlock Deadlock is a situation where a process or a set of processes is blocked on an event that never occurs Processes while holding some resources.
Deadlock Prevention, Avoidance, and Detection
ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
1 Distributed Deadlock Fall DS Deadlock Topics Prevention –Too expensive in time and network traffic in a distributed system Avoidance.
Deadlock and Starvation
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Basics of Deadlock Theory.
6. Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources
Deadlocks in Distributed Systems Ryan Clemens, Thomas Levy, Daniel Salloum, Tagore Kolluru, Mike DeMauro.
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.
Operating Systems Principles Process Management and Coordination Lecture 6: Deadlocks 主講人:虞台文.
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 Deadlock and Starvation Deadlock – two or more processes are waiting indefinitely for.
Distributed process management: Distributed deadlock
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
7: Deadlocks1 DEADLOCKS EXAMPLES: "It takes money to make money". You can't get a job without experience; you can't get experience without a job. BACKGROUND:
Deadlocks – An Introduction
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
Chapter 7 – Deadlock (Pgs 283 – 306). Overview  When a set of processes is prevented from completing because each is preventing the other from accessing.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-6 Deadlocks Department of Computer Science and Software Engineering.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Chapter 7 –System Model – typical assumptions underlying the study of distributed deadlock detection Only reusable resources, only exclusive access, single.
Distributed and hierarchical deadlock detection, deadlock resolution
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
This Time - Deadlock Definition Conditions for deadlocks
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
DEADLOCK DETECTION ALGORITHMS IN DISTRIBUTED SYSTEMS
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 OPERATING SYSTEMS DEADLOCKS created by:-gaurav shrivastava contact:- om.
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.
Ch 3 –What is a deadlock ? –Conditions Hold and Wait Mutual Exclusion Non Preemption Circular Wait –Deadlock Models Single Unit Request AND Request OR.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Deadlocks.
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.
ICS Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources 6.2 Approaches to the Deadlock Problem 6.3 A System Model –Resource Graphs –State.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Process Management Deadlocks.
Chapter 7: Deadlocks.
CSE 120 Principles of Operating
Synchronization: Distributed Deadlock Detection
Ch 3 What is a deadlock ? Conditions Deadlock Models Hold and Wait
The Echo Algorithm The echo algorithm can be used to collect and disperse information in a distributed system It was originally designed for learning network.
ITEC 202 Operating Systems
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Operating System: DEADLOCKS
Process Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Distributed Deadlock Detection
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
OPERATING SYSTEMS DEADLOCKS.
DEADLOCKS.
Operating Systems Principles Process Management and Coordination Lecture 6: Deadlocks 主講人:虞台文.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

Handling Deadlocks n definition, wait-for graphs n fundamental causes of deadlocks n resource allocation graphs and conditions for deadlock existence n approaches to handling deadlocks u deadlock prevention u deadlock avoidance u deadlock detection/resolution F centralized algorithms F distributed algorithms F hierarchical algorithms

What Is a Deadlock? n deadlock – a set of blocked processes waiting for requirements that cannot be satisfied n illustrated by a wait-for-graph (WFG) u nodes – processes in the system u directed edges – wait-for blocking relation u a cycle in WFG indicates a deadlock n starvation – a process is indefinitely prevented from making progress u deadlock implies starvation, is the converse true?

Fundamental Causes of Deadlocks n mutual exclusion — if one process holds a resource, other processes requesting that resource must wait until the process releases it (only one can use it at a time) n hold and wait — processes are allowed to hold one (or more) resource and be waiting to acquire additional resources that are being held by other processes n no preemption — resources are released voluntarily; neither another process nor the OS can force a process to release a resource n circular wait — there must exist a set of waiting processes such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, … Pn-1 is waiting for a resource held by Pn, and Pn is waiting for a resource held P0

Resource Allocation Graph the deadlock conditions can be modeled using a directed graph called a resource- allocation graph (RAG) n 2 kinds of nodes: u boxes — represent resources F Instances of the resource are represented as dots within the box u circles — represent processes n 2 kinds of (directed) edges: u request edge — from thread to resource — indicates the thread has requested the resource, and is waiting to acquire it u assignment edge — from resource instance to thread — indicates the thread is holding the resource instance n when a request is made, a request edge is added u when request is fulfilled, the request edge is transformed into an assignment edge u when process releases the resource, the assignment edge is deleted

RAG with Single Resource Instances n a cycle in RAG with single resource instances is necessary and sufficient for deadlock p1 p2 p3 r1 r2 r3 r4 p1 p2 p3 r1 r2 r3 r4

RAG with Multiple Resource Instances n cycle does not indicate deadlock n knot – strongly connected subgraph (no sinks) with no outgoing edges n a knot in RAG is necessary and sufficient for deadlock p1 p2 p3 r1 r2 r3 r4 p1 p2 p3 r1 r2 r3 r4

Deadlock Prevention and Avoidance n deadlock prevention — eliminate one of the 4 deadlock conditions u examples F acquire all resources before proceeding (no wait while hold) F allow preemption (eliminate 3d condition) F prioritize processes and assign resources in the order of priorities (no circular wait) u may be inefficient n deadlock avoidance — consider each resource request, and only fulfill those that will not lead to deadlock u stay in a safe state — a state with no deadlock where resource requests can be granted in some order such that all processes will complete u may be inefficient F must know resource requirements of all processes in advance F resource request set is known and fixed, resources are known and fixed F complex analysis for every request

Deadlock Detection n Deadlock detection and resolution — detect, then break the deadlock n detection u issues F maintenance of WFG F search of WFG for deadlocks u requirements F progress – no undetected deadlocks F safety – no false (phantom) deadlocks n resolution u roll back one or more processes to break dependencies in WFG and resolve deadlocks

Distributed Deadlock Detection Algorithms n centralized algorithm - coordinator maintains global WFG and searches it for cycles u simple algorithm u Ho and Ramamoorthy’s one- and two-phase algorithms n distributed algorithms - global WFG, with responsibility for detection spread over many sites u Obermarck’s path-pushing u Chandy, Misra, and Haas’s edge-chasing u diffusion n hierarchical algorithms - hierarchical organization, site detects deadlocks involving only its descendants u Menasce and Muntz’s algorithm u Ho and Ramamoorthy’s algorithm

Simple Centralized Deadlock Detection n the central coordinator maintains a global wait-for graph (WFG) for the system n all sites request and release resources (even local resources) by sending request and release messages to the coordinator n when coordinator receives a request/release, it u updates the global WFG u checks for deadlocks n problems u large communication overhead, coordinator is a performance bottleneck u may report phantom deadlock

Problem of False Deadlock n now assume process p1 releases resource p3 is waiting on, requests resource p2 has n p2 requests resource p3 is holding n however, first message reaches coordinator after second message n the global WFG now has a false cycle, which leads to a report of false deadlock p1 p2 p3 p1 p3 p1 p2 site Asite Bcoordinator

Ho and Ramamoorthy Two-Phase Deadlock Detection n every site maintains a status table, containing status of all local processes u resources held, resources waiting on n periodically, coordinator requests all status tables, builds a WFG, and searches it for cycles u no cycles - no deadlock u If cycle is found, coordinator again requests all status tables, again builds a WFG, but this time uses only those edges common to both sets of status tables n rationale was that by using information from two consecutive reports, coordinator would get a consistent view of the state u however, it was later shown that a deadlock in this WFG does not imply a deadlock exists (see 1 phase alg.) F the HR-two-phase algorithm may reduce the possibility of reporting false deadlocks, but doesn’t eliminate it

Ho and Ramamoorthy One-Phase Deadlock Detection n every site maintains two tables u all local processes and resources the locked u resources locked at this site (by both local and non-local processes) n one site periodically requests both tables (once) constructs WFG; WFG only includes the info on non-local processes if this info is matched by the process site and resource site u if cycle – deadlock u if not – no deadlock n correctly detects deadlocks by eliminating inconsistency of reporting due to message propagation delay n more space overhead than 2-phase H&R

Centralized deadlock detection (cont.) n Second Algorithm u A central coordinator maintains a global wait-for graph (WFG) for the system F Individual sites also maintain local WFGs for local processes and resources F Global WFG is an approximation of the total state of the system u When should the coordinator update the WFG and try to detect deadlocks? 1.Whenever a new edge is inserted or removed in a local WFG Site informs coordinator via a message Global WFG can be slightly out-of-date 2.Periodically, when a number of changes have been made to WFG Site sends several changes at once Global WFG can be more out-of-date 3.Whenever it needs to detect deadlock