200 likes | 459 Views
Atomic Snapshots. data . Abstract Data Types. Abstract representation of data & set of methods ( operations ) for accessing it Implement u sing primitives on base objects . Correctness: Linearizability. [Herlihy & Wing, 1990]
E N D
data Abstract Data Types • Abstract representation of data & set of methods (operations) for accessing it • Implement using primitives on base objects Introduction
Correctness: Linearizability [Herlihy & Wing, 1990] • For every concurrent execution there is a sequential execution that • Contains the same operations • Is legal (obeys the specification of the ADTs) • Preserves the real-time order of non-overlapping operations • Each operation appears to takes effect instantaneously at some point between its invocation and its response (atomicity) Introduction
Atomic Snapshot • n components • Update a single component • Scan all the components “at once” (atomically) Provides an instantaneous view of the whole memory update scan v1,…,vn ok Introduction
Atomic Snapshot Algorithm [Afek, Attiya, Dolev, Gafni, Merritt, Shavit, JACM 1993] double collect Update(v,k) A[k] = v,seqi,i • Scan() • repeat • read A[1],…,A[n] • read A[1],…,A[n] • if equal • return A[1,…,n] • Linearize: • Updates with their writes • Scans inside the double collects Introduction
read A[1],…,A[n] read A[1],…,A[n] write A[j] Atomic Snapshot: Linearizability Double collect (read a set of values twice) If equal, there is no write between the collects • Assuming each write has a new value (seq#) Creates a “safe zone”, where the scan can be linearized Introduction
LivenessConditions • Wait-free: every operation completes within a finite number of (its own) steps • no starvation for mutex • Nonblocking: some operation completes within a finite number of (some other process) steps • deadlock-freedom for mutex • Obstruction-free: an operation (eventually) running solo completes within a finite number of (its own) steps • Also called solo termination wait-free nonblocking obstruction-free Introduction
Wait-free Atomic Snapshot [Afek, Attiya, Dolev, Gafni, Merritt, Shavit, JACM 1993] • Embed a scan within the Update. Update(v,k) V = scan A[k] = v,seqi,i,V • Scan() • repeat • read A[1],…,A[n] • read A[1],…,A[n] • if equal • return A[1,…,n] • else record diff • if twice pj • return Vj direct scan • Linearize: • Updates with their writes • Direct scans as before • Borrowed scans in place borrowedscan Introduction
embedded scan read A[j] read A[j] read A[j] read A[j] … … … … … … … … write A[j] write A[j] Atomic Snapshot: Borrowed Scans Interference by process pj And another one… • pjdoes a scan inbeteween Linearizing with the borrowed scan is OK. Introduction
Complexity of Atomic Snapshots • Scan needs O(n2) reads and writes, why? • Update needs O(n2) reads and writes 236755 (2013) 04: R/W simulations
O(nlogn) Atomic snapshots [Attiya, Rachman SIAM 1998] • n components • Scate- Update a single component and Scan all the components “at once” (atomically) Provides an instantaneous view of the whole memory scate v1,…,vn
One-shot Atomic Snapshot • Each processes execute at most one scate operation. • The size of a view is the number of non-empty entries. scate v1,…,vn
One-shot Atomic Snapshot • dominates, if for all , if then • unionof a set , denoted by is the view that dominates all views . scate v1,…,vn
The ClassifierProcedure Localknowledge 1,1,1 Classifier(K,Ii) Write Ii to Ri Read R1,…, Rn If |{R1,…, Rn}|>K then read R1,…, Rn return Oi= {R1,…, Rn} Else return Oi= Ii K=2 Lemma: The output view of a righty dominates the union of the lefties outputs. dominating knowledge righties lefties Original knowledge
Atomic Snapshot from Classifiers Classifier Classifier Classifier 1 3 n • Scate operation requires O(nlogn) operations on single-writer multireader registers.
Atomic Snapshot from Classifiers • Operations are ordered in the leaves : • Operations arriving at different leaves are comparable. • Operations arriving at the same leaf have exactly the same final knowledge. Scate(val) Si=(val) For j=1 to n currenti,1[j]=Sj v=root For l=1 to log(n) currenti,l+1=Classifier(label(v),currenti,l) if righty then v = v.right if lefty then v = v.left Return currenti,log(n)+1 Lemma: Let be a scate operation that passes through a node with level then Lemma : Let OP be the set of scate operations that pass through a node with level then |OP|
Linearization • The views returned by the scate operations are comparable and ordered at the leaves from left to right scan update 1 3 n