what can be implemented anonymously ?

57
What Can Be Implemented Anonymously ? Paper by Rachid Guerraui and Eric Ruppert Presentation by Amir Anter 1

Upload: chynna

Post on 24-Feb-2016

38 views

Category:

Documents


0 download

DESCRIPTION

What Can Be Implemented Anonymously ?. Paper by Rachid Guerraui and Eric Ruppert. Presentation by Amir Anter. Talk outline. What is anonymously ? Motivation Anonymously implementation Counter Snapshot Consensus Summary. Talk outline. What is anonymously ? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: What Can Be Implemented Anonymously ?

1

What Can Be Implemented Anonymously ?

Paper by Rachid Guerraui and Eric Ruppert

Presentation by Amir Anter

Page 2: What Can Be Implemented Anonymously ?

2

Talk outline What is anonymously ? Motivation Anonymously implementation Counter Snapshot Consensus Summary

Page 3: What Can Be Implemented Anonymously ?

3

Talk outline What is anonymously ? Anonymously implementation Counter Snapshot Consensus Summary

Page 4: What Can Be Implemented Anonymously ?

4

What is anonymously ? There is no unique identifiers for the

processes.

Page 5: What Can Be Implemented Anonymously ?

5

Leader election in rings

• Each process has to decide whether it is a leader or not• Termination states are partitioned to elected and not-elected.• In every execution, exactly one process enters an elected state, all others enter a non-elected state.• We assume rings are oriented.

p0

p1p2

1

1

1

2

2

2

Page 6: What Can Be Implemented Anonymously ?

6

Leader election in anonymous rings

• A ring algorithm is anonymous if processes don’t have an ID they can use in the algorithm (all perform the same code)An anonymous leader election algorithm is… Impossible!!

p0

p1p2

1

1

1

2

2

2

Page 7: What Can Be Implemented Anonymously ?

7

Motivation Sensor networks – Might not have id’s Privacy:

Web servers Peer-to-peer sharing systems

Page 8: What Can Be Implemented Anonymously ?

8

Talk outline What is anonymously? Anonymously implementation Weak Counter Snapshot Consensus Summary

Page 9: What Can Be Implemented Anonymously ?

9

Anonymously Implementation Number of processes is know – n. Shared memory – multi-reader, multi-writer. Using registers Crash failures may occur Deterministic Asynchronous

Page 10: What Can Be Implemented Anonymously ?

10

Wait freedomDefinition:

An algorithm is wait-free if a process invoking it will finish after a finite number of steps

Page 11: What Can Be Implemented Anonymously ?

11

Talk outline What is anonymously? Anonymously implementation Weak Counter Snapshot Consensus Summary

Page 12: What Can Be Implemented Anonymously ?

12

Atomic CounterRead-Modify-Write operation:

Fetch-and-add(w, d)do atomically prev:=w w:= prev+d return prev

Page 13: What Can Be Implemented Anonymously ?

13

Atomic Counter

Example: the sequential spec of a counter

H0: H1: c.f&i() c:0H2: c.f&i() c:0 c.f&i() c:1 H3: c.f&i() c:0 c.f&i() c:1 c.f&i() c:2H4: c.f&i() c:0 c.f&i() c:1 c.f&i() c:2 c.f&i() c:3

.

.

.

Page 14: What Can Be Implemented Anonymously ?

14

Atomic Counter It has been shown by Herlihy that fetch&

increment object has no wait-free implementation from registers, even for the non anonymous case.

Page 15: What Can Be Implemented Anonymously ?

15

Anonymous Counter

So how can we implement a counter only from registers and also

anonymously ?!

Page 16: What Can Be Implemented Anonymously ?

16

Weak Counters Single operation: GetTimestamp

Returns an integer Properties:

Let GetTimestamp(t) = x, GetTimestamp(t’)=x’, If t≥t’ then x ≥x’.

If GetTimestamp was invoked n times then each of those invocation returned a value x ≤n.

Weaker version of fetch&increment. Strong enough for our purposes.

Page 17: What Can Be Implemented Anonymously ?

17

Weak CountersExample: the sequential spec of a weak counter

H0: H1: c.f&i() c:0H2: c.f&i() c:0 c.f&i() c:1 H3: c.f&i() c:0 c.f&i() c:1 c.f&i() c:1H4: c.f&i() c:0 c.f&i() c:1 c.f&i() c:1 c.f&i() c:2 ...

Page 18: What Can Be Implemented Anonymously ?

18

Weak Counters• Array A[1,2,…] of binary registers.

• Initially each register A[i]=0.• Invariant:

• If A[k]=1, then all entries A[1..k]=1.

1 2 3 4A 1 1 1 0 0 0

Page 19: What Can Be Implemented Anonymously ?

19

Weak Counters1 2 3 4

A 0 0 0 0 0 0

Page 20: What Can Be Implemented Anonymously ?

20

Weak Counters

a- Last location returned by the process’s previous

GetTimestamp operation.

Page 21: What Can Be Implemented Anonymously ?

21

Weak Counters

L- Shared register initialized to 0.- When process change some A[b] to 1, it also writes b to L.

Page 22: What Can Be Implemented Anonymously ?

22

Weak Counters

j- Local variable- The number of times the process has seen L changes.

Page 23: What Can Be Implemented Anonymously ?

23

Weak Counters

t- Local variable- The largest value the process has seen in L.

Page 24: What Can Be Implemented Anonymously ?

24

Weak Counters

1 2 3 4A 1 1 0 0 0 0

• Line 3, iteration # 1: a=1 , b=2 , l=2• A[2]=1

Page 25: What Can Be Implemented Anonymously ?

25

Weak Counters

1 2 3 4A 1 1 0 0 0 0

• Line 3, iteration # 2: a=1 , b=4 , l=2• A[4]=0

Page 26: What Can Be Implemented Anonymously ?

26

Weak Counters

1 2 3 4A 1 1 0 0 0 0

• Line 11, iteration # 1: a=1 , b=4• mid=2• A[2]=1 a=3

Page 27: What Can Be Implemented Anonymously ?

27

Weak Counters

1 2 3 4A 1 1 0 0 0 0

• Line 11, iteration # 2: a=3 , b=4• mid=3• A[3]=0 b=3

Page 28: What Can Be Implemented Anonymously ?

28

Weak Counters

1 2 3 4A 1 1 1 0 0 0

• Line 11, iteration # 3• a=3=b A[3]=1 , L=3

Page 29: What Can Be Implemented Anonymously ?

29

Weak Counters• Wait freedom

The second loop stops – binary search. The first loop stops

If j≥n then return t• In any finite execution in which k GetTimestamp

operations are invoked: O(k) registers are accessed. Any operation takes O(log k).

Page 30: What Can Be Implemented Anonymously ?

30

Weak Counters

Page 31: What Can Be Implemented Anonymously ?

31

Talk outline What is anonymously? Anonymously implementation Weak Counter Snapshot Consensus Summary

Page 32: What Can Be Implemented Anonymously ?

32

Snapshot object R[1…n] registers Operations

Scan Returns a vector V, where V is an n-element vector

called a view (with a value for each segment). Update(d)

Process i writes d to R[i]

V[i] must return the value of the latest Updatei operation (or the initial value if there were none)Scan returns a snapshot of the segments array that existed at some point during the execution!

Page 33: What Can Be Implemented Anonymously ?

A wait-free simulation of atomic snapshot

33

Initially segment[i].ts=0, segment[i].data=vi, segment[i].view=<v0, …, vn-1>

Scani(S)1. for all j <> i c[j]=Segment[j]2. while true do3. for all j a[j] = Segment[j]4. for all j b[j] = Segment[j]5. if, for all j a[j]=b[j] ; Comparison includes timestamp!6. return <b[0].data, …, b[n-1].data> ; Direct scan7. else if, for some j ≠ i, b[j].ts - c[j].ts ≥ 28. return b[j].view ; Indirect scan

Updatei(S, d)1. view:=scan()2. Segment[i]=<segment[i].ts+1, d, view>

Page 34: What Can Be Implemented Anonymously ?

34

Anonymous snapshot object R[1…m] registers Operations

Scan Returns a vector V, where V is an m-element vector

called a view (with a value for each segment). Update(i,x)

Writes x to R[i]

Page 35: What Can Be Implemented Anonymously ?

35

Anonymous snapshot object

Page 36: What Can Be Implemented Anonymously ?

36

Anonymous snapshot object

The algorithm is anonymous and wait-free. The average number of steps per operation in

any finite execution is2( )O m n

Page 37: What Can Be Implemented Anonymously ?

37

Talk outline What is anonymously? Anonymously implementation Weak Counter Snapshot Consensus Summary

Page 38: What Can Be Implemented Anonymously ?

38

Consensus Object

© 2003 Herlihy and Shavit 13

The Consensus object: each process has a private input

32 1921

© 2003 Herlihy and Shavit 15

They Agree on Some Process’ I nput

1919 19

Page 39: What Can Be Implemented Anonymously ?

39

Formally: Consensus Object- Supports a single operation: decide- Each process pi calls decide with some input vi from some domain. decide returns a value from the same domain.- The following requirements must be met:

Agreement: In any execution E, all decide operations must return the same value.Validity: The values returned by the operations must equal one of the inputs.

Page 40: What Can Be Implemented Anonymously ?

FIFO queue + registers can implement 2-process consensus

40

Decide(v) ; code for pi, i=0,11. Prefer[i]:=v2. qval=Q.deq()3. if (qval = 0) then return v4. else return Prefer[1-i]

Initially Q=<0> and Prefer[i]=null, i=0,1

There is a proof that wait-free consensus for 2 or more processes cannot be solved by registers.

Page 41: What Can Be Implemented Anonymously ?

41

Anonymous Consensus

So how can we implement it only from registers and also anonymously ?!

Page 42: What Can Be Implemented Anonymously ?

42

Obstruction freedom Obstruction-freedom guarantees that a

process will complete its algorithm whenever it has an opportunity to take enough steps without interruption by other processes.

Page 43: What Can Be Implemented Anonymously ?

43

Consensus

Page 44: What Can Be Implemented Anonymously ?

44

Consensus The algorithm is using 8n+2 registers.

Anonymous Uses anonymous snapshot object.

Obstruction free Correct

Page 45: What Can Be Implemented Anonymously ?

45

Consensus - Obstruction freedom

Let’s see that if process is running by itself it eventually halts.

Page 46: What Can Be Implemented Anonymously ?

46

Consensus - Obstruction freedom

Let C be any configuration. m is the maximum value of R in C. P run by itself forever from C.

Page 47: What Can Be Implemented Anonymously ?

47

Consensus - Obstruction freedom

lap increases at least once every iterations Eventually and Now P will write values larger than m to in the next

iterations.

1lap m

4 1n

1j

0vR 4 1n

Page 48: What Can Be Implemented Anonymously ?

48

Consensus - correctness

Let P’ be a process that decides 0 (without loss of generality). Let T be the time P’ last scans R and S’ that scan. We shall show that every other process that terminates

also decides 0.

Page 49: What Can Be Implemented Anonymously ?

49

Consensus - correctness

Let m be the minimum value in All values in are less than m.

0'S

1'S

Page 50: What Can Be Implemented Anonymously ?

50

Consensus - correctness

Claim 1: After T, at most n UPDATES write smaller value than m to R.

Page 51: What Can Be Implemented Anonymously ?

51

Consensus - correctness

Proof: n+1 writes, let’s look at the first process P that writes to R in the second time.

4n+1>n one of the values in is at least m, from line 10 we get that P local P will write at least m to R.

0Rlap m

Page 52: What Can Be Implemented Anonymously ?

52

Consensus - correctness

Claim 2: After T, at most n UPDATES write a value to 1R

Page 53: What Can Be Implemented Anonymously ?

53

Consensus - correctness

Proof: n+1 writes, let’s look at the iteration of the first process P that writes to R in the second time.

At most n values are greater than m in From claim 1, at most n values are smaller than m in

1R

0R

Page 54: What Can Be Implemented Anonymously ?

54

Consensus - correctness

We get that for at leastvalues of i. P will change its local value to 0 in line 5.

0 1[ ] [ ]R i m R i 4 1 2 1n n n n

Page 55: What Can Be Implemented Anonymously ?

55

Talk outline What is anonymously? Anonymously implementation Weak Counter Snapshot Consensus Summary

Page 56: What Can Be Implemented Anonymously ?

56

Summary We showed anonymous algorithms by using

only read/write registers. Weak counter – wait free implementation Snapshot object – wait free implementations Consensus – obstruction free implementation

Page 57: What Can Be Implemented Anonymously ?

57

Thank you!