1 causality. 2 the “happens before” relation happens before (causes)
TRANSCRIPT
2
The “happens before” relation1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
21 happens before (causes)
1 2
6
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
“happens before” is a partial order
101
110
Parallel events: 101
101
7
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
“happens before” is a partial order
813
138
Parallel events: 138
138
8
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
We can move parallel events
The happens before relationdoesn’t change
9
We want to find a mechanism thatcaptures the “happens before” relationship
so that we use causality in various computation problems
10
Logical Clocks
1 2 3 4 50p
1p
1 2 3
1 2
1)( 1 LT 21)()( 12 LTLT
3
4 5
4
6 7 8 9
In each process, the logical clockincreases by 1 with each local event
0
0
11
1 2 30p
1p
1 2
1 2
514
1)4,2max(
1))(),(max()( 723
LTLTLT
3
5
4
4 5 6 7
Logical clocks are piggy-packed on messages
40
0
12
Logical clocks, seem that they capture the happens before relation
ji )()( ji LTLT
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
1 2 3 7 8
2 4 5 6
1 2 3 4 5 6 7
13
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
1 2 3 7 8
2 4 5 6
1 2 3 4 5 6 7
71 )(41)( 71 LTLT
Example:
14
However, logical clocks cannot capture parallelism
)(54)( 813 LTLT
Parallel events
138
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
2p
1 2 3 7 8
2 4 5 6
1 2 3 4 5 6 7
???)( 813
16
Vector Clocks
1 2 3 4 50p
1p6 7 8 9
0
0
0
0
0
1
0
2
0
3
0
4
0
5
1
0
2
0
3
0
4
0
Process entry
Process entry
0p
1p
0
1)( 1VC
17
1 2 3 4 50p
1p6 7 8 9
0
0
0
0
0
1
0
2
0
3
0
4
0
5
1
0
2
0
3
0
4
0
Each process increases its entry at each event
0
3
0
1
0
2
0
1)()( 23 VCVC
increment
18
1 2 3 4 50p
1p6 7 8 9
0
0
0
0
0
1
0
2
0
3
0
4
0
5
1
0
2
0
3
0
4
0
Each process increases its entry at each event
4
0
1
0
3
0
1
0)()( 89 VCVC
increment
19
1 2 30p
1p4 5 6 7
vector clocks are piggy-packed on messages
0
0
0
0
0
1
0
2
1
0
2
0
3
0
4
0
4
0
4
3
4
2
4
0,
0
2max
The maximum of each entry
20
1 2 30p
1p4 5 6 7
vector clocks are piggy-packed on messages
0
0
0
0
0
1
0
2
1
0
2
0
3
0
4
0
4
0
4
3
4
3
0
1
4
2
0
1
4
0,
0
2max
0
1))(),(max()( 723 VCVCVC
21
30p
1p7
vector clocks are piggy-packed on messages
4
0
4
0
4
3
6
4
1
0
5
4
1
0
4
4,
5
0max
1
0))(),(max()( 1089 VCVCVC
4
4
5
0
6
4
4
4
8 9
10
22
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
3p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
25
Incomparable vector clocks
3
2
1
3
2
1
b
b
b
a
a
aWe write
3
2
1
3
2
1
b
b
b
a
a
a
3
2
1
3
2
1
b
b
b
a
a
aIf neither nor
28
If then 21 )()( 21 VCVC
If then 21 )()( 21 VCVC
By examining the vector clockswe can determine the order of events
29
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
3p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 )()( 21 VCVC
30
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
3p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
132 )()( 132 VCVC
31
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
3p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
101 )()( 101 VCVC
32
1 2 3
6 7 8 9
10 11 12 13 14 15 16
4 50p
1p
3p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
148 )()( 148 VCVC
37
0p
1p
2p
messages can crossfrom left to right of the cut
Consistent cut:
21 3 4 5
1 2 3 4
21 3 4 5 6 7
5
3
2
38
0p
1p
messages cross from right to left of the cut
Inconsistent cut:
21 3 4 5
1 2 3 4
21 3 4 5 6 7
4
2
1
2p
39
0p
1p
21 3 4 5
1 2 3 4
21 3 4 5 6 7
5
3
4
messages cross from right to left of the cut
Inconsistent cut:
2p
40
A consistent cut such that
Maximal Consistent Cut
Maximal Consistent Cut of :
Consider some (inconsistent) cut r
r
s rs
and contains most recent events s
44
Assume for contradiction there are two(or more) maximal cuts of r
1s 2s
maximal consistent cuts
r
51
A distributed algorithm for computing the maximum consistent cut of :
•Use vector clocks
•For each processor: Find most recent event with vector clock
r
rv
52
0p
1p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 72p
53
0p
1p
2p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 7
r
6
2
2
54
0p
1p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 7
r
6
2
2
6
2
2
0
0
2
OK
:0p
2p
55
0p
1p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 7
r
6
2
2
6
2
2
3
2
1
OK
:1p
OK
2p
56
0p
1p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 7
r
6
2
2
6
2
2
6
3
2
OK
:2p
OK
2p
57
0p
1p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 7
r
6
2
2
6
2
2
5
0
2
OK
:2p
OK
2pOK
58
0p
1p
0
0
1
0
0
2
0
0
3
5
4
4
5
4
5
0
1
1
3
2
1
3
3
1
5
4
2
1
0
0
2
0
0
3
0
0
4
0
2
5
0
2
6
3
2
7
3
2
21 3 4 5
1 2 3 4
21 3 4 5 6 7
r
6
2
2
2p
s
5
2
2
59
Distributed Snapshot
•A set of processors initiate the computation for obtaining a global snapshot
S
•The cut contains the state of at least one processor in in the initiation S
(these processors receive special marker messages from the system)
60
A Distributed Snapshot Algorithm
•Upon receiving a marker message:
Processor : 0inum nilansi ip
•Count local events in inum
If thennilansi set nilansi
send marker to all neighbors
Spring 2003 Costas Busch 73
0p
1p
2p
1m 2mFIFO Order
Messages from are received in the order they are sent from
ip
ip
3p
Spring 2003 Costas Busch 75
0p
1p
2p
1m 2m
3p
3m 4m
Messages from differentprocessors may be received indifferent order
FIFO order
Spring 2003 Costas Busch 77
Why is FIFO important?
Deposit$1000
ATM
BankAccount
Withdraw$500
$0 $1000 $500
FIFO order
Spring 2003 Costas Busch 78
Why is FIFO important?
Deposit$1000
ATM
BankAccount
Withdraw$500
$0 $500-$500
Not FIFO order Not an allowedtransaction
Spring 2003 Costas Busch 79
0p
1p
2p
3p
2
A processor increments a counterwhen it broadcasts
1
11 22
1 2
A simple FIFO algorithm
1m 2m1 2
Spring 2003 Costas Busch 80
A processor keeps track of the highest valuesreceived from other processors
00
pV 10
pV 20
pV
0p
1p
2p
3p
21
11 22
1 21m 2m1 2
Spring 2003 Costas Busch 81
00
pV
Wait until all messages with smaller values from the same sender are received
wait ok
0p
1p
2p
3p
21
1 1 22
1 21m 2m1 2
Spring 2003 Costas Busch 84
0p
1p
2p
1m
2m
Total Order
Messages are received in the same order in every processor
3p
Spring 2003 Costas Busch 92
0p
1p
2p
3p
2
With the counter,broadcast messages are totally ordered
1
wait ok
2
1
Spring 2003 Costas Busch 93
0p
1p
2p
3p
2
With the counter,broadcast messages are totally ordered
1
wait ok
received
2
2
1
2
Spring 2003 Costas Busch 94
A Symmetric Algorithm
Builds on top of FIFO
It is a form of Vector Clocks
Spring 2003 Costas Busch 95
Every process has a counter
On broadcast: the process sends the counter value to every boby
Spring 2003 Costas Busch 96
On reception of a message:
If received counter value is higher than local value, then:
•Update local counter to new value
•Broadcast new counter value to everybody else
Spring 2003 Costas Busch 100
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
0
0
1
Special broadcast message
Spring 2003 Costas Busch 101
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
Spring 2003 Costas Busch 102
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
Actual reception of normal broadcast message
Spring 2003 Costas Busch 103
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1 2
2
2
Another normal broadcast
Spring 2003 Costas Busch 104
2
1
0
a
a
a
Local vector of :
receive a normal broadcast message if message’s counter is smaller or equal than each ja
ip
ip
Spring 2003 Costas Busch 108
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
1
1
1 1
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
Spring 2003 Costas Busch 109
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
1
1
1 1
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
Spring 2003 Costas Busch 110
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
1
111
1
1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
Symmetry is broken with node ids
Spring 2003 Costas Busch 112
0p
1p
2p
1m
2m
Casual Order
Messages are received in the order they are caused
3p
Spring 2003 Costas Busch 116
The Total Order algorithmswe described are also Casual Order algorithms
Observation:
There is a more efficient algorithmin terms of message complexity
Spring 2003 Costas Busch 120
2p
1p
0p
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
1
0
0
2
0
0
2
0
0
2
0
0
2
0
Spring 2003 Costas Busch 124
2p
1p
0p
0
2
0
0
2
0
0
2
0
0
3
0
0
3
0
0
3
0
0
3
0
0
3
1
0
3
1
0
3
1
0
3
1
Spring 2003 Costas Busch 125
Processor officially receives a message from with vector clock
ip
2
1
0
v
v
v
1) All messages from smaller or equal to arrive
2) All messages from smaller than arrive
kv
jp
kp )( jk
jp
jv
When:
Spring 2003 Costas Busch 129
Total Order
Total Order does not imply Casual Order nor FIFO
a b ab
b a