Rochester Institute of Technology
RIT Scholar Works
Theses
Thesis/Dissertation Collections
1991
A Survey and analysis of algorithms for the
detection of termination in a distributed system
Lois Rixner
Follow this and additional works at:
http://scholarworks.rit.edu/theses
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact
Recommended Citation
Approved by:
Rochester Institute of Technology
Computer Science Department
A Survey
and
Analysis of Algorithms
for the
Detection of Termination
rna
Distributed System
by
Lois
R.
Romer
A thesis, submitted to
The Faculty of the Computer Science Department,
in partial fulfillment of the requirements for the degree of
Master of Science in Computer Science.
Dr. Andrew Kitchen
Dr. James Heliotis
Dr. Peter Anderson
"22
Jit~
1/
Title of Thesis:
A Survey and Analysis of Algorithms for the Detection of
Termination
in
a Distributed System
I,
Lois
R.
Rixner
hereby deny permission to the Wallace
Memorial Library, of RITj to reproduce my thesis
in
whole or
in
part.
Abstract
-This
paper
looks
at algorithmsfor
the
detection
oftermination
in
adistributed
system and analyzes
them
for
effectiveness and efficiency.A
survey
is
done
ofthe
published
algorithmsfor distributed
termination
and eachis
evaluated.Both
centralizeddis
tributed
systems andfully
distributed
systems are reviewed.The
algorithms are analyzedfor
the
overhead and conclusions are made aboutthe
situationsin
whichthey
canbe
used,
i.e.
anoperating system,
areal-timesystem,
or a user application.An
original algorithmis
presented
for
the
asynchronous case withfirst-in-first-out
message ordering.It
allowsany
TABLE
OF
CONTENTS
1.
Introduction
1
1.1.
Purpose
1
1.2.
Definitions
2
1.3.
Approach
4
1.4.
Correctness
of aSolution
7
1.5.
Properties
of anAsynchronous
Solution
8
1.6.
Underlying
Computation
9
1.7.
Tools
for Distributed Algorithms
10
1.8.
Network Definitions
13
1.9.
Assumptions
14
1.10.
Restrictions
14
1.11.
Formal Definition
ofTermination
15
1.12. Phases
ofTermination Problem
15
1.13. Computation
ofOverhead
16
1.14. Perspectives
17
1.15.
Historical Perspectives
17
1.16.
Summary
21
2.
Synchronous
Centralized Solutions
22
2.1.
Introduction
22
2.2.
Issues
22
2.3.
Assumptions
23
2.4.
Solutions
Using
aTree
Topology
23
2.5.
Solutions
Using
aHamiltonian
Cycle
32
2.6.
Summary
36
3.
Synchronous Distributed Solutions
38
3.1.
Assumptions
38
3.2.
Issues
38
3.3.
Solution
Using
Tokens
40
3.4.
Solutions
Using
aLogical
Clock
42
3.5.
Summary
45
4.
Asynchronous Centralized Solutions
47
4.1.
Assumptions
47
4.2.
Issues
47
4.3.
Overview
51
4.4.1.
Control
Messages Used in
the
Algorithm
52
4.4.2.
Overhead for
the
Algorithm
54
4.5.
Chandrasekaran's Dual Approach
to
the
Problem
55
4.6.
Rozoy's Algorithm
57
4.6.1.
Boundaries
onthe
Number
ofControl Messages
59
4.7.
Dijkstra's
Solution
to the
Problem
59
4.8.
Arora's
Solution
Using
aBidirectional
Ring
61
4.9.
Summary
63
5.
Asynchronous
Distributed Solutions
66
5.1.
Assumptions
66
5.2.
Approaches
66
5.3.
Solutions
for
aHamiltonian Cycle
Topology
68
5.3.1.
Arora's Solution
to the
Problem
68
5.3.1.1.
Solution Two
70
5.3.1.2.
Solution Three
72
5.3.2.
Haldar's
Solution
to the
Problem
76
5.4.
Solutions
for
anArbitrary
Network
Topology
78
5.4.1.
Misra's Solution
to
the
Problem
78
5.4.2.
Skyum's Solution
to the
Problem
82
5.4.3.
Huang's
Solution
to the
Problem
84
5.4.4.
Eriksen's Solution
to the
Problem
87
5.5.
Solution
for
anApplication
whichRequires
Synchroneity
88
5.6.
Summary
90
6.
Solutions
for
Unreliable Channels
94
6.1.
Dijkstra's Solution
to the
Problem
95
6.1.1.
Definitions
for
Dijkstra's Solution
95
6.1.2.
Approach
95
6.1.3.
Advantages
98
6.2.
Kumar's Solution
98
6.3.1.
The Four Counter Method
105
6.3.2.
The Sceptic
Algorithm
106
6.3.3.
A Time
Algorithm
107
6.3.4.
Vector Counters
108
6.3.5.
Channel
Counting
109
6.4.
Summary
110
7.
A
New
Algorithm
112
8.
Conclusions
120
8.1.
Synchronous
Communication
122
8.2.
Asynchronous Communication
124
8.2.1.
FIFO
Ordering
for
Messages
124
8.2.2.
Non-FD?0
Ordering
for
Messages
128
8.3.
Summary
131
1.
INTRODUCTION
The
detection
oftermination
for
a sequential programis
trivial.
The
processknows its
own state and
it
may terminate
whenits
task
is
complete.The
detection
oftermination
is
also
easy
for
concurrent processesexecuting
on one machine andsharing
memory.The
information
requiredto
allowthe
processesto
decide if
they
canterminate
canbe
stored atsome shared
memory
location.
However,
when several sequential processes must worktogether
in
adistributed
system,
sharedmemory
is
non-existent and other methods ofdetection
oftermination
mustbe found.
The
problem arisesbecause
a processis
awareonly
ofits
ownlocal
state andis
not aware ofthe
states of other processes atthat
sameinstant in
time.
Francez
[FRAN80]
callsthe
problem ofdesigning
control communicationto
detect
termination,
andsuperimposing
it
on anapplication, the
distributed
termination
problem.
The
more abstract and generalterm
global quiescenceis
sometimes usedto
represent
the
situation where an applicationis
globally
deadlocked
andit is
merely
amatter of
interpretation
asto
whetherthe
systemis deadlocked
orterminated.
Chandy
and
Misra
[CHAN86]
andShavit
andFrancez
[FRAN86]
introduced
this term.
1.1.
Purpose
The
purpose ofthis
paperis
to survey the
literature
for
termination
algorithmsbegin
ning
withFrancez
[FRAN80]
andto
analyzethem
for
appropriateness and correctness.As
each algorithm
is
considered,
this
paper will considerthe efficiency
ofthe
algorithmin
solving
the
problem.We
will alsolook
atany
peculiarities ofthe
solutionsthat
illustrate
the
problems
that
mustbe
solvedin
orderto
create a correct solutionto the
distributed
termi
nation problem.
Even incorrect
algorithms canbe
usefulin
illustrating
conditionsthat
In addition,
this
author will propose an algorithmfor
anasynchronous,
distributed
system with
first-in-first-out
messageordering that
does
not require clocks.1.2.
Definitions
Francez
[FRAN80]
identifies
two
different
classes oftermination
problem.Endoter-minating
processesmay terminate
onreaching
somefinal
statedetermined
only
by
the
ful
fillment
of a condition.For
example asequential process mightterminate
afterexecuting
aspecific number of
statements,
or whenthe
exit procedureis
called.On
the
otherhand
exoterminating
processes arethose that
depend
on other processesin
the group
for
infor
mation
to
do
their
own computation.The
set of allprocesses on which a processdepends
is
called
its
termination
dependency
set(TDS).
An
exoterminating
processmay
notter
minate until all processes within
its TDS
areready to
terminate,
i.e.
have finished
all oftheir
work.Processes
working together to
solve a problemin
adistributed
system are exoterminating.
Therefore it
willbe
necessary that
no process withinthe group terminates
before
all processes areready to terminate.
In
the
context ofdistributed
systems,
severalterms
shouldbe
understood atthe
outset.
All
processesrunning
in
parallel andworking together to
find
asolutionfor
a computation
P,
are calledcommunicating
sequential processes.By
definition
they
have
noshared
memory
andthey
shareinformation
only
by
sending
andreceiving
messages.For
the
sake ofconsistency, the
computation will alwaysbe
referredto
asP
andthe
processes which
do
the
work ofthe
computation willbe
referredto
as p,.This
authorassumes
that
P
andp,-contain
both
the
application andthe
superimposed control codeused
by
the
detection
algorithm.The
number of processesin
the
system will alwaysbe
A
computationis
ready
to
terminate
if it
meetsits
Global
Terminating
Condition
(GTC).
The GTC
refersto
the
terminating
conditionfor
the
computation as a whole.For
consistency's
sake, I
will namethe
boolean
predicate, representing
the
GTC,
B
throughout
this
paper.Each
p,
ofthe
computation willhave
alocal
predicate,
always named6,,
whichwill represent some
local boolean
conditionfor
termination.
If
eachp,-was
running
onits
own,
this
boolean
condition,
6,-,
wouldbe
sufficientfor
termination.
However,
sincethe
p,-are
running
together,
the
conjunction of allthe
6,'s
is
necessary to
meetB.
Once B
has
been
met,
it
cannot change-it is
monotonic.
The
processesp,-exchange communications of
two
different
types:
basic
communication
and control communication.Basic
communication,
be,
refersto any
exchange of messages relative
to the
computation.Control
communication, cc,
refersto the
exchange ofmessages relative
to the termination
algorithm.In
the
singleprocessor,
concurrentenvironment,
a processis
saidto
be
activeif it is
executing
its
text
and passiveif it is blocked.
In
the
distributed
environmentthis
is
notthe
case.A
processis
considered activeif its local
predicate6,
is
not met.This
couldmean
the
processis
actively executing
its
text
orwaiting
for
abe. A
processis
consideredpassive
only
if its local
predicate6,
has
been
met.If
a processis
passiveit
may
send/receivecc;
it
may
also receivebe
althoughit may
not
initiate
(send)
be.
Upon
receipt of abe,
a passive processimmediately
becomes
active(and
its
6,
becomes false).
Notice
that the
6,
are not monotonic.If
a processis
activeit
may
send and receivebe. It
may
become
passive atany
time,
if its
local
predicate6,
becomes
true.
Active
processesmay
ormay
notbe
ableto
The
abovedefinitions
describe
atransaction
oriented model ofdistributed
computation.
All
ofthe
algorithms presented assume atransaction
oriented model exceptthose
presented
by
Mattern
[MAT87B].
Mattern
assumes an atomic model ofdistributed
computation.In
the
atomic modelall
local
actions are performedin
zerotime
andtherefore
there
is
no needfor
the two
states passive and active
-no messages are received unless a process
is
passive.A
processmay
atany time take any
messagefrom
one ofits
incoming
communicationchannels,
immediately
changeits internal
state and atthe
sameinstant
sendoutany
number of messages,
possibly
none at all.For
convenienceMattern
assumesthat
all atomic actions aretotally
globally
ordered.If
every
local
computationinitiated
by
the
receipt of a messageterminates,
the transaction
oriented modelis
equivalentto the
atomic model ofdistributed
computation.
For
Mattern,
the
advantage ofthe
atomic modelis
that there
is
no concurrent
activity
of processes.He
believes
this
giveshim
abetter
insight
into
the
problemof
distributed
termination.
1.3.
Approach
This
authorbelieves
that
the
algorithms canbe best
understoodby
grouping them.
Initially
many
restrictions are put onthe
communication channels which makedeveloping
and
understanding
algorithms easier.In
addition,
communicationmay
block
a process1
2
(synchronous)
or allowthe
processto
continueto
execute(asynchronous).
Furthermore,
initial
efforts allowed one processto
controlthe
system and are referredto
as centralized.Centralized
solutionshave
the inherent
property that the
control code containedin
each1 The
senderdoes
notsendthe
message untilthe
receiveris
ready
toreceive.process cannot
be
the
same.The
centralized solutionsto the
distributed
termination
problem make use of a singleprocess,
the
detector,
to
detect
termination.
The detector initiates
the
detection
algorithmand
is
the only
process with sufficientinformation
to
determine
if termination has
actually
occurred.
The
messagesthe
detector
sends out are called probes.Chandy
andLamport
[CHAN85]
introduced
the term
distributed
snapshotto
referto the
methodby
whichprocesses record
their
own states andthe
states of communicationchannels sothat the
setof process and channel states recorded
form
aglobal system state.The
earliest centralized algorithms usedthe
CSP
notationdescribed
by
Hoare
[HOAR78]
to
pseudo-codetheir
algorithms.These
algorithms areespecially
vulnerableto
deadlock due
to
Hoare's
definition for
communication.The
author assumesthe
readerhas
a
basic knowledge
ofCSP;
however
afew
points are ofspecialinterest.
It is important
to
remember
that the
communicationis
synchronizedin CSP.
In
additionthere
is
nobuffer
ing;
therefore,
if
processp,-wishes
to
sendto
processpy,
p,-must wait until
pj
is
ready to
receive
from
p,-.When
both
the
sender andthe
receiver arewaiting
for
eachother, the two
processes are said
to
correspond and a simultaneous communication occurs.This property
of
CSP
canlead
to
deadlock
if
there
is insufficient
nondeterminismin
the
control code.If
two
processes are eachwaiting
for
input
from
the other,
deadlock
couldeasily
occur.An
unusually
large
number of messages willincrease
the
possibilitiesfor deadlock.
The CSP
requirement of simultaneous communication
led
to the
description
ofthese
algorithms assynchronous.
Francez distinguishes between
"the
instance
at which communicationis
enabled andis
acommunication
"which,
onceenabled,
preventsany
otheractivity
untilit
occurs(even
if
there
are alternative enabled communications)"[FRAN82,289].
An
indulgent
communication
is
a communication which occursonly
whenever a processis
notdoing
anything else,
i.e.,
"the
enabling
of acommunication
is
intentionally
separatedfrom
its
actualoccurrence"
[FRAN82,289].
The
earliest algorithm presentedby
Francez
[FRAN80]
usesinsistant
communication-once
the
cc areenabled,
nobe
may
occur untilthe
ccoccurs,
i.e.,
the
underlying
computationis
frozen.
In
his later
algorithm[FRAN82],
Francez
usesindulgent communication,
i.e.,
although a ccmay
be
enabled,
alternativebe
may
occur,
and
the
basic
computationis
notfrozen.
Later
efforts werefully
distributed
in
an attemptto
makethe
systems morefault
tolerant.
The
fully
distributed
solutionsto the
distributed
termination
problem make useof symmetric code -
the
code
for
the
control algorithmis
the
same on all processors.In
addition,
adistributed
solution allowsany
nodeto
initiate termination
detection
andany
node,
notnecessarily the
initiator,
to actually
detect
termination.
The
reader shouldbe
awarethat
solutions are classified as centralized ordistributed
based
onthe
mechanism usedto
detect
termination.
This
meansthat
a either a centralized
or adistributed
termination
algorithm canbe built
on adistributed
application.The
key
issue
is
that,
in
centralizedsolutions, the
initiator
is
determined before
the
applicationbegins
execution and can not change.In
the
fully
distributed
solutionsthe
initiator
is
determined
during
execution ofthe
application.Either
all ofthe
processes cantake
turns
being
the initiator
or all ofthe
processesmay
have
the capability to
be
the
initiator
atany
time
(or
eventhe
sametime) during
the
execution ofthe
application.instantaneous
communicationis
defined
as when a send/receiveoccurs, the
messageis
atthe
sender or atthe
receiver-not on
the
communicationline
itself.
As
knowledge
ofthe
distributed
termination
problemgrew, the
researchers realizedthat
an algorithm couldbest be
developed
through the
use ofinvariants.
An invariant is
acondition which must
hold
true
at alltimes
during
the
solution of a problem.The
use ofinvariants
has
the
advantage ofmaking it
easierto
provethe
algorithms correct.There
are several other conditionsto
be
consideredwhich arebeyond
the
scopeofthis
paper.
This
paper will consideronly
staticdistributed
systems -the
process set
is
fixed for
the
lifetime
ofthe
system.But it is
alsonecessary to
find
efficient and correct algorithmsfor dynamic
distributed
systems - processes canbe
created and/ordestroyed
during
the
lifetime
ofthe
system.The
entireissue
offaulty
processors willbe
avoided -techniques
for
discovering
that
a processoris
faulty
andfor
correcting the
results ofits
behavior
needto
be developed
and appliedto the
distributed
termination
problembut
will notbe
discussed
here.
Also
the
effects of messageloss due
to
afaulty
channel will notbe
explored,
although
the
literature indicates
that termination
cannotbe
verifiedif
messages arelost.
1.4.
Correctness
ofaSolution
In
orderfor
adistributed
termination
algorithmto
be
correct, the
algorithm mustbe
guaranteed not
to
cause afalse
termination.
False
termination
is
the
term
used whenthe
control code
declares
atermination
whichhas
notactually
occurred-some process
is
stillactive.
Any
correcttermination
algorithm willhave
to
be
ableto
detect
all possible casesof
behind
the
back
communicationin
orderto
preventfalse
termination.
Behind
the
back
communication can occur whenever
the
detector has
visited aprocess,
finds
it passive,
anddetector
may
send messagesto
any
processin
the
system-including
processesalready
visited and assumed passive
by
the
detector
-and cause
them
to
become
active.If
adetector does
notlearn
ofthis
behind
the
back
communication,
afalse
termination
willbe
found.
Apt
andRichier
[APTR85,480]
suggestthe
following
criteria as a guideto
judging
if
asolution
to
the
distributed
termination
problemis
correct.Property
1:
Whenever
P properly
terminates,
then
all processes are passive.Property
2:
There
is
nodeadlock
in
P.
Property
3:
If
all processesbecome
passivethen eventually
P
willproperly
ter
minate.
Property
4:
If
not all processes are passivethen eventually
a statementfrom
the
original programwill
be
executed.These
properties areespecially
important
for
the
synchronous solutions.Because
ofthe
nature ofCSP it is
very easy to
write control code which willdeadlock
and violate property
2.
Property
1 is
really saying that
afalse
termination
will notbe
detected, i.e.,
allbehind
the
back
communication willbe
caught.Property
3
saysthat
if termination occurs,
it
willbe
detected.
Property
4
saysthat
if
termination
has
notoccurred, then the
basic
computationwill not
be
preventedfrom
executing.1.5.
Properties
of anAsynchronous Solution
Ferment
andRozoy
[FERM87]
introduce
adiscussion
ofthe
problemsinvolved in
asynchronous communication.
Most
ofthe
algorithmsfor
the
asynchronous caseto
be
can
test
for
the
emptiness ofits
buffers.
When
the
networkis
not alocal
one,
neither oneof
these
properties wouldhold
and otherinformation
wouldbe
needed.If
a process can neithertest
for
the
emptiness ofits
buffer
nor performinstantaneous
communication,
Ferment
andRozoy
suggestthat there
arethree
critical parameters.If
oneof
these
parameters canbe
metthen
finite
termination
algorithms canbe found for
the
system.
The
parameters are:1.
Transmission Order
-All
messages
that
have
the
samepriority
and are sent over3
the
same communication channelobey the
fifo
rule.2.
Priority
ofDetection Messages
-All
cc
have
alower
priority than
be.
3.
Communication
synchronicity
-There is
a uniform
bound
during
which messagesare
treated,
i.e.,
the
number of messages processedbefore
any
given messageis
received and processed
is
bounded.
This is
abound
onactions,
not ontime
andis
clearer withinRozoy's
definition
ofthe
distributed
system as afinite
statemachine.
All
ofthe
algorithms presentedin
chapters4
and5
assume eitherinstantaneous
communication or
the ability to test
for
anempty channel,
as well as afifo
ordering
of messages.
Chapter
6
willlook
at algorithmsthat
have
the ability to test
for
anempty
channel.1.6.
Underlying
Computation
Several
ofthe
algorithms assume adiffusing
computationfor
the underlying
computation.
A
diffusing
computationis
based
on adirected
graph,
in
which one ofthe
nodeshas
no
incoming
edges -this
nodeis
calledthe
environment;
all ofthe
other nodes are called3
The
orderingofthe
messagesis
First-In-First-Out.
the
'internal
nodes'.The
environmentmay
send amessageto
one or more ofits
successorsin the
graph.This
messageis
sentonly
once.The
internal
nodesmay
send messagesto
their
successorsonly
aftertheir
first
messagehas been
received.An
engaged nodeis
a node notin its
neutralstate,
i.e.,
it
has
received atleast
onemessage and
has
not returned signalsfor
every
message received.The
edgefrom
p,-to
p;-is
an engagement edgeif
py
is
a neutral node andp, is
the
first
process
to
sendpy
a message.1.7.
Tools
for Distributed
Algorithms
Raynal
[RAY88b]
suggeststhree
tools
which canbe
usedto
implement
fully
distri
buted
algorithms:1.
the
use of markers ortokens
2.
logical
clocks3.
sequence numbersfor
messages.Although
there
is
nodesignated
process asdetector,
when a marker ortoken
is used,
the
detection
oftermination
is
restrictedto the
process whichholds
the token.
The token
is
initially
placedby
the
compiler.In
effect, the only
processthat
caninitiate
a probeis
the
processholding
the token.
The
token
is
passedalong
untilthe
probeis
falsified
-i.e.,
anactive process
is
found.
A
new probeis
then
issued
by
the
processholding
the token
whenits
bf
becomes
true.
When
aprocess receivesthe token containing
its
own probeunfalsified,
then termination
is
detected.
There
are several ways ofguaranteeing that
this
willhappen;
5
p:may
gofrom
neutral to engaged andback
to neutral.When
py
goes neutralit has
noArora
andSharma
[AROR83]
offer one solution.Events occurring in
adistributed
system are sometimesdifficult
to
order.Lamport
[LAMP78,558]
discusses "the happened before
relation"and gives a
distributed
algorithmfor
extending
it
to
a consistenttotal ordering
of all ofthe
eventsin
the
system.The
resultof
this
algorithmis
the
concept of adistributed
logical
clock.Abstractly,
"a
clockis just
away
ofassigning
a numberto
anevent,
wherethe
numberis
thought
of asthe time
atwhich
the
eventoccurred"
[LAMP78,559].
A
clockfor
each processmay
be implemented
by
a counter whichis
used as atimestamp
for
events.The
clocksmay
be
synchronizedwithin
the
system whenever a messageis
sent.Each
message contains atimestamp.
The
receiving
processincrements its
clock(counter)
to
be
whicheveris
greater -its
own
time
(represented
by
its
counter)
orthe time
(represented
by
the
timestamp)
ofthe
message.This
method of synchronization can alsobe
used when real clocks are used.Since
notwo
clocks will run atexactly the
samerate,
they
willtend to
drift further
andfurther
apart.
A
resetting
of clocksthrough
comparison oftimes
whenever a messageis
receivedis
sufficient
to
orderthe
eventsin
a system.Apt
andRichier
[APTR85]
offer several solutions
for
virtual clocksderived
from
solutions which assume real clocks.The
third
tool,
sequence numbers on messageshas
none ofthe
problems ofthe
previous
tools.
With
the
use of sequencenumbers,
each process manages a counter.The
counter
is initialized
to
zero andincreases
monotonically.Whenever
amessageis
sentout,
the
current sequence numberis
incremented
andthe
new sequence numberis
attachedto
the
message.The
counter atthe
site of each processis
usedonly
for
messages whichit
sends.
have been
sent morerecently
by
comparing
the
current sequence number withthe
sequence number attached
to the
incoming
message.A
more recent cchas
notbeen
sentif
they
match.Processes receiving
amessagefrom
another process canverify that
it is
a new message(rather
than
aduplicate)
if
the
sequence numberis
not aduplicate
ofthe
sequence numberattached
to
other messages receivedfrom
that
process.If
sequence numbers areused, any
processmay
initiate
a probe atany time.
In
addition,
the
overhead oflogical
clocksis
non-existent.However,
as aresult,
it is
possiblethat
all processes
may
have
a probein
the
system atthe
sametime.
Some
method mustbe
used
to
eliminateunnecessary
probesto
reducethe
number of cc.None
ofthe
synchronous
distributed
solutions make use of sequencenumbers;
however,
we will seethem
in
Arora's
[AROR87]
asynchronous solution.Arora
andSharma
[AROR83]
offer a construct whichillustrates
how
6,-may
be
set.The
programmeris
giventwo
new statements: set and reset.Both
ofthese
statementstake
a variable number ofboolean
parameters.If
all ofthe
boolean
expressions ofthe
setstatement are
true,
the
processis
passive and6,
is
set equalto true.
If
all ofthe
boolean
expressions of
the
reset statement aretrue,
the
processis
active and6,
is
set equalto
false.
It
is
not clearif
the
assignmentto
6,
is implicit
to these
statements or mustbe done
explicitly
by
the
programmer.In
eithercase, the
programmeris
expectedto
addthese
statements
to
his
distributed
programin
the
appropriate places.1.8.
Network Definitions
A
spanning tree
contains allthe
nodesin
the
network and some collection of edges sothat there
is
exactly
one pathbetween
each pair ofnodes;
it is
inherently
acyclic.A Hamiltonian
ring
is
a cyclein
which each nodeis
visitedexactly
once.Thus
eachprocess
has
a successor onthe
cycleto
whichit
canforward
a message and a predecessorfrom
which a message canbe
received.A
Hamiltonian
ring
for
the
ccis
sometimes superimposed
onthe
system.Sometimes
the term
circulardirected
graphCDG is
usedinstead.
In
abroadcast
networkthere
is
a single communication channel sharedby
all ofthe
nodes
in
the
network.Inherent in
broadcast
systemsis
that
all messages sentby
any
nodeare received
by
all other nodes.Something
in
the
messageitself
mustspecify
for
whomit
is intended.
After
receiving
a message notintended
for
itself,
a nodejust ignores it.
In
this paper, the term arbitrary
network willbe
usedto
indicate
that the
networkstructure
is
not specified.Two
nodes are neighborsif
they
aredirectly
adjacent,
i.e.,
they
have
adirect
communication
line.
The diameter
of anetwork,
D,
is
the
greatestdistance
between
any two
nodesin
the
network and
the
distance
between
any two
nodesis
the
shortest pathbetween
them.
The
authors of
the
presenteddistributed
termination
algorithmsdo
notdefine
the
method usedfor
computing
the
distance between
two nodes;
however,
this
authorhas found
that the
number of
hops between
nodes covers most cases.When
computing the time
and messagecomplexities,
this
author usesthe
number ofhops.
In
aweakly
connected network withdirected
edges, there
exists acycle,
notneces-7
sarily
asimplecycle,
whichincludes
every
edge ofthe
network atleast
once.In
astrongly
connected network with
directed edges,
removalofany
one edgebetween
any
pair of nodesmaintains connectivity.
1.9.
Assumptions
There is
one assumption madefor
all ofthe
algorithms:The
underlying
computationP is
writtenin
such away that
it
will alwayseventually terminate
andtherefore,
eachp,-8
will also
terminate
-deadlock
will not occurin
the
computation
itself.
Initially,
the
algorithms we consider will assume
that
all channels ofthe
network are reliable:they
do
notalter
messages,
lose
them,
duplicate
them
ordesequence
them,
later
we will relaxthis
restriction
to
some extent.1.10.
Restrictions
Francez
suggeststhe
following
criteriafor
anideal
solutionfor
the
detection
oftermi
nation
in
P
[FRAN80,44]:
1.
The
required solutionis independent
ofthe
specific problemP is
trying
to
solve.2
The
control communicationis inserted into
the
solutionfor
P
withthe
smallestpossible additions
to the
basic
communication.3.
The
solutionis independent
ofthe
numberofprocesses,
n,
into
whichP is
broken
up.
4.
The
solutionis
independent
ofthe
specific neighborhood relationshipsholding
among the
p,'s.8
This
assumption mustbe
madebecause
whether or not a process will terminateis
5.
The
solutiondoes
not require new communicationchannels,
i.e.
the
cc usethe
same channels as
the
be.
1.11.
Formal Definition
ofTermination
We
can summarize ourdiscussion
asfollows.
The
applicationP
consists of agroup
ofcommunicating
sequentialprocesses, p,-,
i
=l...n,
which executein
parallelin
adistributed
environment.
Control
codeis
addedto the
p,-so
that termination may
be
detected.
These
processes communicate with each other
only through
exchange of messages.Each
processhas
alocal
predicate,
6,-,
i
l...n,
to
representits
local
conditionfor
termination.
When
the
conjunction of all ofthe
6,'s
is
true
atthe
sametime
instant,
the
globalpredicate,
B,
representing the
GTC is
alsotrue
and all ofthe
processesmay terminate.
Note,
distributed
termination
"is
actually
adeadlock
situation where all processes areready to
acceptbut
none
is
willing to
initiate
[FRAN82,288].
Therefore
the
control codeis
used
to
recognizethis
deadlock
situation as a readinessto terminate.
1.12.
Phases
ofthe Termination
Problem
The distributed
termination
problemmay
be broken
into
two
phases:the
detection
phase and
the termination
phase.The
termination
phaseis
trivial,
oncedetection has
occurred,
andis
notdealt
within
this
paper norin
the
majority
ofthe
literature.
Although,
strictly speaking, termination
occursonly
whenthe
termination
phaseis
complete, this
paper will callthe
deadlock
situation,
where all processes areready to
terminate,
termination.
9 After
B has been
met,
the termination phase consists of the explicit communication to1.13.
Computation
ofOverhead
Overhead
canbe
computedfor
the
termination
detection
algorithms with respectto
the
number of cc.When
computation ofthe
overhead requiresknowing
the total
numberof
be,
this
numberwillbe
representedby
m.There
aretwo
casesto
consider:1.
The
best
caseis
whenthe
initiator
ofthe
probeis
the
last
processto
meetits
&,-and
therefore,
asit
visits eachprocess,
p,-, the
detector finds
that
p,-has
also met
its bt.
2.
The
worst caseis
when each process sendsonly
onebe
(or
nobe)
before
meeting
its
b{.
Then
every
subsequentbe
is
sentto
aprocess, p,-,
whose 6,-has
already
been
met.When
p,-receives
the
be it
becomes
active again.The
overheadincludes
both
control messages neededto
enablethe
detection
oftermination
and controlmessages required
for
detecting
termination
afterit has
actually
occurred.The
actual overhead of each algorithm must alsotake
several otherthings
into
consideration.
The
mostimportant
ofthese
is
the
amount of additional code which mustbe
executed whenever a
be
is
performed.Also
ofimportance is
the
amount of extramemory
needed
for
each processto
implement
the
control code.In
afew
casesthe
size ofthe
detec
tion
message will alsobe
ofimportance.
In
most ofthe
algorithms presentedin
this
paperthe
size ofthe
message will remain constantindependent
ofthe
size ofthe
system.How
ever,
in
the
case where messages are not receivedin
the
ordersent, the
size ofthe
detec
tion
messagemay
be dependent
onthe
number of processesin
the
system[KUMA85]
[MAT87A]
[MAT87B].
The
algorithm presentedby
Rozoy
[ROZ086]
also uses a messagedependent
uponthe
size ofthe
network.dictate
that
no one algorithmis
the
best
solutionfor
all situations.For
example a realtime
system might require an algorithm whichis
fastest
most ofthe
time,
evenif it
uses alot
of memory.A
user application mightbe
concerned withthe
control algorithm's effecton
the
be
and anoperating
system might need an algorithm which usesthe
least
amountofmemory.
1.14.
Perspectives
In
this paper,
solutionsfor
whichthe
channelshave
the
most restrictions willbe
looked
atfirst.
Synchronous
communicationis
also more restrictive andtherefore
willbe
considered
first.
Synchronous
solutions canbe
either centralized orfully
distributed.
The
centralized solutions more
closely
resemble a single-processor system and are usefulto the
understanding
oftermination.
The
fully
distributed
synchronous solutions offer an opportunity
to
look
atthe
additionalissues involved
whenthe
control algorithmis distributed.
Yet,
the
environmentis
stillvery
much controlledthrough
the
synchronous communication.
Next
asynchrony
willbe
introduced.
Again
there
are several centralized solutions aswell as several
fully
distributed
solutions.Finally
some restrictions onthe
channels willbe
lifted,
e.g., the
order ofthe
messageswill not
be
requiredto
be first-in-first-out.
This
presents additional problemsin
the
asynchronous
environment,
but
cannothappen in
the
synchronous environment.Both
centralized
anddistributed
asynchronousdistributed
solutions willbe
considered when restrictions1.15.
Historical
Perspectives
Unfortunately,
from
anhistorical
perspectivethese
groupingsoverlap
and researchersborrowed ideas
from
each other.For example, in
a chapter whereonly
algorithmsusing
synchronous communication are
considered,
the
reader will noticethat
ideas
areincor
porated
that may
have been developed
by
another researcherfor
an algorithmusing
asynchronous communication
that
willbe introduced
in
alater
chapter.In
an attemptto
makethe
actualordering clearer,
a chronologicalhistory
is
givenhere.
The
earliest algorithms were writtenin 1980. Francez's
algorithm[FRAN80]
used synchronous communication and was
based
on aspanning tree model,
whichthe
programmerwas required
to
derive.
Dijkstra's
algorithm[DIJK80]
was alsobased
on aspanning tree
model;
however,
the
applicationitself
-a
diffusing
computation -built
the tree
andthe
communication was asynchronous.
Francez
providesfurther background information in his
article oninterval
assertions[FRAN81]
and animproved
version ofhis first
algorithm[FRAN82].
Misra
[MISR82]
then
merges
the
idea
of adiffusing
computation[DIJK80]
andFrancez's
use ofCSP
[FRAN80].
The
literature
of1983
presentsfour
algorithms.Arora
[AROR83]
andRana
[RANA83]
offer synchronousdistributed
solutions.Arora's
solution usestokens
and aring
network
topology.
Rana
uses clocks andhis
results areincorrect.
Dijkstra
[DIJK83]
offersa solution
that
usestokens
and aring
topology.
Since he does
notspecify
whatkind
ofcommunication
occurs, only that the
communicationfacility
exists, the
algorithm willbe
included
withthe
asynchronous centralized solutions.However,
the
importance
ofthis
algorithm
is
that
Dijkstra
alsointroduces
the
idea
ofusing
invariants
to
develop
the
algoapplies
this
idea
of coloredtokens to the
asynchronousdistributed
situation.In
1984,
Topor
[TOP084]
mergedthe
idea
ofa coloredtoken
[DIJK83]
withthat
of aspanning tree
[FRAN82].
1985
brought
a widevariety
of solutionsto the
problem.Apt
andRichier
[APTR85]
offered a
solution,
based
onthe
use ofclocks,
for
the
synchronousdistributed
casethat
uses a
ring topology.
Richier
[RICH85]
also offers avery
complicated solutionfor
the
samecase,
alsousing
a ring.There is
a minor errorin
this
algorithm: one ofthe
variables never"gets
set".It
does
not useclocks;
however,
aboolean
variable replacesthe
idea
of coloredtokens.
Szymanski
[SZYM85]
offers an algorithmfor
the
asynchronousdistributed
case.However,
it is
specificfor
his
application which mustbe
synchronized.Strictly
speaking,
he does
not solvethe
distributed
termination
problem asdefined
by
Francez
[FRAN80].
Finally
Kumar
[KUMA85]
offers several algorithmsfor
the
asynchronousdistributed
casewhich
lift
the
restriction ofmaintaining the ordering
of messagesin
the
send/receive process.
1986
brought
many
possiblesolutions;
however,
most ofthe
researchers presentedthem
in
conjunction with anidea
they
considered moreimportant,
i.e.
the
algorithms werean afterthought used
to
illustrate
their
point.Apt
[APT86]
offers a synchronous centralized
solutionfor
aring topology.
However,
his
real purposeis
to
introduce
correctnessproofs
for
termination
algorithmsthat
useCSP.
He
useshis
algorithmto
showhow
aproof
may
be
done.
Rozoy
[ROZ086]
offers an asynchronous centralized solutionbased
ona
finite
state machine model.However,
her
real pruposeis
to
introduce
atheorem
onthe
bounds
for
the
ccin
any
asynchronous algorithm.Skyum
[SKYU86]
introduces
an algonetwork.
However,
his
application also requiressynchrony
andFrancez's
termination
problem
is
not solved.Arora
[AROR86]
offers an asynchronousdistributed
algorithmbased
oninformation
aprocesshas
aboutits
neighbors.However,
it is incorrect
according
to
Tan
et al[TAN86].
In
1987,
wehave
severalincorrect
algorithms.Chandy
[CHAN87]
offers a mathematical proof
for
the
verification oftermination
detection.
He
assumesthe
existence of adistri
buted
snapshot and provesthat
tennination
has/has
not occurredbased
onthe
snapshot.Arora
[AROR87]
presents an algorithmfor
the
asynchronousdistributed
casethat
usessequence numbers and
the
distance function.
This
authorfinds
the
algorithmto
be
incorrect
due
to the
fact
that
it
does
nottake
into
consideration all ofthe
possibilitiesfor
behind
the
back
communication.Hazari
[HAZA87]
presents anincorrect
synchronousdis
tributed
solutionbecause
the
algorithmdoes
nottake
"into
accountthat
passive processesmay
be
reactivatedby
communicationsfrom
processesthat
are still[TEL87].
Fer
ment and
Rozoy
[FERM87]
presentideas
relativeto the
problems which mustbe
surmounted
in
the
asynchronous case.Mattern
[MAT87A]
[MAT87B]
presents several algorithms
in
the
Kumar
strainfor
the
asynchronousdistributed
case wherethe ordering
ofmessages
is
not maintained.1988
brings
several solutionsfor
the
asynchronous case.Arora
[AROR88]
offers a centralized
solutionfor
a ring.The
solutionis
quite complicateddue
to the
fact
that
he has
previously
presentedincorrect
solutions andbeen
called onit in
the
literature.
Haldar's
solution
[HALD88]
is
based
onArora's
[AROR87] [AROR83]
andis
simpler althoughit
uses
the
same concepts of adistance
function
and sequence numbers.Tel
andMattern
[TELM89]
provethat this
solutionis incorrect.
Arora
andGupta
[AROG88]
dispute Tan
of
the
algorithm whichthis
authorbelieves
is
stillincorrect.
Eriksen
[ERIK88]
presents asolution
for
the
distributed
case on aring
topology.
The
only
information
each processneeds
to
know
is
the
upperboundary
onthe
number of processorsin
the
network.Huang
[HUAN88]
offers adistributed
solution which useslogical
clocks.The
algorithmis
described
in
a generalfashion for
use withany topology.
The
reader wouldhave
to
adaptthe
algorithmto the
particular networktopology
used.This
author wasonly
ableto
find
two
articlesin
the
literature
for
1989
-both
by
Arora
andGupta.
In
the
first
article[AROG89],
they
present aframework for
deriving
ring-based
termination
algorithms.It
appearsto this
authorto simply
be
a generalizationof algorithms
previously
presentedby
these
authors and as such will notbe
discussed
in
this
paper.The
second paper[AROR89]
introduces
three
algorithms whichemploy
bi
directional
control communication around a ring.One is
for
the
asynchronous centralizedcase and
the
othertwo
arefor
the
asynchronousdistributed
case.1.16.
Summary
This
chapter gavethe
reader an overview ofthe
contents ofthis
paper.It
contained aformal description
ofthe termination
problem and an overview ofits
development.
All
terms that
are usedin
this
paper weredefined here.
Finally
the
logic behind
the ordering
of
topics
and ahistorical
perspective were presentedin
orderto clarify
some ofthe overlap
2.
SYNCHRONOUS
CENTRALIZED
SOLUTIONS
2.1.
Introduction
This
chapter willbegin
the
analysis ofsynchronous centralized solutionsby looking
atthe
issues
involved in
declaring
termination
for
this
case.It
will also make explicitthe
assumptions used
in
each ofthe
algorithms presented.It
willthen
look
atthe
algorithmswritten
to
solvethis
version ofthe
problem andfinally
analyzethe
overheadinvolved in
each case.
2.2.
Issues
Centralized
solutionshave
the
advantagethat
they
makethe
issues in
termination
clear,
because
they
are not cloudedby
the
issues in
atruly
distributed
system.One
ofthe
mostbasic
questionsis
what conditions are sufficientto
determine
that
acomputation
P
is
completed andtherefore
canterminate.
The
obvious answeris
that
allp,-have
satisfiedtheir
local 6,-.
However it
turns
outthis
is
not a sufficient condition.For
instance,
consider a computationP,
which consists ofthree
processespx, p2,
andp3,
connectedin
a ring.Suppose
processespj
andp2
arepassive, the
detector
has
visitedthem,
andknows
that
they
are passive.Suppose
alsothat
p3 is
active.Before
going
passive
P3
sends onefinal be
to p2, causing
p2
to
become
active.When
the
detector
visitsp3,
it is
passive andthe
detector
assumestermination
-all processes are passive.
However,
this is incorrect because p2 is
currently
active.This is
an example ofbehind
the
back
communication.
Any
correcttermination
algorithm willhave
to
be
ableto
detect
all possible2.3.
Assumptions
At this
point, the
assumptionthat
all channels ofthe
network are reliableholds.
In
addition all messages are received
in
arelatively short,
finite
amount oftime,
andboth
send and receive are
blocking
operations.2.4.
Solutions
Using
aTree
Topology
Many
ofthe
early
synchronous solutions assume a network with atree
topology
superimposed upon
it for
the
control communication.In
the
earliest solutionsthe tree
has
to
be
derived
by
the
programmer whoknows
the
TDS for
each process.There
arethree
solutions of
this type.
The
first
published algorithmis
writtenby
Francez
[FRAN80].
This
algorithm
is
extremely
cumbersome andfreezes
the
be
ofthe computation;
however,
it
illustrates
the
issues involved. The
secondsolution,
alsoby
Francez
[FRAN82],
eliminatesfreezing
ofthe
computation andis
somewhat more efficient.The
third solution,
writtenby
Topor
[TOP084]
borrows
from
Francez
[FRAN82]
andDijkstra
[DIJK83].
The
resultis
clearer
than
Francez
but
efficiency
and overhead remainthe
same asFrancez's
algorithm[FRAN82].
There is
also asolution,
which uses atree
topology,
that
does
not requirethe
programmer
to
derive
the tree.
Misra
[MISR82]
usesthe
diffusing
computation,
asintro
duced
by
Dijkstra
[DIJK80]
for his
underlying
application.The
diffusing
computationbuilds the
tree
for
him.
Francez
assumesthe
networkis
representedby
aweakly connected,
directed
communication
graph,
Gp,
containing
one nodefor
each p,.A
secondgraph,
Tp
is
derived
from
Gp
and reflectsthe
termination
dependencies
withinP.
Tp
is
also aweakly
connected,
directed
graph.The strategy is to
arrangethe
dependencies among
the
p,
suchcould
occur.)
After
the spanning tree
is
derived,
oneprocess,
the
root, is
assignedthe
job
of
detector.
The
algorithm works asfollows:
1.
When
the
root ofthe tree
reachesits final
state,
i.e.,
its
6,
is
met,
it
initiates
acontrol wave
to
its
descendants
in
the
tree.
2.
When
the
wave reaches anode, it
does
the
following:
If
the
nodehas
satisfiedits local
predicate,
be
is
frozen
(this
preventsbehind
the
back
communication)
andthe
waveis
passeddown
to
all ofits
descen
dants.
If the
nodehas
not satisfiedits local
predicate,
the
waveis
stopped and anegative response
is
passedback
up.3.
When
the
wave reachesthe
leaves
it is
passedback
up to the
root asfollows:
If
all ofthe
nodesin
p,'s subtreehave
satisfiedtheir
local
predicate,
pass apositive response
up to
p,'s parent.If
p(,
orany
nodein its
subtree,
has
not satisfiedits
local
predicate,
pass anegative response
up to
p,'s parent.4.
If
the
root receives a positiveresponse,
it initiates
termination.
If
the
rootreceives
any
negativeresponse,
it
propagates an'unfreezing
wave'so
that
basic
communication
may
resume.When
this
waveis
receivedby
the
leaves
they
ini
tiate
afourth
wave.This
wavemay
pass a node whichhas
not metits
local
predicate
only
afterthat
node performs onebasic
communication.This
preventsthe possibility
of an endless controlloop.
Only
whenthe
root receivesthis
fourth
wave
may
it initiate
another control waveto
detect
termination.
once
enabled,
ccis
insistant.
The
overheadin
the
best
caseis 2ra
where nis
the
number of processesin
the
system.In
the
worst caseit
is
(An
*m)
+ 2n
where mis
the
number ofbasic
communications.In
this
algorithmthe
control codeinterferes
withthe efficiency
ofthe
execution ofthe
application
itself
through
the
freezing
ofbe.
The
resulting
algorithmis
not efficient andit
wouldbe better if
the
programmerdid
not
have
to
derive
the spanning tree
himself.
However,
Francez
made alarge
contributionto the
field
by defining
the
problem andexploring the
dependencies between
the
processesinto
whichthe
application mustbe
partitioned.A
later
algorithm offeredby
Francez
[FRAN82]
has
a smaller overhead with respectto the
controlstrategy
anddoes
notdelay
the
computationby freezing
the
be.
The
control
communicationis indulgent instead
ofinsistant
to
further
reducethe time
consumedby
it
andincrease
efficiency.For
this
algorithm each nodehas
two
additionallocal
variables:
advance
initially true,
whichis
setto true
whenever abasic
communication
takes
placesend-w$\ftof
children]
alsoinitially
true,
whichis
setto
false
to
indicate
wave w2
may
be
propagateddown
to this
child.The initial idea
wasto
have
three waves;
however,
waves one andthree
canbe
combined
to
form
the
single wave wl-3.The
algorithm works asfollows:
1.
Wave
wl-3is initiated
by
the
leaves
astheir
local
predicates,
6,,
become
true.
The
current value of advanceis
passedup to the parent, the
variable advanceofthe
leaf
is
then
setto
false,
andthe
node sits and waitsfor
a messagefrom
any
other
process,
althoughit
may
notinitiate
any
communication unlessit
receiv