Distributed and hierarchical deadlock detection, deadlock resolution

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.
1 Distributed Deadlock Fall DS Deadlock Topics Prevention –Too expensive in time and network traffic in a distributed system Avoidance.
Handling Deadlocks n definition, wait-for graphs n fundamental causes of deadlocks n resource allocation graphs and conditions for deadlock existence n.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
6. Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources
Deadlocks in Distributed Systems Ryan Clemens, Thomas Levy, Daniel Salloum, Tagore Kolluru, Mike DeMauro.
Chapter 6 Concurrency: Deadlock and Starvation
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.
1 CSC 539: Operating Systems Structure and Design Spring 2005 Process deadlock  deadlock prevention  deadlock avoidance  deadlock detection  recovery.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 30 Handling Deadlock.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
03/07/2007CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
03/03/2004CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
Distributed process management: Distributed deadlock
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Deadlocks – An Introduction
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.
Deadlock Questions answered in this lecture: What are the four necessary conditions for deadlock? How can deadlock be prevented? How can deadlock be avoided?
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)
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.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-6 Deadlocks Department of Computer Science and Software Engineering.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Deadlocks II.
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.
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.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
DEADLOCK DETECTION ALGORITHMS IN DISTRIBUTED SYSTEMS
Chapter 7 Deadlocks Page 2 Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Chapter 81 Deadlock Avoidance Technique  Resource Allocation Denial: Grant incremental resource requests if we can prove that this leaves the system in.
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings.
Operating Systems Unit VI Deadlocks and Protection Department of Computer Science Engineering and Information Technology.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Academic Year 2014 Spring Academic Year 2014 Spring.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Parallel and Distributed Simulation Deadlock Detection & Recovery.
Deadlocks Copyright ©: University of Illinois CS 241 Staff1.
7.1 CSE Department MAITSandeep Tayal 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
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.
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);
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Process Management Deadlocks.
CSE 120 Principles of Operating
Synchronization: Distributed Deadlock Detection
Concurrency: Deadlock and Starvation
Deadlock Detection & recovery
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.
Chapter 7: Deadlocks.
Process Deadlocks.
Ho-Ramammorthy 2 phase snapshot algorithm PRESENTATION
Chapter 7: Deadlocks.
Deadlocks Session - 14.
The relation between the process and
Chapter 7: Deadlocks.
Distributed Deadlock Detection
Chapter 8: Deadlocks Deadlock Characterization
Presentation transcript:

Distributed and hierarchical deadlock detection, deadlock resolution distributed algorithms Obermarck’s path-pushing Chandy, Misra, and Haas’s edge-chasing hierarchical algorithms Menasce and Muntz’s algorithm Ho and Ramamoorthy’s algorithm resolution

Distributed deadlock detection Path-pushing WFG is disseminated as paths — sequences of edges Deadlock if process detects local cycle Edge-chasing Probe messages circulate Blocked processes forward probe to processes holding requested resources Deadlock if initiator receives own probe

Obermarck’s Path-Pushing 4/25/2017 Obermarck’s Path-Pushing Individual sites maintain local WFGs Nodes for local processes Node “Pex” represents external processes Pex1 -> P1 -> P2 ->P3 -> Pex2 a process may wait for multiple other processes Deadlock detection: site Si finds a cycle that does not involve Pex – deadlock site Si finds a cycle that does involve Pex – possibility of a deadlock sends a message containing its detected path to the downstream sites to decrease network traffic the message is sent only when Pex1 > Pex2 assumption: the identifier of a process spanning the sites is the same! If site Sj receives such a message, it updates its local WFG graph, and reevaluates the graph (possibly pushing a path again)

Chandy, Misra, and Haas’s Edge-Chasing When a process has to wait for a resource (blocks), it sends a probe message to process holding the resource Process can request (and can wait for) multiple resources at once Probe message contains 3 values: ID of process that blocked ID of process sending message ID of process message was sent to When a blocked process receives a probe, it propagates the probe to the process(es) holding resources that it has requested ID of blocked process stays the same, other two values updated as appropriate If the blocked process receives its own probe, there is a deadlock size of a message is O(1)

Performance evaluation of Obermarck’s and Chandy-Misra-Haas algorithms 4/25/2017 Performance evaluation of Obermarck’s and Chandy-Misra-Haas algorithms Obermarck’s on average(?) only half the sites involved in deadlock send messages every such site sends one message, thus n(n–1)/2 messages to detect deadlock for n sites size of a message is O(n) Chandy, Misra, and Haas’s (Singhal’s estimate is incorrect) given n processes, a process may be blocked by up to (n-1) processes, the next process may be blocked by another (n-2) processes and so on. If there is more sites than processes, the worst case the number of messages is n(n-1)/2. If there are fewer sites m than processes then the worst case estimate is n2(n-m)/2m size of a message is 3 integers This is on Chandy-Misra-Haas and Obermark's algorithm. The links to the original papers are on the course's website. I advise you to read the original papers as Singhal's description is not very precise. Both algorithms assume that a process may wait for more than one process. However, this is different from multiple resource instances that we studied. For CMH and Obermark's it is assumed that the process will not be able to make progress unless BOTH processes free their resources. Thus, in the worst case the processes wait-for graph (WFG) is completely connected. Assume that all links span sites. Thus, the total number of external links is n(n-1)/2 where n is the number of processes. My message complexity estimate is as follows. For CMH, Each (process) initiator maintains a counter. Every time there is an external chain, the process increments the counter and sends a probe with this counter. Each process keeps the counter for all other processes and only sends the probe once (for each initiator and each counter). In the worst case, the probe for one initiator can traverse all edges in the WFG. In their (conference) paper CMH try to limit the number of initiators per deadlock by allowing only the processes that just obtained an incoming link in the WFG to initiate the probes. However, the cycle can be formed such that the links are formed in parallel. Hence every process becomes an initiator. Thus, the total number of messages in the worst case is n*n*(n-1)/2 which is in O(n^3) ---- For Obermark, the sites send a "path" to the other sites. Recall, that to decrease traffic Obermark proposes that only those sites send the path whose outgoing process identifier is less than incoming. BTW, I was not clear in class, Obermark proposes that the site sends the path only to the "downstream" with respect to the shared process (transaction). That is the site does not broadcast it to all other sites. Now, let us estimate the complexity of the algorithm. I find it a little easier to think of processes being inside the sites and the edges in the WFG being external. The reasoning, however, is similar in Obermark's notation. Suppose the identifiers of the processes are 1, 2, ..., n Suppose all WFG links are external and the higher id processes wait for the lower id ones (except for process 1 that waits for process n so that we have a deadlock) For simplicity, suppose there are n sites (one per process). Let us call the sites by the identifier of the process that resides there: 1, 2, 3, ..., n In the worst case, - site 2 pushes process id 2 to site 1, - site 3 pushes process id 3 to sites 1 and 2 -- this forces site 2 to push process id 3 to site 1. and so on Thus, process n identifier travels along all links, process (n-1) travels along all links except those leading to site n, and so on. Notice that the graph is completely connected. The total number of links is n(n+1)/2 Thus, the number of links, process n travels is n(n+1)/2 process n-1: (n-1)n/2 The total number of messages is: n(n+1)/2 + (n-1)n/2 + (n-2)(n-1)/2 + (n-3)(n-2)/2 + .... doing pairwise factoring we obtain [ n(n+1 + n-1) + (n-2)(n-1+n-3) + ...] / 2 simplify [ n * 2n + (n-2)(2n-4) + (n-4)(2n-8) + ...]/2 factoring 2 we obtain n^2 + (n-2)^2 + (n-4)^2 + ... There is probably an exact formula for this series, but I just estimated it from above and below. Let us call the above sum A(n) It is known that n^2 + (n-1)^2 + (n-2)^2 + ... = n(n+1)(2n+1)/6 Let's call this sum B(n) Clearly, B(n) > A(n) since some of the addends of B(n) are missing from A(n). Let us estimate B(n) from below. Let us consider 2A(n) = 2n^2 + 2(n-2)^2 + ... it is smaller than n^2 + (n-1)^2 + (n-2)^2 + (n-3)^2 + ... That is 2A(n) > B(n). Which means that B(n) > A(n) > B(n)/2 Observe that both B(n) and B(n)/2 are in O(n^3) Therefore A(n) is in O(n^3). That is, the worst case message complexity of Obermark's algorithm is the same as that of CMH and it is cubic with respect to the number of processes in the system. -------------------- THIS IS OLD It is not clear how Singhal came up with the message complexity for CMH. I put the original paper on the web. In the paper the complexity is computed as follows. There could be at least one probe message passed between each pair of processes in the system. Consider the case of N processes. In the worse case process P1 can wait for processes P2..PN, P2 -- for P3..PN, and so on. If all processes are on separate sites, the total number of probe messages will be N(N-1)/2. However, the original paper does not consider a situation where the number of sites M is smaller than the number of processes. Suppose this is the case. Observe that if two processes share a site, the wait-for link between them does not generate a message. Hence the worst case allocation of processes is such that the maximum number of links is external. I'd like to show that the number of external links is maximized when the processes are spread evenly among the sites. Indeed, let us consider the following setup. Two sites A and B have NA and NB processes respectively such that NA > NB. Suppose that all processes wait for each other. Let us consider moving a process P from site A to site B. In this move, all wait-for links from P to processes in A are externalized and all links from P to processes in B are internalized. Since all processes wait for each other. The number of externalized links is NA-1 and the number of internalized links is NB. This means that if we move a process from A to B (where the number of processes is NA > NB) the number of external links at least does not decrease. Hence, the maximum number of external links is when the number of processes is equal on all sites. Now let us count the number of external links. I am going to count all links and then subtract the ones that are internalized due to processes being on the same site. The total number of links (as calculated above) is N(N-1)/2. Let us count internal links. Suppose M divides N. This means that the number of processes at each site is N/M. Since every process is connected with every other by wait-for relation, the number of internal links per site is: N/M(N/M-1) ---------- 2 that is N(N-M)/2(M*M). There are exactly M sites. Hence, the total number of internal links is M*N(N-M)/2(M*M) which is N(N-M)/2M The final formula is: N(N-1) N(N-M) ----- - ----- 2 2M Which simplifies to: N*N*(M-1) --------- 2M

Menasce and Muntz’ hierarchical deadlock detection Sites (called controllers) are organized in a tree Leaf controllers manage resources Each maintains a local WFG concerned only about its own resources Interior controllers are responsible for deadlock detection Each maintains a global WFG that is the union of the WFGs of its children Detects deadlock among its children changes are propagated upward either continuously or periodically

Ho and Ramamoorthy’s hierarchical deadlock detection Sites are grouped into disjoint clusters Periodically, a site is chosen as a central control site Central control site chooses a control site for each cluster Control site collects status tables from its cluster, and uses the Ho and Ramamoorthy one-phase centralized deadlock detection algorithm to detect deadlock in that cluster All control sites then forward their status information and WFGs to the central control site, which combines that information into a global WFG and searches it for cycles Control sites detect deadlock in clusters Central control site detects deadlock between clusters

Estimating performance of deadlock detection algorithms Usually measured as the number of messages exchanged to detect deadlock Deceptive since message are also exchanged when there is no deadlock Doesn’t account for size of the message Should also measure: Deadlock persistence time (measure of how long resources are wasted) Tradeoff with communication overhead Storage overhead (graphs, tables, etc.) Processing overhead to search for cycles Time to optimally recover from deadlock

Deadlock resolution resolution – aborting at least one process (victim) in the cycle and granting its resources to others efficiency issues of deadlock resolution fast – after deadlock is detected the victim should be quickly selected minimal – abort minimum number of processes, ideally abort less “expensive” processes (with respect to completed computation, consumed resources, etc.) complete – after victim is aborted, info about it quickly removed from the system (no phantom deadlocks) no starvation – avoid repeated aborting of the same process problems detecting process may not know enough info about the victim (propagating enough info makes detection expensive) multiple sites may simultaneously detect deadlock since WFG is distributed removing info about the victim takes time

Deadlock recovery (cont.) Any less drastic alternatives? Preempt resources One at a time until no deadlock Which “victim”? Again, based on cost, similar to CPU scheduling Is rollback possible? Preempt resources — take them away Rollback — “roll” the process back to some safe state, and restart it from there OS must checkpoint the process frequently — write its state to a file Could roll back to beginning, or just enough to break the deadlock This second time through, it has to wait for the resource Has to keep multiple checkpoint files, which adds a lot of overhead Avoid starvation May happen if decision is based on same cost factors each time Don’t keep preempting same process (i.e., set some limit)