Common2 extended to stacks and unbound concurrency By:Yehuda Afek Eli Gafni Adam Morrison May 2007 Presentor: Dima Liahovitsky 1.

Slides:



Advertisements
Similar presentations
N-Consensus is the Second Strongest Object for N+1 Processes Eli Gafni UCLA Petr Kuznetsov Max Planck Institute for Software Systems.
Advertisements

A Completeness theorem for a class of synchronization objects Afek.Y, Weisberger.E, Weisman.H Presented by: Reut Schwartz.
1 © R. Guerraoui The Power of Registers Prof R. Guerraoui Distributed Programming Laboratory.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Mutual Exclusion By Shiran Mizrahi. Critical Section class Counter { private int value = 1; //counter starts at one public Counter(int c) { //constructor.
1 Parallel Parentheses Matching Plus Some Applications.
Universality of Consensus The Art of Multiprocessor Programming Spring 2007.
Prof. Jennifer Welch 1. FIFO Queue Example 2  Sequential specification of a FIFO queue:  operation with invocation enq(x) and response ack  operation.
CPSC 668Set 18: Wait-Free Simulations Beyond Registers1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
Data Structure (Part I) Stacks and Queues. Introduction to Stack An stack is a ordered list in which insertion and deletions are made at one end. –The.
ADT Stacks and Queues. Stack: Logical Level “An ordered group of homogeneous items or elements in which items are added and removed from only one end.”
Stack and Queue Dr. Bernard Chen Ph.D. University of Central Arkansas.
Common2 Extended to Stacks Adam Morrison joint with Eli Gafni Yehuda Afek.
Stacks, Queues, and Deques
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
Distributed Algorithms (22903) Lecturer: Danny Hendler Shared objects: linearizability, wait-freedom and simulations Most of this presentation is based.
Main Index Contents 11 Main Index Contents Model for a Queue Model for a Queue The Queue The Queue ADTQueue ADT (3 slides) Queue ADT Radix Sort Radix Sort.
What Can Be Implemented Anonymously ? Paper by Rachid Guerraui and Eric Ruppert Presentation by Amir Anter 1.
Stacks. 2 Outline and Reading The Stack ADT (§2.1.1) Array-based implementation (§2.1.1) Growable array-based stack (§1.5) Java.util.Stack class Java.util.Vector.
Part-B1 Stacks. Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations.
Part-B1 Stacks. Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations.
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
analysis, plug ‘n’ chug, & induction
Abstract Data Types (ADTs) and data structures: terminology and definitions A type is a collection of values. For example, the boolean type consists of.
Recursion Chapter 7 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
Simple Wait-Free Snapshots for Real-Time Systems with Sporadic Tasks Håkan Sundell Philippas Tsigas.
Linearizability By Mila Oren 1. Outline  Sequential and concurrent specifications.  Define linearizability (intuition and formal model).  Composability.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS Fall 2011 Prof. Jennifer Welch CSCE 668 Set 18: Wait-Free Simulations Beyond Registers 1.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 3 (26/01/2006) Instructor: Haifeng YU.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data.
Stacks. A stack is a data structure that holds a sequence of elements and stores and retrieves items in a last-in first- out manner (LIFO). This means.
1 Chapter 9 Synchronization Algorithms and Concurrent Programming Gadi Taubenfeld © 2014 Synchronization Algorithms and Concurrent Programming Synchronization.
1 Consensus Hierarchy Part 1. 2 Consensus in Shared Memory Consider processors in shared memory: which try to solve the consensus problem.
Wait-Free Consensus CPSC 661 Fall 2003 Supervised by: Lisa Higham Presented by: Wei Wei Zheng Nuha Kamaluddeen.
Queues Linear list. One end is called front. Other end is called rear. Additions are done at the rear only. Removals are made from the front only. FIFO.
1 Consensus Hierarchy Part 2. 2 FIFO (Queue) FIFO Object headtail.
Iterators ITI 1121 N. El Kadri. Motivation Given a (singly) linked-list implementation of the interface List, defined as follows, public interface List.
Asynchronous Exclusive Selection Bogdan Chlebus, U. Colorado Darek Kowalski, U. Liverpool.
Chapter 21 Asynchronous Network Computing with Process Failures By Sindhu Karthikeyan.
Distributed Algorithms (22903) Lecturer: Danny Hendler The wait-free hierarchy and the universality of consensus This presentation is based on the book.
CH 5 : STACKS, QUEUES, AND DEQUES ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Distributed Algorithms (22903) Lecturer: Danny Hendler The Atomic Snapshot Object The Renaming Problem This presentation is based on the book “Distributed.
An algorithm of Lock-free extensible hash table Yi Feng.
Data Structures Arrays and Lists Part 2 More List Operations.
1 Chapter 11 Global Properties (Distributed Termination)
Distributed Algorithms (22903) Lecturer: Danny Hendler Shared objects: linearizability, wait-freedom and simulations Most of this presentation is based.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Process Synchronization.
Unit VI.  C++ templates are a powerful mechanism for code reuse, as they enable the programmer to write code (classes as well as functions) that behaves.
1 © R. Guerraoui Set-Agreement (Generalizing Consensus) R. Guerraoui.
Distributed Algorithms (22903)
Stacks.
Stacks and Queues.
Distributed Algorithms (22903)
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Distributed Algorithms (22903)
Multicore programming
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Distributed Algorithms (22903)
Distributed Algorithms (22903)
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Distributed Algorithms (22903)
Deterministic Objects: Life Beyond Consensus
CS210- Lecture 3 Jun 6, 2005 Announcements
Yehuda Afek, Eli Daian, Eli Gafni, Giuliano Losa
Presentation transcript:

Common2 extended to stacks and unbound concurrency By:Yehuda Afek Eli Gafni Adam Morrison May 2007 Presentor: Dima Liahovitsky 1

Outline:  Introduction, refresh and definitions  Wait-free stack implementation  Snapshot objects  Unbounded concurrency objects  Summary 2

Refresh: TAS TAS object: boolean variable state, initally TRUE Test-and-set() v := state; state := false; return v; 3

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

Refresh: wait-freedom Definition: an algorithm is wait-free if a process invoking it will finish after a finite number of steps. 5

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

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

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

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

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

Outline:  Introduction, refresh and definitions  Wait-free stack implementation  Snapshot objects  Unbounded concurrency objects  Summary 11

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

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!

Wait-free STACK 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 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 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:

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

Outline:  Introduction, refresh and definitions  Wait-free stack implementation  Snapshot objects  Unbounded concurrency objects  Summary 18

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

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 Scan() starts here Scan() ends here one Possible snapshot returned from scan(): Not possible snapshots returned from scan():

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

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

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…

Outline:  Introduction, refresh and definitions  Wait-free stack implementation  Snapshot objects  Unbounded concurrency objects  Summary 24

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).

Unbounded concurrency TAS There is an easy implementation of TAS from F&A, Therefore… 26

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

Outline:  Introduction, refresh and definitions  Wait-free stack implementation  Snapshot objects  Unbounded concurrency objects  Summary 28

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

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 Thank you!