1 / 21

Fall 2012 CISG 5500 Advanced Operating Systems

Chapter 7 Distributed Deadlock Detection. Fall 2012 CISG 5500 Advanced Operating Systems. Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University. Assumptions: System has only reusable resources Only exclusive access to resources

jesus
Télécharger la présentation

Fall 2012 CISG 5500 Advanced Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 7 Distributed Deadlock Detection Fall 2012CISG 5500Advanced Operating Systems Donghyun (David) Kim Department of Mathematics and Computer ScienceNorth Carolina Central University Some slides are in courtesy of Dr. Erciyes, CSU San Marcos / Dr. Prabhakaran, UT-Dallas

  2. Assumptions: • System has only reusable resources • Only exclusive access to resources • Only one copy of each resource • States of a process: running or blocked • Running state: process has all the resources • Blocked state: waiting on one or more resource Distributed Deadlock Detection

  3. Resource Deadlocks • A process needs multiple resources for an activity • Deadlock occurs if each process in a set request resources held by another process in the same set, and it must receive all the requested resources to move further • Communication Deadlocks • Processes wait to communicate with other processes in a set • Each process in the set is waiting on another process’s message, and no process in the set initiates a message until it receives a message for which it is waiting Deadlocks

  4. Nodes in a graph are processes. • Edges of a graph imply the pending requests or assignment of resources. • Wait-for Graphs (WFG) • Resource-allocation graph • Transaction-wait-for Graphs (TWF): WFG in databases. • Deadlock: directed cycle in the graph. R1 P1 R2 P2 Graph Models

  5. Deadlock Prevention: difficult • Deadlock Avoidance: before allocation, check for possible deadlocks. • Difficult as it needs global state info in each site (that handles resources). • Deadlock Detection: Find cycles. Focus of discussion. • Deadlock detection algorithms must satisfy 2 conditions: • No undetected deadlocks. • No false deadlocks. Deadlock Handling Strategies

  6. Centralized Control • A control site constructs wait-for graphs (WFGs) and checks for directed cycles. • WFG can be maintained continuously (or) built on-demand by requesting WFGs from individual sites. • Distributed Control • WFG is spread over different sites. Any site can initiate the deadlock detection process. • Hierarchical Control • Sites are arranged in a hierarchy. • A site checks for cycles only in descendents. Distributed Deadlocks Control

  7. Ho-Ramamoorthy2-phase Algorithm • Each site maintains a status table of all processes initiated at that site • includes all resources locked & all resources being waited on. • two process may claim they locked the same resource. • Controller requests (periodically) the status table from each site. • Controller then constructs WFG from these tables, searches for cycle(s). • If no cycles, no deadlocks. • Otherwise, (cycle exists): request for state tables again. • Construct WFG based only on common transactions in the 2 consecutive tables. • If the same cycle is detected again, system is in deadlock. • Later proved: cycles in 2 consecutive reports need not result in a deadlock. Hence, this algorithm detects false deadlocks. Centralized Algorithms

  8. Ho-Ramamoorthy 1-phase Algorithm • Each site maintains 2 status tables • resource status table and process status table • Resource table: transactions that have locked or are waiting for resources stored at that site • Process table: resources locked by or waited on by transactions. • Controller periodically collects these tables from each site. • Constructs a WFG from transactions common to both the tables. • No cycle, no deadlocks. • A cycle means a deadlock. Centralized Algorithms

  9. All sites collectively cooperate to detect a cycle in the state graph that is likely to be distributed over several sites of the system. • Can be divided into four classes • Path-pushing • the wait-for dependency information of the global WFG is disseminated in the form of paths (i.e. a sequence of wait-for dependency edges). • Edge-chasing • special messages or probes circulated along edges of WFG. Deadlock exists if the probe is received back by the initiator. • Diffusion computation • queries on status sent to process in WFG. Each blocked node will reply any query. Deadlock if a node receive replies from all of its neighbors. • Global state detection • get a snapshot of the distributed system. Not discussed further in class. Distributed Algorithms

  10. A probe(i, j, k) belongs to a deadlock detection initiated for process Pi. This probe is sent by the home site of Pjto Pk. • This probe message is circulated via the edges of the TWF graph. Probe returning to Piimplies deadlock detection. probe(1,1,2) P2 P1 probe(1,7,1) Chandy-Misra-Haas’s Algorithm(Edge-Chasing Algorithm) probe(1,2,6) P7 P6 probe(1,6,7)

  11. Terms used: • Pjis dependent on Pkif a sequence of Pj, Pi,1, … , Pi,m, Pk exists such that each process except Pk in the sequence is blocked and each process except the first one(Pj), holds a resource for which the previous process in the sequence is waiting. • Pjis locally dependent on Pkif Pj is dependent on Pkand both the processes are at the same site. • Each process maintains an array dependenti: dependenti(j) is true only if Pi knows that Pjis dependent on it. (initially set to false for all i& j). P1is locally dependent on P2 P2 P1 Pj Pk Chandy-Misra-Haas’s Algorithm – cont’ Pj is dependent on Pk

  12. To determine if a blocked process is deadlock, the system executes the following algorithm: Sending the probe: if Piis locally dependent on itself then deadlock. else for all Pjand Pksuch that (a) Pi is locally dependent upon Pj, and (b) Pjis waiting on Pk, and (c) Pjand Pkare on different sites, send probe(i, j,k) to the home site of Pk. On receiving of the probe (i, j, k): if (d) Pkis blocked, and (e) dependentk(i) is false, and (f) Pkhas not replied to all requests of Pj, then begin dependentk(i):= true; if k= ithen Pkis deadlocked else for all Pm and Pn such that (a’) Pkis locally dependent upon Pm, and (b’) Pm is waiting on Pn, and (c’) Pm and Pn are on different sites, send probe(i, m, n) to the home site of Pn. end. Chandy-Misra-Haas’s Algorithm – cont’

  13. Performance: For a deadlock that spans mprocesses over nsites,m(n-1)/2 messages are needed. Size of the message 3 words. Delay in deadlock detection O(n). Chandy-Misra-Haas’s Algorithm – cont’

  14. P0 P2 P1 P3 probe(1,3,4) probe(1,7,1) P4 Chandy-Misra-Haas’s Algorithm: Example P7 P5 P6

  15. Deadlock detection computation is diffused through the WFG of the system. • A process can be either active or blocked (waiting for a resource). • A process determines if it is deadlocked by initiating a diffusion computation - by sending query messages to all the processes from whom it is waiting to receive a message (theses processes are called the dependent set of the process). • If an active process receives a query or reply message, it is discards it. When a blocked process Pkreceives a query (i, j, k) message, it takes the following actions: • If this is the first query received by Pkfor the deadlock detection initiated by Pi (called the engaging query), it propagates the query to all the processes in its dependent set and sets a local variable numk(i) to the number of query messages sent. • If this is not an engaging query, then Pkreturns a reply message to it immediately, provided Pkhas been continuously blocked since it received the corresponding engaging query. Otherwise discard it. • A local boolean variable waitk(i) at process Pk denotes the fact that it has been continuously blocked since it received the last engaging query from process Pi. When a blocked process Pk receive a reply (i, j, k) , it decrements numk(i) provided waitk(i) holds. A process sends a reply message in response to an engaging query only after it has received a reply to every query message it sent out for this engaging query (i.e. numk(i) = 0). Chandy et al.’s Diffusion Computation Algorithm

  16. Initiation by a blocked process Pi send query(i, i, j) to all processes Pi in the dependent set DSi of Pinum(i) := |DSi|; waiti(i) := true; • Blocked process Pkreceiving query(i, i, k) if this is engaging query for process Pk/* first query from Pi */ then send query(i, k, m) to all Pmin DSk;numk(i) := |DSk|; waitk(i) := true; else if waitk(i)then send a reply(i, k, j) to Pj. • Process Pkreceiving reply(i, j, k) if waitk(i) == true thennumk(i):= numk(i)- 1; if numk(i)= 0 then if i= kthen declare a deadlock. else send reply(i, k, m) to Pm, which sent the engaging query. Chandy et al.’s Diffusion Computation Algorithm – cont’

  17. reply(1,6,2) query P2 reply P1 P3 reply(1,1,7) query(1,3,4) query(1,7,1) Diffusion Algorithm - Example P4 P7 P5 P6

  18. AND Model • A process/transaction can simultaneously request for multiple resources. • Remains blocked until it is granted all of the requested resources. • Edge-chasing algorithm can be applied here. • OR Model • A process/transaction can simultaneously request for multiple resources. • Remains blocked till any one of the requested resource is granted. (after receiving one request, cancel the remaining requests and issue new requests) • Diffusion based algorithm can be applied here. AND vs. OR Request Models

  19. Follows Ho-Ramamoorthy’s 1-phase algorithm. More than 1 control site organized in hierarchical manner. • Each control site applies 1-phase algorithm to detect (intracluster) deadlocks. • Central site collects info from control sites, applies 1-phase algorithm to detect intracluster deadlocks. Control site Hierarchical Deadlock Detection Central Site Control site Control site

  20. Deadlock persistence • Average time a deadlock exists before it is resolved. • Implication of persistence • Resources unavailable for this period: affects utilization • Processes wait for this period unproductively: affects response time. • Deadlock resolution • Aborting at least one process/request involved in the deadlock. • Efficient resolution of deadlock requires knowledge of all processes and resources. • If every process detects a deadlock and tries to resolve it independently highly inefficient ! Several processes might be aborted. Persistence & Resolution

  21. Priorities for processes/transactions can be useful for resolution. • Consider priorities introduced in Obermarck’s algorithm. • Highest priority process initiates and detects deadlock (initiations by lower priority ones are suppressed). • When deadlock is detected, lowest priority process(es) can be aborted to resolve the deadlock. • After identifying the processes/requests to be aborted, • All resources held by the victims must be released. State of released resources restored to previous states. Released resources granted to deadlocked processes. • All deadlock detection information concerning the victims must be removed at all the sites. Deadlock Resolution

More Related