Proving linearizability & lock-freedom

Size: px
Start display at page:

Download "Proving linearizability & lock-freedom"

Transcription

1 Proving linearizability & lock-freedom Viktor Vafeiadis MPI-SWS

2 Michael & Scott non-blocking queue head tail X null

3 CAS compare & swap CAS (address, expectedvalue, newvalue) { atomic { if ( *address == expectedvalue ) { *address = newvalue; return true; else { return false; - A single hardware instruction on x86

4 Michael & Scott non-blocking queue head tail X null

5 Michael & Scott non-blocking queue head tail 4 null X null

6 Michael & Scott non-blocking queue head tail 4 null X 1 3 2

7 Michael & Scott non-blocking queue head tail 4 null X 1 3 2

8 Michael & Scott non-blocking queue head tail 4 null X 1 3 2

9 Enqueue & dequeue enqueue(v) { m = new Node(); m val = v; m next = null; while (true) { t = Q tail; n = tail next; if (Q tail tail) continue; if (n == null) { if (CAS(&t next,n,m)) break; else { CAS(&Q tail,t,n); CAS(&Q tail,t,n); Don t read the code! dequeue () { while (true) { h = Q head; t = Q tail; n = h next; if (Q tail t) continue; if (h == t) { if (n == null) return EMPTY; CAS(&Q tail,t,n); else { if (CAS(&Q head,h,n)) return n val;

10 RGSep actions (pre-/postcondition pairs) Summarize the shared state updates head tail head tail Enqueue A null A B null Dequeue head tail head tail A B A B Advance tail pointer head tail A B head tail A B

11 The actions of enqueue & dequeue enqueue(v) { m = new Node(); m val = Local v; m next updates = null; while (true) { t = Q tail; n = tail next; if (Q tail t) continue; if (n == null) { if (CAS(&t next,n,m)) ENQUEUE break; else { CAS(&Q tail,t,n); ADV. TAIL CAS(&Q tail,t,n); ADV. TAIL dequeue () { while (true) { h = Q head; t = Q tail; n = h next; if (Q tail t) continue; if (h == t) { if (n == null) return EMPTY; CAS(&Q tail,t,n); ADV. TAIL else { if (CAS(&Q head,h,n)) DEQUEUE return n val;

12 Length (first attempt) length() { num = 0; curr = Q head next; while (curr null) { num++; curr = curr next; return num; head tail X null

13 Length (second attempt) length() { num = 0; while (true) { t = Q tail; n = tail next; if (n == null) break; CAS(&Q tail,t,n); curr = Q head next; while (curr null) { num++; if (curr == t) break; curr = curr next; return num; Read Q tail, and ensure that Q tail next == null

14 Length (third attempt) length() { num = 0; do { h = Q head; while (true) { t = Q tail; n = tail next; if (n == null) break; CAS(&Q tail,t,n); while (h Q head); curr = h next; while (curr null) { num++; if (curr == t) break; curr = curr next; return num; Get a snapshot of Q head and Q tail and ensure that Q tail next==null.

15 Verification challenge Functional correctness (linearizability): Every method executes atomically and obeys a high-level specification VMCAI 09 CAV 10 Liveness properties, e.g. lock-freedom: At all times, some outstanding method call is guaranteed to terminate. POPL 09

16 Linearizability Every method executes atomically & obeys a functional correctness specification Shared variable: AQ enqueue(v) spec AQ := append(singleton(v), AQ); return 0; dequeue() spec if (AQ == empty) { return EMPTY; else { r := hd(aq); AQ := tl(aq); return r;

17 Linearizability & forward simulation Linearizability: The implementation (of every method) is a refinement of an atomic specification. Standard proof technique: forward simulation Abstract (spec) S abs S abs Concrete (impl) S conc S conc

18 Linearization points The implementation is a refinement of an atomic specification. abstract execution concrete execution linearization point (LP)

19 Linearization point of enqueue enqueue(v) { m := new Node(); m val := v; m next := null; while (true) { t := Q tail; n := tail next; if (Q tail tail) continue; if (n == null) { if (CAS(&t next,n,m)) break; else { CAS(&Q tail,t,n); CAS(&Q tail,t,n); Lin. Point (provided CAS succeeds)

20 Proof search for the LP? For each execution path of each method, choose a candidate LP Check whether it is a valid LP Does this work?

21 Proof search for the LP? For each execution path of each method, choose a candidate LP Check whether it is a valid LP Does this work? Not quite. 1. LPs can be conditional 2. LPs can be in the code of another thread

22 LP of dequeue, when it returns EMPTY dequeue () { while (true) { h := Q head; t := Q tail; n := h next; if (Q tail t) continue; if (h == t) { if (n == null) return EMPTY; CAS(&Q tail,t,n); else { if (CAS(&Q head,h,n)) return n val; LP provided this test fails, and the h==t test succeeds the n==null test succeeds Condition: prophecy(q tail t) h == t n == null

23 Key observation Method executions that logically modify the state have a simple LP. Method executions that do not logically modify the state often have a complex LP. So: Treat these two cases differently. Search for LPs of executions that logically modify the state; Do a non-constructive proof for executions that do not logically modify the state.

24 Basic LP validation Auxiliary variable: lres 1. At the entry to the function: lres := UNDEF; 2. At the candidate effectful LPs: assert(lres==undef); lres := method_spec(); 3. At the return points, check res == lres concrete result abstract result

25 Validating pure executions Auxiliary variable: can_return 1. At the entry to the function: i. can_return[i] := false; 2. At every point, add a pure LP checker : if (abs_method() has no side-effects) can_return[abs_method()] := true; 3. At the return points, check can_return[res] == true concrete result

26 For example... dequeue spec if (AQ == empty) { return EMPTY; else { r := hd(aq); AQ := tl(aq); return r; pure lin. checker if (AQ == empty) { can_return[empty] := true;

27 Enhanced LP validation Auxiliary variables: lres, can_return 1. At the entry to the function: lres := UNDEF; i. can_return[i] := false; 2. At the candidate effectful LPs: assert(lres==undef); lres := abs_method() 3. Add pure checkers at every program point: assign can_return[i] := true if method_spec returns i & has no side-effects. 4. At the return points, check (res==lres) (lres==undef can_return[res])

28 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); -INF INF null contains(5) add(5); remove(3); remove(5)

29 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); -INF INF null c contains(5) add(5); remove(3); remove(5)

30 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); -INF INF null c contains(5) add(5); remove(3); remove(5)

31 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); -INF INF null c contains(5) add(5); remove(3); remove(5)

32 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); -INF INF null c contains(5) add(5); remove(3); remove(5)

33 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); 3 -INF INF null c contains(5) add(5); remove(3); remove(5)

34 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); 3 5 -INF 1 7 +INF null c contains(5) add(5); remove(3); remove(5)

35 LPs in other threads add (e) {... remove (e) {... contains (e) { c := H; while (c val < e) c := c next; return (c val == e); 3 5 -INF 1 7 +INF null c contains(5) add(5); remove(3); remove(5)

36 Enhanced LP validation Auxiliary variables: lres, can_return 1. At the entry to the function: lres := UNDEF; i. can_return[i] := false; 2. At the candidate effectful LPs: assert(lres==undef); lres := abs_method() 3. Add pure checkers at every program point (incl. program points in other threads) 4. At the return points, check (res==lres) (lres==undef can_return[res])

37 Implementation CAVE: Concurrent Algorithm VErifier - RGSep action inference [VMCAI 2010] - Shape-value abstract domain [VMCAI 2009] - Algorithm for proving linearizability [CAV 2010]

38 Experiments (linearizability) Algorithm Lines Ops Eff Pure LpO Time (s) DCAS stack Treiber stack M&S two-lock queue M&S non-blocking queue DGLM non-blocking queue Pessimistic set V&Y DCAS-based set ORVYY lazy set Lines: lines of code: excluding comments & specs Ops: # methods Eff: # effectful methods Pure: # methods with a pure execution path LpO: # linearization points in other threads

39 Non-blocking liveness properties Proving that non-blocking algorithms don t block [Gotsman, Cook, Parkinson, Vafeiadis, POPL 09]

40 Non-blocking liveness properties Wait-freedom: Every thread is guaranteed to complete its operation. Lock-freedom: [Provided that there is at least one thread scheduled,] some thread is guaranteed to complete its operation. Obstruction-freedom: Every thread is guaranteed to complete its operation, provided it eventually executes in isolation. (No assumptions about the scheduler.)

41 Lock-freedom reduces to termination A library is lock-free iff init(); n { if(?) enqueue(?) else if(?) dequeue() else length() terminates when n(=the number of threads) is bounded.

42 Reminder: enqueue & dequeue enqueue(v) { m = new Node(); m val = v; m next = null; while (true) { t = Q tail; n = tail next; if (Q tail t) continue; if (n == null) { if (CAS(&t next,n,m)) ENQUEUE break; else { CAS(&Q tail,t,n); ADV. TAIL CAS(&Q tail,t,n); ADV. TAIL dequeue () { while (true) { h = Q head; t = Q tail; n = h next; if (Q tail t) continue; if (h == t) { if (n == null) return EMPTY; CAS(&Q tail,t,n); ADV. TAIL else { if (CAS(&Q head,h,n)) DEQUEUE return n val;

43 Guarantee-strengthening I don t execute ENQUEUE or DEQUEUE infinitely often I don t execute ENQUEUE or DEQUEUE infinitely often I don t execute ENQUEUE, DEQUEUE, or ADV.TAIL infinitely often I don t execute ENQUEUE, DEQUEUE, or ADV.TAIL infinitely often I terminate I terminate

44 Guarantee-strengthening First, do action inference Then, iteratively eliminate actions

45 Guarantee-strengthening First, do action inference (ENQUEUE DEQUEUE ADV.TAIL) Then, iteratively eliminate actions

46 Guarantee-strengthening First, do action inference (ENQUEUE DEQUEUE ADV.TAIL) Then, iteratively eliminate actions ENQUEUE DEQUEUE ADV.TAIL Terminates

47 Guarantee-strengthening First, do action inference (ENQUEUE DEQUEUE ADV.TAIL) Then, iteratively eliminate actions ENQUEUE DEQUEUE ADV.TAIL Terminates

48 Guarantee-strengthening First, do action inference (ENQUEUE DEQUEUE ADV.TAIL) Then, iteratively eliminate actions ENQUEUE DEQUEUE ADV.TAIL Terminates ENQUEUE DEQUEUE ADV.TAIL Terminates

49 Guarantee-strengthening First, do action inference (ENQUEUE DEQUEUE ADV.TAIL) Then, iteratively eliminate actions ENQUEUE DEQUEUE ADV.TAIL Terminates ENQUEUE DEQUEUE ADV.TAIL Terminates ENQUEUE DEQUEUE ADV.TAIL Terminates

Automatically Proving Linearizability

Automatically Proving Linearizability Automatically Proving Linearizability Viktor Vafeiadis University of Cambridge Abstract. This paper presents a practical automatic verification procedure for proving linearizability (i.e., atomicity and

More information

Technical Report. Automatically proving linearizability. Viktor Vafeiadis. Number 778. September Computer Laboratory

Technical Report. Automatically proving linearizability. Viktor Vafeiadis. Number 778. September Computer Laboratory Technical Report UCAM-CL-TR-778 ISSN 1476-2986 Number 778 Computer Laboratory Automatically proving linearizability Viktor Vafeiadis September 2016 15 JJ Thomson Avenue Cambridge CB3 0FD United Kingdom

More information

Proving liveness. Alexey Gotsman IMDEA Software Institute

Proving liveness. Alexey Gotsman IMDEA Software Institute Proving liveness Alexey Gotsman IMDEA Software Institute Safety properties Ensure bad things don t happen: - the program will not commit a memory safety fault - it will not release a lock it does not hold

More information

Non-blocking Array-based Algorithms for Stacks and Queues!

Non-blocking Array-based Algorithms for Stacks and Queues! Non-blocking Array-based Algorithms for Stacks and Queues! Niloufar Shafiei! Department of Computer Science and Engineering York University ICDCN 09 Outline! Introduction! Stack algorithm! Queue algorithm!

More information

Proving Lock-Freedom Easily and Automatically

Proving Lock-Freedom Easily and Automatically Proving Lock-Freedom Easily and Automatically Xiao Jia Wei Li Shanghai Jiao Tong University Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) Abstract Lock-freedom is a liveness property

More information

Non-blocking Array-based Algorithms for Stacks and Queues. Niloufar Shafiei

Non-blocking Array-based Algorithms for Stacks and Queues. Niloufar Shafiei Non-blocking Array-based Algorithms for Stacks and Queues Niloufar Shafiei Outline Introduction Concurrent stacks and queues Contributions New algorithms New algorithms using bounded counter values Correctness

More information

A Non-Blocking Concurrent Queue Algorithm

A Non-Blocking Concurrent Queue Algorithm A Non-Blocking Concurrent Queue Algorithm Bruno Didot bruno.didot@epfl.ch June 2012 Abstract This report presents a new non-blocking concurrent FIFO queue backed by an unrolled linked list. Enqueue and

More information

Lindsay Groves, Simon Doherty. Mark Moir, Victor Luchangco

Lindsay Groves, Simon Doherty. Mark Moir, Victor Luchangco Lindsay Groves, Simon Doherty Victoria University of Wellington Mark Moir, Victor Luchangco Sun Microsystems, Boston (FORTE, Madrid, September, 2004) Lock-based concurrency doesn t scale Lock-free/non-blocking

More information

CS510 Concurrent Systems. Jonathan Walpole

CS510 Concurrent Systems. Jonathan Walpole CS510 Concurrent Systems Jonathan Walpole Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms utline Background Non-Blocking Queue Algorithm Two Lock Concurrent Queue Algorithm

More information

Design of Concurrent and Distributed Data Structures

Design of Concurrent and Distributed Data Structures METIS Spring School, Agadir, Morocco, May 2015 Design of Concurrent and Distributed Data Structures Christoph Kirsch University of Salzburg Joint work with M. Dodds, A. Haas, T.A. Henzinger, A. Holzer,

More information

Linearizability Checking: Reductions to State Reachability

Linearizability Checking: Reductions to State Reachability Linearizability Checking: Reductions to State Reachability Ahmed Bouajjani Univ Paris Diderot - Paris 7 Joint work with Michael Emmi Constantin Enea Jad Hamza Bell Labs, Nokia Univ Paris Diderot EPFL IMS-NUS,

More information

Shape-Value Abstraction for Verifying Linearizability

Shape-Value Abstraction for Verifying Linearizability Shape-Value Abstraction for Verifying Linearizability Viktor Vafeiadis Microsoft Research, Cambridge, UK Abstract. This paper presents a novel abstraction for heap-allocated data structures that keeps

More information

Cache-Aware Lock-Free Queues for Multiple Producers/Consumers and Weak Memory Consistency

Cache-Aware Lock-Free Queues for Multiple Producers/Consumers and Weak Memory Consistency Cache-Aware Lock-Free Queues for Multiple Producers/Consumers and Weak Memory Consistency Anders Gidenstam Håkan Sundell Philippas Tsigas School of business and informatics University of Borås Distributed

More information

CONCURRENT LIBRARIES. Correctness Criteria, Verification

CONCURRENT LIBRARIES. Correctness Criteria, Verification CONCURRENT LIBRARIES Correctness Criteria, Verification Verification Ingredients Specifying a Library: φ Implementing a Library: L Verifying a Library implementation: L φ The History of an Object Object

More information

Lock-free Serializable Transactions

Lock-free Serializable Transactions Lock-free Serializable Transactions Jeff Napper jmn@cs.utexas.edu Lorenzo Alvisi lorenzo@cs.utexas.edu Laboratory for Advanced Systems Research Department of Computer Science The University of Texas at

More information

Solo-Valency and the Cost of Coordination

Solo-Valency and the Cost of Coordination Solo-Valency and the Cost of Coordination Danny Hendler Nir Shavit November 21, 2007 Abstract This paper introduces solo-valency, a variation on the valency proof technique originated by Fischer, Lynch,

More information

CS 241 Honors Concurrent Data Structures

CS 241 Honors Concurrent Data Structures CS 241 Honors Concurrent Data Structures Bhuvan Venkatesh University of Illinois Urbana Champaign March 27, 2018 CS 241 Course Staff (UIUC) Lock Free Data Structures March 27, 2018 1 / 43 What to go over

More information

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 31 October 2012

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 31 October 2012 NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY Tim Harris, 31 October 2012 Lecture 6 Linearizability Lock-free progress properties Queues Reducing contention Explicit memory management Linearizability

More information

Linearizability of Persistent Memory Objects

Linearizability of Persistent Memory Objects Linearizability of Persistent Memory Objects Michael L. Scott Joint work with Joseph Izraelevitz & Hammurabi Mendes www.cs.rochester.edu/research/synchronization/ Workshop on the Theory of Transactional

More information

Lock free Algorithm for Multi-core architecture. SDY Corporation Hiromasa Kanda SDY

Lock free Algorithm for Multi-core architecture. SDY Corporation Hiromasa Kanda SDY Lock free Algorithm for Multi-core architecture Corporation Hiromasa Kanda 1.Introduction Background needed Multi-Thread Problem of Multi-Thread program What's Lock free? Lock-free algorithm performance

More information

FIFO Queue Synchronization

FIFO Queue Synchronization FIFO Queue Synchronization by Moshe Hoffman A Thesis submitted for the degree Master of Computer Science Supervised by Professor Nir Shavit School of Computer Science Tel Aviv University July 2008 CONTENTS

More information

Synthesis for Concurrency

Synthesis for Concurrency Synthesis for Concurrency Martin Vechev ETH Zurich (joint work with Eran Yahav, Greta Yorsh) 1 Concurrency is Everywhere Unreliable Concurrency is Everywhere 2003 Northeast Blackout concurrency error triggers

More information

The Wait-Free Hierarchy

The Wait-Free Hierarchy Jennifer L. Welch References 1 M. Herlihy, Wait-Free Synchronization, ACM TOPLAS, 13(1):124-149 (1991) M. Fischer, N. Lynch, and M. Paterson, Impossibility of Distributed Consensus with One Faulty Process,

More information

Experience with Model Checking Linearizability

Experience with Model Checking Linearizability Experience with Model Checking Linearizability Martin Vechev, Eran Yahav, and Greta Yorsh IBM T.J. Watson Research Center Non-blocking concurrent algorithms offer significant performance advantages, but

More information

BQ: A Lock-Free Queue with Batching

BQ: A Lock-Free Queue with Batching BQ: A Lock-Free Queue with Batching Gal Milman Technion, Israel galy@cs.technion.ac.il Alex Kogan Oracle Labs, USA alex.kogan@oracle.com Yossi Lev Oracle Labs, USA levyossi@icloud.com ABSTRACT Victor Luchangco

More information

LOCKLESS ALGORITHMS. Lockless Algorithms. CAS based algorithms stack order linked list

LOCKLESS ALGORITHMS. Lockless Algorithms. CAS based algorithms stack order linked list Lockless Algorithms CAS based algorithms stack order linked list CS4021/4521 2017 jones@scss.tcd.ie School of Computer Science and Statistics, Trinity College Dublin 2-Jan-18 1 Obstruction, Lock and Wait

More information

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 17 November 2017

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 17 November 2017 NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY Tim Harris, 17 November 2017 Lecture 7 Linearizability Lock-free progress properties Hashtables and skip-lists Queues Reducing contention Explicit

More information

Atomic Variables & Nonblocking Synchronization

Atomic Variables & Nonblocking Synchronization Atomic Variables & Nonblocking Synchronization CMSC 433 Fall 2014 Michael Hicks (with some slides due to Rance Cleaveland) A Locking Counter public final class Counter { private long value = 0; public

More information

Building Efficient Concurrent Graph Object through Composition of List-based Set

Building Efficient Concurrent Graph Object through Composition of List-based Set Building Efficient Concurrent Graph Object through Composition of List-based Set Sathya Peri Muktikanta Sa Nandini Singhal Department of Computer Science & Engineering Indian Institute of Technology Hyderabad

More information

Checking Program Properties with ESC/Java

Checking Program Properties with ESC/Java Checking Program Properties with ESC/Java 17-654/17-765 Analysis of Software Artifacts Jonathan Aldrich 1 ESC/Java A checker for Java programs Finds null pointers, array dereferences Checks Hoare logic

More information

6.852: Distributed Algorithms Fall, Class 21

6.852: Distributed Algorithms Fall, Class 21 6.852: Distributed Algorithms Fall, 2009 Class 21 Today s plan Wait-free synchronization. The wait-free consensus hierarchy Universality of consensus Reading: [Herlihy, Wait-free synchronization] (Another

More information

Lecture 21: Transactional Memory. Topics: consistency model recap, introduction to transactional memory

Lecture 21: Transactional Memory. Topics: consistency model recap, introduction to transactional memory Lecture 21: Transactional Memory Topics: consistency model recap, introduction to transactional memory 1 Example Programs Initially, A = B = 0 P1 P2 A = 1 B = 1 if (B == 0) if (A == 0) critical section

More information

Lock Oscillation: Boosting the Performance of Concurrent Data Structures

Lock Oscillation: Boosting the Performance of Concurrent Data Structures Lock Oscillation: Boosting the Performance of Concurrent Data Structures Panagiota Fatourou FORTH ICS & University of Crete Nikolaos D. Kallimanis FORTH ICS The Multicore Era The dominance of Multicore

More information

Parallelism and Data Synchronization

Parallelism and Data Synchronization Project 5 Parallelism and Data Synchronization Out: In class on Tuesday, 10 Nov 2009 Due: 10am on Friday, 20 Nov 2009 In this project, you will be focusing on the theoretical side of parallelism and data

More information

Static Analysis of Atomicity for Algorithms Using Non-Blocking Synchronization

Static Analysis of Atomicity for Algorithms Using Non-Blocking Synchronization Static Analysis of Atomicity for Algorithms Using Non-Blocking Synchronization Liqiang Wang and Scott D. Stoller Abstract In concurrent programming, non-blocking synchronization is very efficient but difficult

More information

Mutual Exclusion Algorithms with Constant RMR Complexity and Wait-Free Exit Code

Mutual Exclusion Algorithms with Constant RMR Complexity and Wait-Free Exit Code Mutual Exclusion Algorithms with Constant RMR Complexity and Wait-Free Exit Code Rotem Dvir 1 and Gadi Taubenfeld 2 1 The Interdisciplinary Center, P.O.Box 167, Herzliya 46150, Israel rotem.dvir@gmail.com

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Schedule of Lectures Jan 17/19: Interprocedural DFA

More information

Time and Space Lower Bounds for Implementations Using k-cas

Time and Space Lower Bounds for Implementations Using k-cas Time and Space Lower Bounds for Implementations Using k-cas Hagit Attiya Danny Hendler September 12, 2006 Abstract This paper presents lower bounds on the time- and space-complexity of implementations

More information

Lock-free algorithms for Kotlin coroutines. It is all about scalability Presented at SPTCC 2017 /Roman JetBrains

Lock-free algorithms for Kotlin coroutines. It is all about scalability Presented at SPTCC 2017 /Roman JetBrains Lock-free algorithms for Kotlin coroutines It is all about scalability resented at TCC 2017 /Roman Elizarov @ JetBrains peaker: Roman Elizarov 16+ years experience reviously developed high-perf trading

More information

Unit 6: Indeterminate Computation

Unit 6: Indeterminate Computation Unit 6: Indeterminate Computation Martha A. Kim October 6, 2013 Introduction Until now, we have considered parallelizations of sequential programs. The parallelizations were deemed safe if the parallel

More information

Lock-Free Techniques for Concurrent Access to Shared Objects

Lock-Free Techniques for Concurrent Access to Shared Objects This is a revised version of the previously published paper. It includes a contribution from Shahar Frank who raised a problem with the fifo-pop algorithm. Revised version date: sept. 30 2003. Lock-Free

More information

Fine-grained synchronization & lock-free programming

Fine-grained synchronization & lock-free programming Lecture 17: Fine-grained synchronization & lock-free programming Parallel Computer Architecture and Programming CMU 15-418/15-618, Spring 2016 Tunes Minnie the Moocher Robbie Williams (Swings Both Ways)

More information

Lecture 7: Transactional Memory Intro. Topics: introduction to transactional memory, lazy implementation

Lecture 7: Transactional Memory Intro. Topics: introduction to transactional memory, lazy implementation Lecture 7: Transactional Memory Intro Topics: introduction to transactional memory, lazy implementation 1 Transactions New paradigm to simplify programming instead of lock-unlock, use transaction begin-end

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Summer 1 2015) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

Local Linearizability

Local Linearizability Local Linearizability joint work with: Andreas Haas Andreas Holzer Michael Lippautz Ali Sezgin Tom Henzinger Christoph Kirsch Hannes Payer Helmut Veith Concurrent Data Structures Correctness and Performance

More information

Linearizability with ownership transfer

Linearizability with ownership transfer Linearizability with ownership transfer Hongseok Yang University of Oxford Joint work with Alexey Gotsman (IMDEA Software Institute, Spain) Concurrent libraries Encapsulate efficient concurrent algorithms.

More information

Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems

Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems Håkan Sundell Philippas Tsigas Outline Synchronization Methods Priority Queues Concurrent Priority Queues Lock-Free Algorithm: Problems

More information

Lock-Free and Practical Doubly Linked List-Based Deques using Single-Word Compare-And-Swap

Lock-Free and Practical Doubly Linked List-Based Deques using Single-Word Compare-And-Swap Lock-Free and Practical Doubly Linked List-Based Deques using Single-Word Compare-And-Swap Håkan Sundell Philippas Tsigas OPODIS 2004: The 8th International Conference on Principles of Distributed Systems

More information

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 21 November 2014

NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY. Tim Harris, 21 November 2014 NON-BLOCKING DATA STRUCTURES AND TRANSACTIONAL MEMORY Tim Harris, 21 November 2014 Lecture 7 Linearizability Lock-free progress properties Queues Reducing contention Explicit memory management Linearizability

More information

A Program Logic for Concurrent Objects under Fair Scheduling

A Program Logic for Concurrent Objects under Fair Scheduling A Program Logic for Concurrent Objects under Fair Scheduling Hongjin Liang Xinyu Feng School of Computer Science and Technology & Suzhou Institute for Advanced Study University of Science and Technology

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

Having a BLAST with SLAM

Having a BLAST with SLAM Having a BLAST with SLAM Meeting, CSCI 555, Fall 20 Announcements Homework 0 due Sat Questions? Move Tue office hours to -5pm 2 Software Model Checking via Counterexample Guided Abstraction Refinement

More information

Midterm Exam Amy Murphy 6 March 2002

Midterm Exam Amy Murphy 6 March 2002 University of Rochester Midterm Exam Amy Murphy 6 March 2002 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your

More information

Indistinguishability: Friend and Foe of Concurrent Data Structures. Hagit Attiya CS, Technion

Indistinguishability: Friend and Foe of Concurrent Data Structures. Hagit Attiya CS, Technion Indistinguishability: Friend and Foe of Concurrent Data Structures Hagit Attiya CS, Technion Uncertainty is a main obstacle for designing correct applications in concurrent systems Formally captured by

More information

A simple correctness proof of the MCS contention-free lock. Theodore Johnson. Krishna Harathi. University of Florida. Abstract

A simple correctness proof of the MCS contention-free lock. Theodore Johnson. Krishna Harathi. University of Florida. Abstract A simple correctness proof of the MCS contention-free lock Theodore Johnson Krishna Harathi Computer and Information Sciences Department University of Florida Abstract Mellor-Crummey and Scott present

More information

AST: scalable synchronization Supervisors guide 2002

AST: scalable synchronization Supervisors guide 2002 AST: scalable synchronization Supervisors guide 00 tim.harris@cl.cam.ac.uk These are some notes about the topics that I intended the questions to draw on. Do let me know if you find the questions unclear

More information

C2TLA+: A translator from C to TLA+

C2TLA+: A translator from C to TLA+ C2TLA+: A translator from C to TLA+ Amira METHNI (CEA/CNAM) Matthieu LEMERRE (CEA) Belgacem BEN HEDIA (CEA) Serge HADDAD (ENS Cachan) Kamel BARKAOUI (CNAM) www.cea.fr June 3, 2014 Outline Cliquez pour

More information

Linked Lists: The Role of Locking. Erez Petrank Technion

Linked Lists: The Role of Locking. Erez Petrank Technion Linked Lists: The Role of Locking Erez Petrank Technion Why Data Structures? Concurrent Data Structures are building blocks Used as libraries Construction principles apply broadly This Lecture Designing

More information

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL Whatever can go wrong will go wrong. attributed to Edward A. Murphy Murphy was an optimist. authors of lock-free programs LOCK FREE KERNEL 251 Literature Maurice Herlihy and Nir Shavit. The Art of Multiprocessor

More information

Proving Linearizability Using Partial Orders

Proving Linearizability Using Partial Orders Proving Linearizability Using Partial Orders Artem Khyzha 1, Mike Dodds 2, Alexey Gotsman 1, and Matthew Parkinson 3 1 IMDEA Software Institute, Madrid, Spain 2 University of York, UK 3 Microsoft Research

More information

Last class: Today: CPU Scheduling. Start synchronization

Last class: Today: CPU Scheduling. Start synchronization Last class: CPU Scheduling Today: Start synchronization Synchronization Processes (threads) share resources. How do processes share resources? How do threads share resources? It is important to coordinate

More information

Ownership of a queue for practical lock-free scheduling

Ownership of a queue for practical lock-free scheduling Ownership of a queue for practical lock-free scheduling Lincoln Quirk May 4, 2008 Abstract We consider the problem of scheduling tasks in a multiprocessor. Tasks cannot always be scheduled independently

More information

Lecture 9: Multiprocessor OSs & Synchronization. CSC 469H1F Fall 2006 Angela Demke Brown

Lecture 9: Multiprocessor OSs & Synchronization. CSC 469H1F Fall 2006 Angela Demke Brown Lecture 9: Multiprocessor OSs & Synchronization CSC 469H1F Fall 2006 Angela Demke Brown The Problem Coordinated management of shared resources Resources may be accessed by multiple threads Need to control

More information

Verifying Concurrent Data Structures by Simulation

Verifying Concurrent Data Structures by Simulation Electronic Notes in Theoretical Computer Science 137 (2005) 93 110 www.elsevier.com/locate/entcs Verifying Concurrent Data Structures by Simulation Robert Colvin 1,2 Simon Doherty 3 Lindsay Groves 4 School

More information

Lecture Notes on Queues

Lecture Notes on Queues Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning Lecture 9 September 25, 2012 1 Introduction In this lecture we introduce queues as a data structure and linked lists

More information

Hoare logic. A proof system for separation logic. Introduction. Separation logic

Hoare logic. A proof system for separation logic. Introduction. Separation logic Introduction Hoare logic Lecture 6: Examples in separation logic In the previous lecture, we saw how reasoning about pointers in Hoare logic was problematic, which motivated introducing separation logic.

More information

On the Importance of Synchronization Primitives with Low Consensus Numbers

On the Importance of Synchronization Primitives with Low Consensus Numbers On the Importance of Synchronization Primitives with Low Consensus Numbers ABSTRACT Pankaj Khanchandani ETH Zurich kpankaj@ethz.ch The consensus number of a synchronization primitive is the maximum number

More information

Fine-grained synchronization & lock-free data structures

Fine-grained synchronization & lock-free data structures Lecture 19: Fine-grained synchronization & lock-free data structures Parallel Computer Architecture and Programming Redo Exam statistics Example: a sorted linked list struct Node { int value; Node* next;

More information

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs 3.

Whatever can go wrong will go wrong. attributed to Edward A. Murphy. Murphy was an optimist. authors of lock-free programs 3. Whatever can go wrong will go wrong. attributed to Edward A. Murphy Murphy was an optimist. authors of lock-free programs 3. LOCK FREE KERNEL 309 Literature Maurice Herlihy and Nir Shavit. The Art of Multiprocessor

More information

Programming Paradigms for Concurrency Lecture 3 Concurrent Objects

Programming Paradigms for Concurrency Lecture 3 Concurrent Objects Programming Paradigms for Concurrency Lecture 3 Concurrent Objects Based on companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Modified by Thomas Wies New York University

More information

Having a BLAST with SLAM

Having a BLAST with SLAM Announcements Having a BLAST with SLAM Meetings -, CSCI 7, Fall 00 Moodle problems? Blog problems? Looked at the syllabus on the website? in program analysis Microsoft uses and distributes the Static Driver

More information

The Universality of Consensus

The Universality of Consensus Chapter 6 The Universality of Consensus 6.1 Introduction In the previous chapter, we considered a simple technique for proving statements of the form there is no wait-free implementation of X by Y. We

More information

Computer Science First Exams Pseudocode Standard Data Structures Examples of Pseudocode

Computer Science First Exams Pseudocode Standard Data Structures Examples of Pseudocode Computer Science First Exams 2014 Pseudocode Standard Data Structures Examples of Pseudocode Candidates are NOT permitted to bring copies of this document to their examinations. 1 Introduction The purpose

More information

Operating Systems CMPSC 473. Synchronization February 21, Lecture 11 Instructor: Trent Jaeger

Operating Systems CMPSC 473. Synchronization February 21, Lecture 11 Instructor: Trent Jaeger Operating Systems CMPSC 473 Synchronization February 21, 2008 - Lecture 11 Instructor: Trent Jaeger Last class: CPU Scheduling Today: A little more scheduling Start synchronization Little s Law Evaluating

More information

The Rule of Constancy(Derived Frame Rule)

The Rule of Constancy(Derived Frame Rule) The Rule of Constancy(Derived Frame Rule) The following derived rule is used on the next slide The rule of constancy {P } C {Q} {P R} C {Q R} where no variable assigned to in C occurs in R Outline of derivation

More information

Research on the Implementation of MPI on Multicore Architectures

Research on the Implementation of MPI on Multicore Architectures Research on the Implementation of MPI on Multicore Architectures Pengqi Cheng Department of Computer Science & Technology, Tshinghua University, Beijing, China chengpq@gmail.com Yan Gu Department of Computer

More information

Lecture Notes on Queues

Lecture Notes on Queues Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning and Jamie Morgenstern Lecture 9 February 14, 2012 1 Introduction In this lecture we introduce queues as a data structure

More information

Part 3: Beyond Reduction

Part 3: Beyond Reduction Lightweight Analyses For Reliable Concurrency Part 3: Beyond Reduction Stephen Freund Williams College joint work with Cormac Flanagan (UCSC), Shaz Qadeer (MSR) Busy Acquire Busy Acquire void busy_acquire()

More information

Software Model Checking. Xiangyu Zhang

Software Model Checking. Xiangyu Zhang Software Model Checking Xiangyu Zhang Symbolic Software Model Checking CS510 S o f t w a r e E n g i n e e r i n g Symbolic analysis explicitly explores individual paths, encodes and resolves path conditions

More information

k-abortable Objects: Progress under High Contention

k-abortable Objects: Progress under High Contention k-abortable Objects: Progress under High Contention Naama Ben-David 1, David Yu Cheng Chan 2, Vassos Hadzilacos 2, and Sam Toueg 2 Carnegie Mellon University 1 University of Toronto 2 Outline Background

More information

Having a BLAST with SLAM

Having a BLAST with SLAM Having a BLAST with SLAM # #2 Topic: Software Model Checking via Counter-Example Guided Abstraction Refinement There are easily two dozen SLAM/BLAST/MAGIC papers; I will skim. #3 SLAM Overview INPUT: Program

More information

The Relative Power of Synchronization Methods

The Relative Power of Synchronization Methods Chapter 5 The Relative Power of Synchronization Methods So far, we have been addressing questions of the form: Given objects X and Y, is there a wait-free implementation of X from one or more instances

More information

Abstraction Functions and Representation Invariants

Abstraction Functions and Representation Invariants Abstraction Functions and Representation Invariants Prof. Clarkson Fall 2017 Today s music: In C by Terry Riley A2 Implement a text adventure game engine, and write your own adventure Experience with lists,

More information

Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999

Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999 Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999 Name: Please initial the bottom left corner of each page. This is an open-book exam. You have 50 minutes to

More information

Lecture 21: Transactional Memory. Topics: Hardware TM basics, different implementations

Lecture 21: Transactional Memory. Topics: Hardware TM basics, different implementations Lecture 21: Transactional Memory Topics: Hardware TM basics, different implementations 1 Transactions New paradigm to simplify programming instead of lock-unlock, use transaction begin-end locks are blocking,

More information

CMPT 125: Practice Midterm Answer Key

CMPT 125: Practice Midterm Answer Key CMPT 125, Spring 2017, Surrey Practice Midterm Answer Key Page 1 of 6 CMPT 125: Practice Midterm Answer Key Linked Lists Suppose you have a singly-linked list whose nodes are defined like this: struct

More information

An efficient Unbounded Lock-Free Queue for Multi-Core Systems

An efficient Unbounded Lock-Free Queue for Multi-Core Systems An efficient Unbounded Lock-Free Queue for Multi-Core Systems Authors: Marco Aldinucci 1, Marco Danelutto 2, Peter Kilpatrick 3, Massimiliano Meneghin 4 and Massimo Torquati 2 1 Computer Science Dept.

More information

UNIVERSITY REGULATIONS

UNIVERSITY REGULATIONS CPSC 221: Algorithms and Data Structures Midterm Exam, 2013 February 15 Name: Student ID: Signature: Section (circle one): MWF(201) TTh(202) You have 60 minutes to solve the 5 problems on this exam. A

More information

Lock-Free Concurrent Data Structures, CAS and the ABA-Problem

Lock-Free Concurrent Data Structures, CAS and the ABA-Problem Lock-Free Concurrent Data Structures, CAS and the ABA-Problem 2 Motivation Today almost all PCs and Laptops have a multi-core ( e.g. quad-core ) processor Dr. Wolfgang Koch using SMP (symmetric multiprocessing)

More information

Data Structure Advanced

Data Structure Advanced Data Structure Advanced 1. Is it possible to find a loop in a Linked list? a. Possilbe at O(n) b. Not possible c. Possible at O(n^2) only d. Depends on the position of loop Solution: a. Possible at O(n)

More information

Runtime Checking for Program Verification Systems

Runtime Checking for Program Verification Systems Runtime Checking for Program Verification Systems Karen Zee, Viktor Kuncak, and Martin Rinard MIT CSAIL Tuesday, March 13, 2007 Workshop on Runtime Verification 1 Background Jahob program verification

More information

Distributed Systems Synchronization. Marcus Völp 2007

Distributed Systems Synchronization. Marcus Völp 2007 Distributed Systems Synchronization Marcus Völp 2007 1 Purpose of this Lecture Synchronization Locking Analysis / Comparison Distributed Operating Systems 2007 Marcus Völp 2 Overview Introduction Hardware

More information

Formal Specification and Verification

Formal Specification and Verification Formal Specification and Verification Introduction to Promela Bernhard Beckert Based on a lecture by Wolfgang Ahrendt and Reiner Hähnle at Chalmers University, Göteborg Formal Specification and Verification:

More information

Finding heap-bounds for hardware synthesis

Finding heap-bounds for hardware synthesis Finding heap-bounds for hardware synthesis B. Cook + A. Gupta # S. Magill* A. Rybalchenko # J. Simsa* S. Singh + V. Vafeiadis + *CMU # MPI-SWS + MSR Coding hardware in advanced languages Use of advanced

More information

Alternation for Termination

Alternation for Termination Alternation for Termination William R. Harris 1, Akash Lal 2, Aditya V. Nori 2, and Sriram K. Rajamani 2 1 University of Wisconsin; Madison, WI, USA 2 Microsoft Research India; Bangalore, India Abstract.

More information

An Almost Non- Blocking Stack

An Almost Non- Blocking Stack An Almost Non- Blocking Stack Hans-J. Boehm HP Labs 2004 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Motivation Update data structures

More information

Having a BLAST with SLAM

Having a BLAST with SLAM Having a BLAST with SLAM # #2 Topic: Software Model Checking via Counter-Example Guided Abstraction Refinement There are easily two dozen SLAM/BLAST/MAGIC papers; I will skim. #3 SLAM Overview INPUT: Program

More information

Stack as an ADT. COMP 182: Data Structures and Program Design Lecture Slides 8. Stack as an Idea

Stack as an ADT. COMP 182: Data Structures and Program Design Lecture Slides 8. Stack as an Idea Stack as an ADT COMP 182: Data Structures and Program Design Lecture Slides 8 John Noga CSU Northridge April 9, 200 public interface Stack { public boolean push(ourthing ot); public OurThing (); public

More information

Lecture: Consistency Models, TM. Topics: consistency models, TM intro (Section 5.6)

Lecture: Consistency Models, TM. Topics: consistency models, TM intro (Section 5.6) Lecture: Consistency Models, TM Topics: consistency models, TM intro (Section 5.6) 1 Coherence Vs. Consistency Recall that coherence guarantees (i) that a write will eventually be seen by other processors,

More information

6.852: Distributed Algorithms Fall, Class 15

6.852: Distributed Algorithms Fall, Class 15 6.852: Distributed Algorithms Fall, 2009 Class 15 Today s plan z z z z z Pragmatic issues for shared-memory multiprocessors Practical mutual exclusion algorithms Test-and-set locks Ticket locks Queue locks

More information