Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wait-Free Consensus CPSC 661 Fall 2003 Supervised by: Lisa Higham Presented by: Wei Wei Zheng Nuha Kamaluddeen.

Similar presentations


Presentation on theme: "Wait-Free Consensus CPSC 661 Fall 2003 Supervised by: Lisa Higham Presented by: Wei Wei Zheng Nuha Kamaluddeen."— Presentation transcript:

1 Wait-Free Consensus CPSC 661 Fall 2003 Supervised by: Lisa Higham Presented by: Wei Wei Zheng Nuha Kamaluddeen

2 Outline ● Deterministic Wait-Free – Impossibility – Universality ● Randomized Wait-Free – Robust weak shared coin ● Multi Consensus Game – Use randomizes solution – Recycling counter ● Conclusion

3 Deterministic Wait-Free ● Wait-Free Implementation is the one which guarantees that any process can complete any operation in a finite number of steps of that process ● Given two concurrent objects X and Y ● Q: Does there exist a wait-free implementation of X by Y? ● FLP and Herlihy ’ s papers answered this question

4 Consensus Problem ● A system of n processes that communicate through m shared objects – Each process starts with an input value from domain D – Communicates with one another by applying operations to the shared objects – Eventually agree on a common input value and halt

5 Consensus Problem ● Requirements: – Agreement: all processes decide on one common value if they do decide – Validity: the common decision value is the input of some process – Wait-Freedom: each process decides after a finite number of steps

6 Consensus Number ● Consensus Number for an object X is the largest n for which X solves consensus problem for n processes ● If no largest n exists, then the consensus number is said to be infinite

7 FLP vs. Herlihy ● FLP answered the question for a specific object, i.e., R/W register. ● FLP provided a stronger result for this special case: no implementation of consensus problem of n>=2 processes using R/W registers, even for at most 1 stopping faulty process, and even for binary inputs ● Herlihy gave a more generalized answer: Impossibility and Universality Hierarchy for wait-free implementation of any type of object

8 Impossibility and Universality Hierarchy Memory-to-memory move and swap, augmented queue, compare&swap, fetch&cons, sticky byte Infinity n-register assignment 2n - 2 Test&set, swap, fetch&add, queue, stack 2 R/W registers 1 Consensus Number … … Object

9 Impossibility and Universality ● Impossibility – It is impossible to construct a wait-free implementation of an object with consensus number n from any number of objects with a strictly smaller consensus number

10 Impossibility and Universality ● Universality: an object is universal in a system of n (or fewer) processes if it can implement any object of consensus number n ● The n-consensus object is universal in a system of n (or fewer) processes

11 FIFO Queue ● Supports two operations: – enq(queue, val): appends a new element to the end of queue with the value val – deq(queue): reads and removes the first element of queue

12 FIFO Queue has n >= 2 P: decide(input: value) returns(value) prefer[P] := input if deq(A) = 0 then return prefer[P] else return prefer[Q] endif end decide Prefer ┴ ┴ A 1 0 Initially

13 FIFO Queue has n = 2 ● Impossible for n > 2 ● Proof: – Initially: ● Three processes P, Q and R ● Each about to make decision step ● P's operation x-valent ● Q's operation y-valent – Cover all possible combinations of operations

14 FIFO Queue has n = 2 (cont.) ● Case 1: P and Q deq(A) 1 v 2 C: bi-valent T' T S' S S' ~ T' R Q deq(A) P deq(A) Q deq(A) P deq(A) 3 A 1 v 2 3 A x-valenty-valent

15 FIFO Queue has n = 2 (cont.) ● Case 2: P enq(A, p) and Q deq(A) Non-Empty Queue C: bi-valent T' S' S Q deq(A) P enq(A, p) Q deq(A) P enq(A, p) T S' ~ T' R 1 p 2 3 A 1 p 2 3 A x-valent y-valent

16 FIFO Queue has n = 2 (cont.) ● Case 2: P enq(A, p) and Q deq(A) Empty Queue C bi-valent S P enq(A, p) T S ~ T’ R p A p A T' Q deq(A) P enq(A, p) x-valent y-valent

17 FIFO Queue has n = 2 (cont.) ● Case 3: P and Q enq() 1 2 Q’s P’s p q 1 2 Q’s P’s q p C: bi-valent T'S' S Q enq(A, q) P enq(A, p) Q enq(A, q)P enq(A, p) T S’’’ ~ T’’’ R x-valenty-valent P-only until it deq p Q-only until it deq q S’’’ S’’ T’’’ T’’ P-only until it deq q Q-only until it deq p AA

18 Augmented Queue ● Add one more operation to the FIFO queue: – Peek(): returns but does not remove the first item in the queue ● See how the queue becomes POWERFULL

19 Augmented Queue has n = infinity decide(input: value) enq(A, input) Return peek(q) end decide

20 Universality ● An object is UNIVERSAL if it implements any other object ● Example: Object R implements object A Front-EndObject R PiPi Object A Invoke Respond Invoke

21 Universality Algorithm: Idea Input: invoke Output: respond Consensus Object Input: (var, pref_val) Output: decides val to var Universal Algorithm invoke respond

22 Universality Algorithm: Idea ● A linked list to represent the object ● Each cell represents an invocation ● Sequence of cells represent the sequence of applied operations ● Sequence: unbounded integer size

23 Universality Algorithm: Idea ● When a process P makes an invocation 1. P creates a node with sequence = 0 and fill in its invocation 2. P tries to attach its node to the linked list 3. Attaching the node means performing its invocation 4. Once the node is attached, it will have a sequence and all of its entries will be filled

24 Universality Algorithm: Idea ● Apply (invoke, state, state, result) – May be non-deterministic – Apply (invoke, state) represents (new_state, result)

25 Universality Algorithm: Node Seq: integer Inv: INVOKE Before: * cell After: * cell New state result New: consensus object After: consensus object

26 Universality Algorithm: Linked-List Seq = 1 State: S1 Seq = 2 Inv2 State: S2 Res: R2 Seq = 3 State: S3 Seq = 4 Inv4 State: S4 Res: R4 Inv3 Res: R3 Anchor before after Example: Apply(Inv2, S1)  (S2, R2) Similarly: Apply(Inv3, S2)  (S3, R3) …… etc.

27 Universality Algorithm P0 Anchor P4 P3P2P1 Announce Head 0 1 2 3 4 Seq = 1 State: S1 Initially decide(var, val) Assigns a val to var before after NULL

28 Universality Algorithm P0 Anchor P4 P3P2P1 Announce Head 0 1 2 3 4 Seq = 1 State: S1 before after NULL 0 Inv decide(var, val) Assigns a val to var 3 3 3

29 Universality Algorithm P0 Anchor P4 P3P2P1 Announce Head 0 1 2 3 4 Seq = 1 State: S1 before after NULL decide(var, val) Assigns a val to var before (S1, Inv) (S2, R2) 0 Inv after NULL State: S2 Res: R2 Seq = 2

30 Universality Algorithm P0 Anchor P4 P3P2P1 Announce Head 0 1 2 3 4 Seq = 1 State: S1 before after NULL Decide(var, val) Assignes a val to var Seq = 2 Inv State: S2 Res: R2 before after NULL

31 Universality Algorithm P0 Anchor P4 P3P2P1 Announce Head 0 1 2 3 4 Seq = 1 State: S1 before after NULL decide(var, val) Assigns a val to var Seq = 2 Inv State: S2 Res: R2 before 0 Inv3 0 Inv1 0 Inv4 1 1 3 after NULL 1 1 1 1 S2, Inv1 S3, R3

32 Universality Algorithm P0 Anchor P4 P3P2P1 Announce Head 0 1 2 3 4 Seq = 1 State: S1 before after NULL decide(var, val) Assigns a val to var Seq = 2 Inv State: S2 Res: R2 before 0 Inv3 0 Inv4 Seq = 3 Inv1 State: S3 Res: R3 NULL after before

33 Universality Algorithm: Why Help ● Beyond being nice ● With help  wait-free ● Without help  non-blocking

34 Universal Algorithm universal(what: INVOC) returns(RESULT) my_cell: cell := [seq:0, inv: what new: create(consensus_object) before: create(consensus_object) after: null] announce[P] := my_cell for each process Q do head[P] := max(head[P], head[Q]) while (announce[P].seq = 0]) c: *cell := head[P] help: *cell := announce[(c.seq mod n) + 1] if help.seq = 0 then prefer := help else prefer := announce[P] d := decide(c.after, prefer) decide(d.new, apply(d.inv, c.new.state)) d.before := c d.seq := c.seq + 1 head[P] := d head[P] := announce[P] return (announce[P].new.result) end universal create my_cell (use INV = INVOKE) Announce my_cell While my_cell is not attached to the linked-list Consult head to point to some process: help, and see if it needs help if yes prefer (help) else prefer (my_cell) send my prefer to decide send my apply preference to decide fill fields of the attached cell return my new RESULT

35 Impossibility/Universality: Importance ● Research done before was focusing on constructing complex objects from atomic R/W registers ● Atomic registers have few applications in constructing wait-free implementation of more complex data structure – Examples: ● Sets, queues, stacks, priority queues, lists ● Classical synchronization primitives: test&set, compare&swap, fetch&add ● Simple memory-to-memory operation: move and swap

36 Research Turning Points ● Pay attention to other primitives: stronger than R/W registers ● Give up wait-free ● Use randomized wait-free

37 Conclusion ● Deterministic Wait-Free Consensus – Impossibility and universality Hierarchy – Universality algorithm

38 References  M. Herlihy. Wait-Free Synchronization. ACM Transactions on Programming Languages and Systems, 13(1): 124-149. January 1991.

39 Questions?


Download ppt "Wait-Free Consensus CPSC 661 Fall 2003 Supervised by: Lisa Higham Presented by: Wei Wei Zheng Nuha Kamaluddeen."

Similar presentations


Ads by Google