termination detection

28
Termination Detection Presented by: Yonni Edelist

Upload: glenda

Post on 07-Jan-2016

72 views

Category:

Documents


1 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Termination Detection

Termination Detection

Presented by:

Yonni Edelist

Page 2: Termination Detection

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

Page 3: Termination Detection

The model- example

0 2

4

6

3

1

5

Page 4: Termination Detection

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

Page 5: Termination Detection

example

We denote messages sent by the termination detection algorithm ‘signals’

0 2

4

6

3

1

5

Page 6: Termination Detection

Termination detection in a ring

Page 7: Termination Detection

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’

Page 8: Termination Detection

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

Page 9: Termination Detection

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)

Page 10: Termination Detection

P0- Example

3

2

0

1

Red outline represents an active machine

Page 11: Termination Detection

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)

Page 12: Termination Detection

Rule 0- Example

3

2

0

1

Page 13: Termination Detection

But what if a message is sent?

3

2

0

1

Page 14: Termination Detection

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)

Page 15: Termination Detection

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

Page 16: Termination Detection

Rule 1- Example

3

2

0

1

Page 17: Termination Detection

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

Page 18: Termination Detection

But…

3

2

0

1

Page 19: Termination Detection

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

Page 20: Termination Detection

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

Page 21: Termination Detection

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

Page 22: Termination Detection

Invariant P2- Example

3

2

0

1

Page 23: Termination Detection

Rule 3

The algorithm may finish unsuccessfully Rule 3: after an unsuccessful round, machine

0 initiates another round

Page 24: Termination Detection

But…

3

2

0

1

Page 25: Termination Detection

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

Page 26: Termination Detection

Still not good enough

3

2

0

1

Page 27: Termination Detection

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)

Page 28: Termination Detection

Final example

3

2

0

1