CS3771 Today: deadlock detection and election algorithms  Previous class Event ordering in distributed systems Various approaches for Mutual Exclusion.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Deadlock Prevention, Avoidance, and Detection
Handling Deadlocks n definition, wait-for graphs n fundamental causes of deadlocks n resource allocation graphs and conditions for deadlock existence n.
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
Token-Dased DMX Algorithms n LeLann’s token ring n Suzuki-Kasami’s broadcast n Raymond’s tree.
Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Lectures 25-26: Distributed Coordination (Ch 18)
Chapter 18: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 18 Distributed Coordination Event Ordering.
Chapter 16: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 11, 2005 Chapter 16 Distributed.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 17 Distributed Coordination Event Ordering Mutual Exclusion Atomicity Concurrency.
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.
Distributed Coordination CS 3100 Distributed Coordination1.
CS 582 / CMPE 481 Distributed Systems
What we will cover…  Distributed Coordination 1-1.
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.
Chapter 18-1: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 18 Distributed Coordination Chapter.
Module 2.4: Distributed Systems
Chapter 18: Distributed Coordination (Chapter 18.1 – 18.5)
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
Distributed process management: Distributed deadlock
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Chapter 18.3: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 18 Distributed Coordination Chapter.
1 Mutual exclusion (mx) and Deadlock(dl) handling Overview of Event Ordering Mutual Exclusion Atomicity Locking protocols Time-stamping Deadlock Handling.
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.
O/S 4740 Distributed Coordination. Event Ordering In a Centralized system, we have common memory and clock, –So we can always determine the order that.
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.
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.
Distributed and hierarchical deadlock detection, deadlock resolution
Chapter 18: Distributed Coordination Adapted to COP4610 by Robert van Engelen.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Lecture 12 Handling Deadlock – Prevention, avoidance and detection.
Chapter 16: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 11, 2005 Outline n Event.
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 Chapter 11 Global Properties (Distributed Termination)
Chapter 18: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 11, 2005 Chapter 18 Distributed.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Silberschatz and Galvin  Operating System Concepts Module 18: Distributed Coordination Event Ordering Mutual Exclusion Atomicity Concurrency.
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.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 7: Deadlocks.
Chapter 18: Distributed Coordination
Synchronization: Distributed Deadlock Detection
Operating System: DEADLOCKS
Chapter 7 Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Distributed Deadlock Detection
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
Module 18: Distributed Coordination
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

CS3771 Today: deadlock detection and election algorithms  Previous class Event ordering in distributed systems Various approaches for Mutual Exclusion in distributed systems Centralized approach Token based approach Fully distributed approach Deadlock prevention  Today: Deadlock detection Global wait-for graph Deadlock detection algorithms Election algorithms

CS3772 Deadlock handling with deadlock detection  The deadlock-prevention may preempt resources even if no deadlock has occurred!  Deadlock detection is based on so called wait-for graphs, corresponds to local or nonlocal processes that either hold or request local resources.  A wait-for graph shows resource allocation state  A cycle in the wait-for graph represents deadlock P5P3 P1P2 P3 P2 P4 Site A Site B

CS3773 Global wait-for graphs  To show that there is NO DEADLOCK it is not enough to show that there is no cycle locally  We need to construct the global wait-for graph  It is the union of all local graphs. P5P3 P1 P2 P4

CS3774 How to construct this global wait-for graph?  Centralized approach:  The graph is maintained in ONE process: the deadlock-detection coordinator  Since there is communication delay in the system we have two types of graphs: Real wait-for graph // real but unknown state of the system Constructed wait-for graph // approximation generated by the coordinator during the execution of its algorithm  When is the wait-for graph constructed? 1.Whenever a new local edge inserted/removed a message is sent 2. Periodically maintained 3. Whenever the coordinator invokes the cycle-detector algorithm  What happens if a cycle is detected? The coordinator selects a victim and notifies all processes

CS3775 Centralized approach deadlock detection  False cycles may exist in the constructed global wait-for graph (because messages arrive in some order and delays contribute to edges added that form cycles; if a remove edge message arrives after another add edge message)  There is a centralized deadlock detection algorithm based on Option 3 that guarantees that it detects all deadlocks and no false deadlocks are detected.

CS3776 Centralized deadlock detection algorithm  Wait-for graph is built whenever the coordinator needs to invoke the cycle-detection algorithm.  Also 1. When Pi at site A requests a resource from Pj, at site B, a Request message is sent together with the TS. 2. The edge Pi->Pj is inserted in the local wait-for graph of A. 3. This edge is inserted in the local wait-for graph of B only if B cannot grant the requested resource immediately. TS is associated with the link. 4. Local edges do not have TSs associated.

CS3777 Cycle detection phase 1.The coordinator sends message to each site. 2.Each site responds with its local wait-for graph. 3.The coordinator builds global wait-for as follows:  Graph will contain a vertex per every process  Graph will have edge Pi->Pj if and only if:  Pi->Pj is a local edge in one of the local graphs, or  Pi->Pj has a TS associated and appears in more than 2 local graphs. 4.Cycle means deadlock, no cycle means no deadlock state in this graph.

CS3778 Fully distributed approach- deadlock detection  Each site is taking part in the deadlock detection process.  Every site constructs a special augmented local wait-for graph that characterizes the dynamic behavior of the system.  Deadlock means that there is a cycle at least at one of the sites.

CS3779 Building the special local wait- for graphs  We add one additional node, Pex, to the local wait- for graphs.  We add edges: Pi->Pex if Pi is waiting on a resource held by any process in a different site. Pex->Pj if there is a process in a remote site that waits on Pj.  Detection idea: if there is a cycle without Pex then it is a deadlock state; if Pex is involved then it is possibly a deadlock.

CS37710 Augmented local wait-for graphs P5P3 P1P2 P3 P2 P4 Site A Site B Pex P3 is waiting for a resource hold by P4, therefore P3->Pex Pex->P2 is added as P4 waits on P2 at site B

CS37711 Detection  If at site Si there is a cycle Pex->…Pk->Pex then: Assuming Pk is waiting on a resource from site Sj Si sends message to Sj, Sj’s local graph is updated, a cycle without Pex is searched for in Sj. If there is a cycle then the algorithm terminates, deadlock is detected. If there is a cycle involving Pex then a message is sent similar to above. The algorithm ends when all nodes have been updated and no local cycle not involving Pex is found or when a deadlock is detected.

CS37712 Detection - example P3 P2 P4 Site B Pex Edge P2->P3 is added, due to message from Site A Deadlock detected: P2,P3,P4,P2

CS37713 Election algorithms  Many distributed algorithms are using a coordinator process, e.g. in: Enforcing mutual exclusion Maintaining the global wait-for graph Replacing a lost token  In case the coordinator process fails a new copy of the coordinator should be started.  Where? – decided with election algorithms.

CS37714 Election algorithms - assumptions  Every process has a priority number.  The coordinator is always the process with the largest priority number.  If the coordinator fails the algorithm must elect the process with the largest priority number.

CS37715 The Bully algorithm  Suppose Pi sends a message to the coordinator and that is not answered within time T. Pi assumes failure of coordinator.  Pi sends an election message to all processes with higher priorities.  If no response is received within time T, Pi assumes that all these processes have failed. Pi starts a copy of the coordinator.  If a response is received then Pi waits for time T’ to see if a process with a higher priority has been elected.

CS37716 The Bully algorithm, cont.  If no answer is received within T’ then the algorithm is restarted (as this may indicate that the process that sent the first reply has failed).  A process that is elected sends a message to all other processes.

CS37717 Summary  Deadlocks are primarily handled with detection in distributed systems.  The main problem is maintaining the wait-for graph.  Some of the distributed algorithms require the use of a coordinator.  In case of failure of the coordinator an election algorithm is run to restart a new copy on some site.