Presentation is loading. Please wait.

Presentation is loading. Please wait.

IBM T. J. Watson Research Center Conditions for Strong Synchronization Maged Michael IBM T J Watson Research Center Joint work with: Martin Vechev, Hagit.

Similar presentations


Presentation on theme: "IBM T. J. Watson Research Center Conditions for Strong Synchronization Maged Michael IBM T J Watson Research Center Joint work with: Martin Vechev, Hagit."— Presentation transcript:

1 IBM T. J. Watson Research Center Conditions for Strong Synchronization Maged Michael IBM T J Watson Research Center Joint work with: Martin Vechev, Hagit Attiya, Rachid Guerraoui, Danny Hendler, Petr Kuznetsov The Chemistry of Concurrent and Distributed Programming Mysore Park, February 16, 2011

2 2Maged Michael The Chemistry of Concurrent and Distributed Programming Motivation There are good algorithms with good features … except for the requirement of strong synchronization Are there conditions under which the avoidance of both RAW and AWAR is impossible? Atomic write after read (AWAR) Read after write order (RAW)

3 3Maged Michael The Chemistry of Concurrent and Distributed Programming Read After Write Order Write to a shared variable X followed by a read of a different shared variable Y (without an intervening write of Y by the same thread) flag[0] := true while flag[1]... Write X Read Y Modern multiprocessors may reorder the read before the write Write X RAW fence Read Y Entry section of Dekkers algorithm

4 4Maged Michael The Chemistry of Concurrent and Distributed Programming Atomic Write After Read A read of a shared variable followed by a write of some shared variable (possibly the same variable), where the read and the write are atomic CAS(X,expval,newval) atomically r := (X == expval) if r X := newval return r do oldval := X until CAS(X,oldval,oldval+1) return oldval Fetch and increment E.g., CAS, TAS, FAA, RMW operations.

5 5Maged Michael The Chemistry of Concurrent and Distributed Programming Strong Non-Commutativity A method m1 is strongly non-commutative if there exists a method m2 (possibly the same as m1), such that: –m1 influences m2, AND –m2 influences m1 Any linearizable implementation of a SNC method must contain strong synchronization

6 6Maged Michael The Chemistry of Concurrent and Distributed Programming Common Examples of SNC Methods Set –Add(v) : boolean // Returns true iff v was not in the set –Remove(v) : boolean // Returns true iff v was in the set LIFO Stack –Pop() : Value FIFO Queue –Dequeue() : Value CAS Data Type –CAS(expected,newval) : boolean Work Stealing –Take() : Task –Steal() : Task Counter –FetchAndAdd(v) : value

7 7Maged Michael The Chemistry of Concurrent and Distributed Programming Avoiding SNC: Idempotent Types –Non-deterministically, an operation may have no effect –No deterministic sequential specification –E.g., idempotent work stealing [PPoPP 2009] A task may be extracted more than once Conventional (non-idempotent) Take is SNC –SNC with Steal Idempotent Take is not SNC

8 8Maged Michael The Chemistry of Concurrent and Distributed Programming Avoiding SNC: Limited Concurrency –E.g., single-consumer FIFO queue Multi-consumer dequeue is SNC Single-consumer dequeue is not SNC

9 9Maged Michael The Chemistry of Concurrent and Distributed Programming Avoiding SNC: Limited API –E.g., Set Add without return value Set Add : boolean is SNC Set Add : void is not SNC –E.g., Counter Add without returning value FetchAndAdd : integer is SNC AtomicAdd : void is not SNC

10 10Maged Michael The Chemistry of Concurrent and Distributed Programming Implications Algorithm Design –Guidance on when avoiding RAW/AWAR is futile Hardware Design –Added motivation to lower overheads of RAW/AWAR API Design –Sometimes return values in APIs dictate RAW/AWAR Specifications and Correctness Conditions –Motivation to examine requirements of determinism and linearizability Formal Verification and Algorithm Synthesis –Avoid useless work on non-RAW/AWAR algorithms when RAW/AWAR is required

11 11Maged Michael The Chemistry of Concurrent and Distributed Programming SNC Executions (Ongoing) Adapting the definition of SNC to executions –Goal: Prove that strong synchronization is required for all SNC executions of SNC methods Examples: –Successful executions of TryLock –Successful executions of LIFO Stack Pop –Successful executions of CAS –Successful executions of FIFO Queue Dequeue –Successful executions of Work Stealing Take and Steal –(Successful) executions of FetchAndAdd –Successful executions of Set Add and Remove

12 12Maged Michael The Chemistry of Concurrent and Distributed Programming Summary When is it impossible to avoid both read-after-read (RAW) order and atomic write-after-read (AWAR ) operations? Strong non-commutativity Tradeoff between RAW/AWAR and relaxations in specification THANK YOU

13 13Maged Michael The Chemistry of Concurrent and Distributed Programming BACKUP

14 14Maged Michael The Chemistry of Concurrent and Distributed Programming Strong Non-Commutativity A method m1 is strongly non-commutative in a sequential specification Spec if there exists a method m2 (possibly the same as m1), and there exist histories base, s1, s2, s3, s4 such that: 1.s1 and s4 are complete invocations of m1 with entry(s1) = entry(s4) and exit(s1) exit(s4). 2.s2 and s3 are complete invocations of m2 with entry(s2) = entry(s3) and exit(s2) exit(s3). 3.proc(entry(s1)) proc(entry(s2)). 4.base is a complete sequential history in Spec. 5.base · s2 · s4 Spec. 6.base · s1 · s3 Spec.


Download ppt "IBM T. J. Watson Research Center Conditions for Strong Synchronization Maged Michael IBM T J Watson Research Center Joint work with: Martin Vechev, Hagit."

Similar presentations


Ads by Google