Presentation is loading. Please wait.

Presentation is loading. Please wait.

Atomic Snapshots. Abstract Data Types Abstract representation of data & set of methods (operations) for accessing it Implement using primitives on base.

Similar presentations


Presentation on theme: "Atomic Snapshots. Abstract Data Types Abstract representation of data & set of methods (operations) for accessing it Implement using primitives on base."— Presentation transcript:

1 Atomic Snapshots

2 Abstract Data Types Abstract representation of data & set of methods (operations) for accessing it Implement using primitives on base objects 236825Introduction2 data

3 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) 236825Introduction3

4 Atomic Snapshot n components Update a single component Scan all the components “at once” (atomically) Provides an instantaneous view of the whole memory 236825Introduction4 update ok scan v 1,…,v n

5 236825Introduction5 Atomic Snapshot Algorithm Update(v,k) A[k] =  v,seq i, i  Scan() repeat read A[1],…,A[n] if equal return A[1,…,n] Linearize: Updates with their writes Scans inside the double collects double collect [Afek, Attiya, Dolev, Gafni, Merritt, Shavit, JACM 1993]

6 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 236825Introduction6 read A[1],…,A[n] write A[j]

7 Liveness Conditions 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 236825Introduction7

8 Wait-free Atomic Snapshot [Afek, Attiya, Dolev, Gafni, Merritt, Shavit, JACM 1993] Embed a scan within the Update. 236825Introduction8 Update(v,k) V = scan A[k] =  v,seq i, i,V  Scan() repeat read A[1],…,A[n] if equal return A[1,…,n] else record diff if twice p j return V j Linearize: Updates with their writes Direct scans as before Borrowed scans in place Linearize: Updates with their writes Direct scans as before Borrowed scans in place direct scan borrowed scan

9 Atomic Snapshot: Borrowed Scans Interference by process p j And another one…  p j does a scan inbeteween Linearizing with the borrowed scan is OK. 236825Introduction9 write A[j] read A[j] …… …… embedded scan write A[j] read A[j] …… ……

10 © Hagit Attiya236755 (2013) 04: R/W simulations10 Complexity of Atomic Snapshots Scan needs O(n 2 ) reads and writes, why? Update needs O(n 2 ) reads and writes

11 O(nlogn) Atomic snapshots n components Scate - Update a single component and Scan all the components “at once” (atomically) Provides an instantaneous view of the whole memory 11 scate v 1,…,v n [Attiya, Rachman SIAM 1998]

12 One-shot Atomic Snapshot 12 scate v 1,…,v n

13 One-shot Atomic Snapshot 13 scate v 1,…,v n

14 The Classifier Procedure 14 K=2 1,1,1 lefties righties Local knowledge Original knowledge dominating knowledge Lemma: The output view of a righty dominates the union of the lefties outputs.

15 Atomic Snapshot from Classifiers 15 1 3 Scate operation requires O(nlogn) operations on single-writer multireader registers.

16 Atomic Snapshot from Classifiers Scate(val) S i =(val) For j=1 to n current i,1 [j]=S j v=root For l=1 to log(n) current i,l+1 =Classifier(label(v),current i,l ) if righty then v = v.right if lefty then v = v.left Return current i,log(n)+1 16 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.

17 Linearization 17 1 3 scan update The views returned by the scate operations are comparable and ordered at the leaves from left to right


Download ppt "Atomic Snapshots. Abstract Data Types Abstract representation of data & set of methods (operations) for accessing it Implement using primitives on base."

Similar presentations


Ads by Google