Distributed Deadlock Detection
Distributed Deadlock Detection
Introduction:
A process may request resources in any order, which may not be known a priori
and a process can request resource while holding others.
A deadlock is a state where a set of processes request resources that are held by
other processes in the set.
The processors do not share a common global memory and communicate solely
by passing messages over the communication network.
The communication medium may deliver messages out of order, messages may
be lost garbled or duplicated due to timeout and retransmission, processors may
fail and communication links may go down.
In the running state (also called active state), a process has all the needed
resources and is either executing or is ready for execution.
Wait-For-Graph:
The state of the system can be modeled by directed graph, called a wait for
graph(WFG).
In a WFG , nodes are processes and there is a directed edge from node P1 to
mode P2 if P1 is blocked and is waiting for P2 to release some resource.
A system is deadlocked if and only if there exists a directed cycle or knot in the
WFG
deadlock prevention,
deadlock detection.
• A method that might work is to order the resources and require processes to
acquire them in strictly increasing order. This approach means that a process can
never hold a high resource and ask for a low one, thus making cycles impossible.
• With global timing and transactions in distributed systems, two other methods
are possible ‐‐ both based on the idea of assigning each transaction a global
timestamp at the moment it starts.
• When one process is about to block waiting for a resource that another process
is using, a check is made to see which has a larger timestamp.
• We can then allow the wait only if the waiting process has a lower timestamp.
– they have run longer so the system have larger investment on these processes.
– they are likely to hold more resources.
– A young process that is killed off will eventually age until it is the oldest one in
the system, and that eliminates starvation.
Maintenance of the WFG and Searching of the WFG for the presence of cycles(or
knots).
Correctness Criteria:
The resources of this process (or processes) are then released and may be
acquired by other processes.
– Each machine maintains the resource graph for its own processes and
resources
. – A centralized coordinator maintain the resource graph for the entire
system
– When the coordinator detect a cycle, it kills off one process to break the
deadlock.
– In updating the coordinator’s graph, messages have to be passed.
• Method 1) Whenever an arc is added or deleted from the resource
graph, a message have to be sent to the coordinator.
• Method 2) Periodically, every process can send a list of arcs added and
deleted since previous update.
• Method 3) Coordinator ask for information when it needs it.
False Deadlocks:
Edge‐Chasing Algorithm
• Chandy‐Misra‐Haas’s Algorithm:
– A probe(i, j, k) is used by a deadlock detection process Pi. This
probe is sent by the home site of Pj to Pk.
– This probe message is circulated via the edges of the graph. Probe
returning to Pi implies deadlock detection.
– Terms used:
• Pj is dependent on Pk, if a sequence of Pj, Pi1,.., Pim, Pk exists.
• Pj is locally dependent on Pk, if above condition + Pj,Pk on
same site.
• Each process maintains an array dependenti: dependenti(j) is
true if Pi knows that Pj is dependent on it. (initially set to false
for all i & j).
Chandy‐Misra‐Haas’s Algorithm
Sending the probe:
if Pi is locally dependent on itself then deadlock.
else for all Pj and Pk such that
(a) Pi is locally dependent upon Pj, and
(b) Pj is waiting on Pk, and
(c ) Pj and Pk are on different sites, send probe(i,j,k) to the home
site of Pk.
Receiving the probe:
if (d) Pk is blocked, and
(e) dependentk(i) is false, and
(f) Pk has not replied to all requests of Pj,
then begin
dependentk(i) := true;
if k = i then Pi is deadlocked
else ...
Receiving the probe:
…….
else for all Pm and Pn such that
(a’) Pk is 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.
Performance:
For a deadlock that spans m processes over n sites, m(n-1)/2 messages
are needed.
Size of the message 3 words.
Delay in deadlock detection O(n).
Chandy‐Misra‐Haas Algorithm
Hierarchical:
The sites (nodes) are logically connected in a hierarchical structure (such as
a tree).
A site can detect deadlock in its descendants.
This type of algorithm has the best of both the centralized and the
distributed deadlock detection algorithms.
For efficiency purposes, it is best to keep clusters of interacting processes
together in the hierarchy.
• 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.
Menasce and Muntz Hirarchical deadlock dectection: