Download presentation
Presentation is loading. Please wait.
Published byGriselda Davis Modified over 9 years ago
1
Common2 extended to stacks and unbound concurrency By:Yehuda Afek Eli Gafni Adam Morrison May 2007 Presentor: Dima Liahovitsky 1
2
Outline: Introduction, refresh and definitions Wait-free stack implementation Snapshot objects Unbounded concurrency objects Summary 2
3
Refresh: TAS TAS object: boolean variable state, initally TRUE Test-and-set() v := state; state := false; return v; 3
4
Refresh: F&A F&A object: int variable num, initialised at the begining Fetch-and-add(x) v := num; num := v + x; return v; 4
5
Refresh: wait-freedom Definition: an algorithm is wait-free if a process invoking it will finish after a finite number of steps. 5
6
Refresh: linearization, concurrency Let H be a history of execution of the system: a sequence of invocation and response events. H is linearizable if H is equivalent to some valid sequential history S, meaning that the partial order of operations in H is a sub-set of the partial order of operations in S. Such a S is the linearization of H. If two operations o1, o2 are incompatible by the partial order on operations induced by a history H, we say: o1 and o2 are concurrent. 6
7
Refresh: linearization (cntd.) Example: Stack 7 St: St.push(a) St.push(b)St.pop(b) St.pop(a) time St.pop(x)St.pop(y)St.push(y)St.push(x) not linearizable linearizable Concurrent operations Linearization points
8
Refresh: consensus Consensus object: Operation: decide(x i ), returns a value Supports: Agreement: all processes calling for decide() get the same return value Validity: the value returned to processes from decide() must be an input of one of them 8
9
Refresh: consensus (cntd.) Consensus power of object obj: The largest number of processes that can wait-free reach consensus using copies of obj object, and registers. Consensus power k k-consensus Consensus hierarchy: K-consensus object cannot implement (k+1)- consensus object 9
10
Common2 Definition (by Y. Afek, 1993): Family of objects that are wait-free implementable from 2- consensus objects for any number of processes. It has been known that F & A, TAS are inside Common 2. It has been believed that not FIFO queue nor LIFO stack are inside Common 2. Hmmmmmm… maybe stack IS inside Common 2?.. 10
11
Outline: Introduction, refresh and definitions Wait-free stack implementation Snapshot objects Unbounded concurrency objects Summary 11
12
Wait-free STACK 12 Push(x) { 1. i = F&A(range, 1); 2. items[i] = x; } Shared Items: range: F&A object initialized to 1//index for the next push items: array [1…] of registers//items[0] = $ T: array [1…] of TAS object Pop() { 1. t = F&A(range, 0) - 1; 2. for i = t downto 1 3.X = items[i]; 4.If x != null then { 5. If TAS(T[i]) then return x; } // end if } // end for 6. return $; //indicator of empty stack } // end Pop
13
Wait-free STACK 13 Let’s have a look at our implementation… Wait-free? Implemented from registers and 2-consensus objects? It’s also known that TAS and F&A have n-bounded implementations from 2-consensus objects Therefore if we show that our stack is linearizable, then we can proudly say that: The Stack object has an n-bounded wait-free implementation from registers and 2-consensus objects => our Stack is in Common2, by definition. yes!
14
Wait-free STACK 14 1. Eliminating concurrent Push(x)/Pop(x) from the History time St.push(x) St.pop(x) Just delete concurrent push(x)/pop(x) ?... Dummy-push(x) { //like previus Push(x), but without array modification i := F&A(range, 1); } Linearization proof sketch:
15
15 2. Linearizing the rest of the history (without concurrent push(x) / pop(x)): Variables for linearization algorithm: I : array of values, initially I[0] = $ and all other cells are NULL S: history, initially empty Terms for the linearizing algorithm L: top(I) : value in the highest index non-NULL cell of I Linearization proof sketch: High level eventPrimitive event Push(x) invocationF&A(range, 1) Push(x) responseItems[i] := x Pop(x) invocationF&A(range, 0) Pop(x) responseWinning TAS at T[x] Pop($) responseLosing TAS at T[1] Pop($) responseReading NULL from items[1]
16
16 2. Linearizing the rest of the history (without concurrent push(x) / pop(x)): L(History = ) { 1.for j := 1 to h do { 2. if e j = {// push() response 3.I[i] := x 4.let y be the lowest non-NULL item stored above x in I 5.if no such y exists then S := S o Push(x) 6.else { 7. let S = S 1 o Push(y) o S 2 8. S := S 1 o Push(x) Push(y) o S 2 9. } //end else 10. } //end if 11. while Pop(top(I)) is active in e 1 …e j { 12. let v = top(I) 13. S := S o Pop(v) 14. If v != $ then I[index(v)] := NULL 15. } //end while 16. } //end for } //end L Linearization proof sketch:
17
Midway Conclusions: So what have we proved for now? There is an n-bounded wait-free stack implementation from registers and 2-consensus objects (TAS, F&A). Therefore stack is in Common2. What next? If we show unbounded concurrency TAS and F&A implementations from registers and 2-consensus objects… Then we will automatically get an unbounded concurrency wait- free stack implementation from registers and 2-consensus objects. 17
18
Outline: Introduction, refresh and definitions Wait-free stack implementation Snapshot objects Unbounded concurrency objects Summary 18
19
Snapshot object Each object has a “segment” = SWMR register. A process may obtain an “atomic snapshot” of all segments of other processes. Supports two operations: 1. update(v) : a process updates its segment to v 2. Scan(): returns an n-element vector called “view” (or V[]), with a value of each segment of all n processes V[i] must return the value of the latest update() of process i. scan() returns a “snapshot” of the segments array that existed at some point during the execution. 19
20
Snapshot example V[i] must return the value of the latest update() of process i. scan() returns a “snapshot” of the segments array that existed at some point during the execution. 3 processes: P1, P2, P3 20 timeP1.segP2.segP3.seg quantums 1000 2100 3200 4210 5213 Scan() starts here Scan() ends here one Possible snapshot returned from scan(): Not possible snapshots returned from scan():
21
Atomic write-and-snapshot We introduce one-shot n-bounded write-and-snapshot() implementation. The implementation can be easily turned into long-lived one by having each process P simulate a sequence P 1, P 2,... of different processes in the one-shot implementation, where P i performs the i-th operation of P. Write-and-snapshot(input i ) makes update() and scan() in one procedure. When process i calls write-and-snapshot(), it first updates its segment, and then returns a set of segments of all other processes that have already updated their segments. Therefore if process i is the first process to complete write-and- snapshot(), it’ll receive an empty set from write-and-snapshot(). 21
22
Atomic write-and-snapshot Shared variables: T[1..n] : array of TAS objects level[1..n] : array of swmr registers; initialized to n+1 value[1..n] : array of swmr registers Local variable: S : set of at most n integers; t : stores returned value of result of TAS Write-and-snapshot (input i ) { 1.value[i] := input i ; 2.while(TRUE) do { 3.level[i] := level[i] – 1; 4.S := { j | level[j] <= level[i] } 5.If |S| >= level[i] then { 6.t := TAS(T[level[i]]); 7.If t=TRUE then// if we won TAS 8. return { value[j] | j of S }; } //if } //while } // write-and-snapshot 22 Simpler to understan d n-bounded implementation There exists unbounded concurrency wait-free implementation
23
Issues for unbounded concurrency write-and-snapshot 1.How does a process determine in which level to start its descent? 2.How does a process decide when to stop at some level and return from there? 3.How does a process that decides to stop at level L find out which processes are active in the levels below it, in order to return them as its immediate snapshot? 23 There exists an algorithm that solves these issues, and therefore implements unbounded concurrency write-and-snapshot(). We are going to use this unbounded concurrency write-and- snapshot() to implement unbounded concurrency F&A…
24
Outline: Introduction, refresh and definitions Wait-free stack implementation Snapshot objects Unbounded concurrency objects Summary 24
25
Unbounded concurrency F&A Shared variables: WS : write-and-snapshot object args: array[1,…] of registers, initially empty Fetch-and-add (k p ){//invoked by process P 1.args[P] := k p ; 2.S := WS.write-and-snapshot(); //unbounded concurrency WAS 3.return ∑ Q ∈ S,Q!=P (args[Q]) ; } //end of F&A 25 A process P announces its input. (line 1) P then obtains an atomic write-and-snapshot S p (line 2), and returns the sum of all inputs announced in S p (line 3).
26
Unbounded concurrency TAS There is an easy implementation of TAS from F&A, Therefore… 26
27
Unbounded concurrency STACK Push(x) { 1. i = F&A(range, 1); 2. items[i] = x; } 27 Shared Items: range: F&A object initialized to 1//index for the next push items: array [1…] of registers//items[0] = $ T: array [1…] of TAS object Pop() { 1. t = F&A(range, 0) - 1; 2. for i = t downto 1 3.X = items[i]; 4.If x != null then { 5. If TAS(T[i]) then return x; } // end if } // end for 6. return $; //indicator of empty stack } // end Pop Stack has an unbounded concurrency wait-free implementation from registers and 2-consensus objects
28
Outline: Introduction, refresh and definitions Wait-free stack implementation Snapshot objects Unbounded concurrency objects Summary 28
29
Summary We showed a wait-free stack implementation in n-bounded concurrency model, meaning that stack object is inside Common2, refuting the previous conjecture that such an implementation is impossible. We introduced an unbounded concurrency write-and-snapshot object, using which we easily got unbounded concurrency F&A object, using which we’ve also got unbounded concurrency TAS object. Back to our stack, the last discovery immediately makes our stack implementation an unbounded concurrency wait-free implementation from registers and 2-consensus objects. 29
30
Summary Common2 membership problem (whether every consensus power 2 object can be wait-free implemented from 2-consensus) remains open. The previous conjecture that a FIFO queue object cannot be implemented wait-free from Common2 objects, is not proven yet. Is there a natural object that is wait-free implementable from 2- consensus in the n-bounded concurrency model, but is not implementable for unbounded concurrency model? Our conjecture is that swap object is one such an object. 30 Open problems:
31
31 Thank you!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.