Distributed Deadlock Detection ============================== Def: A deadlock occurs when a set of processes in a system is blocked waiting on "requirements" that can never be satisfied. reusabel vs consumable exclusive vs shared Resource Model -------------- i) reusable resource ii) exclusive access iii) one copy of each resource Def: Resource Graph A bipartite directed graph (N,E), where N = P U R P = {p_1, ... p_n} R = {r_1, ... r_n} (r_1, ... r_n) available unit vectors An edge (p_i, r_j) a request edge An edge (r_i, p_j) an allocation edge Def: Wait for graph (WFG) -Nodes : process -directed edge from P_1 -> P_2 if P_1 is blocked waiting for P_2 to release a resource. (P,E) an edge from process P_i to process P_j iff P_i needs a resource currently hold by P_j Request Model ------------- i) single-unit request model : cycle in WFG ii) AND request model : simultaneous requests - blocked until all of them granted - cycle in WFG - a process can be in more than one cycle iii) OR request model : any one e.g. reading a replicated data object - a cycle in WFG not a sufficient cond (but necessary) - a knot in WFG is a sufficient cond (but not necessary) Def: A node y is reachable from a node X, X -> Y, if there is a path (i.e. a sequence of directed edges) from node X to node Y. Def: A cycle in a graph is a path that starts and ends on the same node. If a nodes in C lies a cycle, then for all X in C : X -> X Def: A knot K in a graph is a non empty set of nodes s.t. for every X in K, all nodes in K and only the nodes in K are reachable from X. (for all X for all Y in K, X -> Y) and (for all X in K, there exists Z s.t. X -> Z implies Z is in K) Def: A state is an expedient state if all process having outstanding requests are blocked. Thm: In a general resource graph, i) A cycle is a necessary condition for a deadlock ii) If the graph is expedient, then a knot is a sufficient condition for a deadlock Deadlock i) detection (& recovery) ii) prevention iii) avoidance - not practical Difficulties -resource allocation information is distributed -gathering information requires msgs. since msgs have non-zero delays, it is difficult to have an accurate and current view of resource allocation. Centralized Deadlock Detection Fig 3-23 (a)(b)(c) An Edge-Chasing Algorithm for the AND graph p.161. 162 (Fig 7.1) A Diffusion Computation Based Algorithm p.164 An Edge-Chasing Algorithm 1) probe (i,j,k) sent by P_j to P_k on behalf of P_i 2) P_j depends on P_k if P_j -> P_i1 -> ... -> P_im -> P_k P_j, P_i1, ... P_im are blocked waiting resources 3) P_j locally dependent on P_k if P_j depends on P_k and both are on the same site. 4) for each process P_i, dependent_i(j) = true if P_i knows that P_j depends on it Initially dependent_i(j) = false for all i,j The Algorithm p.161 Example Fig 7.1 To detect a deadlock involving m processes that spans over n sites, at most a ( m * ( n - 1 ) ) / 2 msgs The delay in detecting the deadlock is O(n)