Sie sind auf Seite 1von 37

Cuts

p0

p1
p2

Cut: consists from an event


from each process
2

p0

p1
p2

4
1
2

3

Consistent cut:

p0

p1
p2

no messages cross the cut

4
1
2

3

messages can cross


from left to right of the cut

Consistent cut:

p0

p1
p2

7
2
3

5

Inconsistent cut: messages cross


from right to left of the cut
2

p0

p1
p2

1
2

4
6

Inconsistent cut: messages cross


from right to left of the cut
2

p0

p1
p2

4
4

6
4
3

5

Maximal Consistent Cut


Consider some (inconsistent) cut
Maximal Consistent Cut of
A consistent cut
and

r:

s such that s r

s contains most recent events

r
2

p0

p1
p2

1
2 (inconsistent cut)

4
9

maximal consistent cut

p0

p1
p2

4
1
2

3

1
2 (inconsistent cut)

4
10

Theorem:

Proof:

For every cut r,


there is a unique
maximal consistent cut

Proof by contradiction

11

Assume for contradiction there are two


(or more) maximal cuts of r

r
s1 s2
maximal consistent cuts
12

It cannot be that s1 and s2 dont cross

r
s1

s2

not maximal!
13

s1 and s2 cross

r
s1

s2
14

s1 and s2 cross

r
s1

s2
new cut s
15

s1 and s2 cross
Contradiction!

r
s1

not maximal!

s2

not maximal!

End of proof

s is consistent
16

A distributed algorithm for computing


the maximum consistent cut of r :
Use vector clocks
For each processor:
Find most recent event with
vector clock v r

17

p0

1
0

0

2
0

0

3
0

0

p1

1
1

0

p2 1

0
0

2

0
0

3

2
0

4

0
0

1

1
2

3

1
3

3

4
4

5

5
4

5

2
4 4
5

2
0

5

2
3

6

2
3

7

18

p0

1
0

0

2
0

0

r
2

p1

1
1

0

p2 1

0
0

2

0
0

3

2
0

4

0
0

1

3
0

0

1
2

3

1
3

3

4
4

5

5
4

5

2
4 4
5

2
0

5

2
3

6

2
3

7

2
2

6
19

p0

1
0

0

2
0

0

OK

p1

1
1

0

p2 1

0
0

2

0
0

3

2
0

4

0
0

1

p0 :

3
0

0

1
2

3

2
0

0

1
3

3

2
2

6

4
4

5

5
4

5

2
4 4
5

2
0

5

2
3

6

2
3

7

2
2

6
20

p0

1
0

0

2
0

0

1
1
1

0

p1
p2 1

0
0

1

0
0

2

0
0

3

p1 :

OK

3
0

0

1
2

3

OK

1
3

3

4
2
0

4

1
2

3

2
2

6

4
4

5

5
4

5

2
4 4
5

2
0

5

2
3

6

2
3

7

2
2

6
21

p0

1
0

0

2
0

0

1
1
1

0

p1
p2 1

0
0

1

0
0

2

0
0

3

p2 :

OK

3
0

0

1
2

3

OK

1
3

3

4
2
0

4

2
3 /

6

2
2

6

4
4

5

5
4

5

2
4 4
5

2
0

5

2
3

6

2
3

7

2
2

6
22

p0

1
0

0

2
0

0

1
1
1

0

p1
p2 1

0
0

1

0
0

2

0
0

3

p2 :

OK

3
0

0

1
2

3

OK

1
3

3

4
2
0

4

2
0

5

2
2

6

5
2
0

5

OK

4
4

5

5
4

5

2
4 4
5

2
3

6

2
3

7

2
2

6
23

p0

1
0

0

2
0

0

s r
2

p1

1
1

0

p2 1

0
0

2

0
0

3

2
0

4

0
0

1

3
0

0

1
2

3

1
3

3

4
4

5

5
4

5

2
4 4
5

2
0

5

2
3

6

2
3

7

2
2

5

2
2

6
24

Distributed Snapshot
A set S of processors initiate the
computation for obtaining a global snapshot
(these processors receive special
marker messages from the system)

The cut contains the state of at least


one processor in S in the initiation
25

A Distributed Snapshot Algorithm


Processor pi :

numi = 0

ansi = nil

Count local events in numi


Upon receiving a marker message:
If ansi = nil then
set ansi = numi
send marker to all neighbors
26

numi
2

p0

p1
p2

27

p0

p1
p2
p3

S = { p0}
p0
p2

p1
p3
28

p0

p1
p2
p3

m
m
m

S = { p0}
p0
p2

p1
p3
29

p0

p1
p2
p3

m
m
m

S = { p0}
p0
p2

p1
p3
30

p0

p1
p2
p3

m
m
m

m
m

m m

S = { p0}
p0
p2

p1
p3
31

p0

p1
p2
p3

m
m
m

m
m

m m

S = { p0}
p0
p2

p1
p3
32

p0

p1
p2
p3

m
m
m

m
m

m m

m
m

S = { p0}
p0
p2

p1
p3
33

p0

p1
p2
p3

m
m
m

m
m

m m

m
m

cut

S = { p0}
p0
p2

p1
p3
34

Theorem: The cut obtained by the algorithm


is consistent

Proof:

By contradiction

35

Suppose the cut is inconsistent

36

(we assume FIFO)

It must be:

Impossible!
End of proof
37

Das könnte Ihnen auch gefallen