Termination Detection
Presented by:
Yonni Edelist
The model
A finite graph of machines (nodes) and communication channels (edges), in which a distributed computation is taking place
Machines can be either ‘active’ or ‘passive’ Only active machines may send messages Passive machine may become active only when
it receives a message Active machine may become passive at any time
The model- example
0 2
4
6
3
1
5
The problem
If, in the computation, a finite number of messages are sent, the graph will reach a stable state in which no more messages are sent
One machine, say machine no. 0, wants to detect that the graph has reached that state
We will build an algorithm which enables machine 0 to detect termination
example
We denote messages sent by the termination detection algorithm ‘signals’
0 2
4
6
3
1
5
Termination detection in a ring
The model
N machines, 0..N-1 Machine 0 initiates the detection algorithm Does so by sending a signal (a token) to
machine 1 Machine i can propagate the token to
machine i+1 We denote the machine currently holding the
token ‘t’
System Invariant
We describe an invariant, which will be true for every configuration of the system (for every value of t)
Machine 0 will know that all other machines are passive based on:– t=0– The invariant– (possibly) further information available at machine
0
First Invariant- P0
First step- we assume that there are no messages
Meaning: an active node may become passive, but not vice-versa
P0: (∀ i: 0≤i<t machine i is passive)
P0- Example
3
2
0
1
Red outline represents an active machine
Rule 0
In order to preserve the invariant, we must follow the rule:
Rule 0: Machine i transmits the token only if it’s passive
(remember that a passive machine can’t become active again)
Rule 0- Example
3
2
0
1
But what if a message is sent?
3
2
0
1
Invariant P1
If machine i<t receives a message, it becomes active, thus falsifying P0
Message must have been sent by machine j≥t
P1 is established whenever P0 is falsified in the above manner
P0: (∀ i: 0≤i<t machine i is passive)
Invariant P1 (cont.)
A machine can be either black or white
P1: (∃ j: t ≤ j ≤ N: machine j is black)
Rule 1: When machine j sends a message to machine i<j, it becomes black
Rule 1- Example
3
2
0
1
Invariant P1 (cont.)
Now P= P0 ∨ P1 is not falsified when a message is sent to i < j.
Machine 0 knows:- (t=0 ∧ machine 0 is white) ¬P1- P0: (∀ i: 0≤i<t machine i is passive) Therefore- machine 0 can still detect
termination
But…
3
2
0
1
Invariant P2
P1 may be falsified when a black machine hands the token over
We want to ensure that every token propagation that falsifies P1 establishes P2
We define that the token may be either black or white
Invariant P2 (cont)
P2: the token is black And the accompanying rule: Rule 2: A black machine transmits a black
token. A white machine doesn’t change the colour of the token
Invariant P2 (cont)
Machine 0 knows:- (t=0 ∧ machine 0 is white) ¬P1
- Token is white ¬P2- P0: (∀ i: 0≤i<t machine i is passive) Therefore- machine 0 can still detect
termination
Invariant P2- Example
3
2
0
1
Rule 3
The algorithm may finish unsuccessfully Rule 3: after an unsuccessful round, machine
0 initiates another round
But…
3
2
0
1
Rule 4
Since a round that begun with a black token is doomed, we adopt:
Rule 4: at the beginning of a new round, machine 0 makes itself white and transmits a white token
Still not good enough
3
2
0
1
Rule 5
Whitening a black machine i may falsify only P1, and only in the case i > t
Rule 5: when transmitting the token to machine i+1, machine i makes itself white
P1: (∃ j: t ≤ j ≤ N: machine j is black)
Final example
3
2
0
1
Top Related