IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. SE-13, NO. 1, JANUARY 1987
Local Distributed Deadlock Detection by Cycle
Detection and Clusterng
ISRAEL CIDON, MEMBER, IEEE, JEFFREY M. JAFFE, MEMBER, IEEE, AND MOSHE SIDI, MEMBER, IEEE
Abstract-A distributed algorithm for the detection of deadlocks in
store-and-forward communication networks is presented. At first, we
focus on a static environment and develop an efficient knot detection
algorithm for general graphs. The knot detection algorithm uses at most
O(n2 + m) messages and O(log (n)) bits of memory to detect all dead-
locked nodes in the static network. Using the knot detection algorithm
as a building block, a deadlock detection algorithm in a dynamic en-
vironment is developed. This algorithm has the following properties:
It detects all the nodes which cause the deadlock. The algorithm is
triggered only when there is a potential for deadlock and only those
nodes which are potentially deadlocked perform the algorithm. The
algorithm does not affect other processes at the nodes.
Index Terms-Clustering, computer networks, cycle detection,
deadlock detection, distributed algorithms.
I. INTRODUCTION
EADLOCKS in computer systems and transaction
systems
have been extensively. studied in the litera-
ture [1]. Various schemes to prevent the occurrence of
deadlocks have been presented [2], [3]. Distributed dead-
lock detection algorithms for detecting resource dead-
locks in computer systems have been suggested [4]-[6].
Distributed algorithms for detection [7]-[9] and resolu-
tion [7], [9] of buffer deadlocks have been described.
In a network without deadlock prevention, having a dis-
tributed deadlock detection algorithm is invaluable. De-
tection of deadlocks could be a key to notifying a "help-
desk," that manual intervention is necessary. If one also
has a distributed deadlock resolution scheme [7], [9], then
deadlock detection is the first step towards starting such a
scheme. Finally, in a network in ,which throwing away
messages is an acceptable resolution of a "bad situa-
tion," deadlock detection is a catalyst for determining
when and where messages should be discarded.
Various properties are desirable in distributed deadlock
Manuscript received January 31, 1986; revised June 16, 1986.
I. Cidon was with the Department of Electrical Engineering, Tech-
nion-Israel Institute of Technology, Haifa, 32000, Israel. He is now with
the IBM Thomas J. Watson Research Center, Yorktown Heights, NY
10598.
J. M. Jaffe is with the IBM Thomas J. Watson Research Center, York-
town Heights, NY 10598. Most of this work was performed while he was
on leave to the IBM Scientific Center, Technion City, Haifa 32000, Israel.
M. Sidi is with IBM Thomas J. Watson Research Center, Yorktown
Heights, NY 10598, on leave from the Department of Electrical Engineer-
ing, Technion-Israel Institute of Technology, Haifa 32000, Israel.
IEEE Log Number 8611357.
detection algorithms. When the algorithm is to detect
buffer deadlocks, then it should use only a small (prefer-
ably fixed) portion of the nodal storage [8], [9]. Algo-
rithms that accumulate a large amount of information,
such as the "wait-for graph" [7], would have insufficient
storage in practice. Preferably, deadlock detection algo-
rithms should be local, so that if a potential deadlock oc-
curs in a portion of the network, nodes in remote portions
do not ever find out that deadlock detection algorithm is
in progress [8]. By contrast, the algorithm in [9] is global,
as all nodes of the network are involved in the detection
algorithm.
In addition, the detection algorithm should be efficient
and should limit the amount of control messages trans-
mitted during its execution. The algorithm should be
started only when necessary, should find all deadlocked
nodes in the network, and should not interfere with the
normal operation of the network.
In this paper we present a new distributed deadlock de-
tection algorithm with all the above properties. Our ap-
proach is to describe the algorithm as it applies to com-
puter networks. However, with slight modifications this
algorithm can be applied to transaction systems too.
The algorithm that we present, uses only O(log (n)) bits
of memory per node, is local, is started only upon events
that may lead to deadlock, and does not interfere the nor-
mal operation of the network. In a static network with n'
potentially deadlocked nodes and m' links that are at-
tached to such nodes, the number of control messages
transmitted for detecting all the deadlocked nodes is O(n'2
+ in) in the worst case, better than the previously known
deadlock detection algorithms.
A main feature of our algorithm is that it finds out all
deadlocked nodes in a single invocation of the algorithm,
as opposed to the "search" type algorithms [5], [6], [8],
[11], [12] in which each node starts an independent in-
vocation of the search to find if it is deadlocked. Here we
use a new approach to deadlock detection using cycle de-
tection and clustering techniques which are similar to [13],
[14].
II. THE MODEL
We adopt here the model in [8], [9], [15]. For com-
pleteness we give a concise description.
0098-5589/87/0100-0003$01.00
©
1987 IEEE
3