Semantic Atomicity for Multithreaded Programs!

Size: px
Start display at page:

Download "Semantic Atomicity for Multithreaded Programs!"

Transcription

1 P A R A L L E L C O M P U T I N G L A B O R A T O R Y Semantic Atomicity for Multithreaded Programs! Jacob Burnim, George Necula, Koushik Sen! Parallel Computing Laboratory! University of California, Berkeley!

2 Parallel Correctness is Hard! Difficult to write correct parallel software.! " Key: Interference between parallel threads.! " Atomicity freedom from harmful interference; a fundamental parallel correctness property.!! Today: Semantic atomicity.! " Specifying atomicity with respect to userdefined, semantic equivalence.! " Efficiently testing such specifications.! " Overall Goal: Lightweight, useful specs to help programmers find and fix parallelism bugs.! 2

3 Outline! Overview + Motivation!! Background: Atomicity!! Specifying Semantic Atomicity!! Testing Semantic Atomicity!! Experimental Evaluation!! Conclusion! 3

4 Background: Atomicity! Atomicity a non-interference property.! " Block of code is atomic if it behaves as if executed all-at-once and without interruption.! " Interference from other threads is benign cannot change overall program behavior.! 4

5 Background: Atomicity! Atomicity a non-interference property.! " Block of code is atomic if it behaves as if executed all-at-once and without interruption.! int bal = 0;! deposit(int a) {! int t = bal;! bal = t + a;! }! }! Atomic specification.! Programmer intends that this code is atomic.! Want to check specification.! Is the code actually atomic?! 5

6 Background: Atomicity! Atomicity a non-interference property.! " Block of code is atomic if it behaves as if executed all-at-once and without interruption.! Thread 1:! Thread 2:! int bal = 0;! deposit(int a) {! int t = bal;! bal = t + a;! }! }! deposit(10)! t = 0! bal = 10! deposit(5)! t = 0! bal = 5! Atomicity specification does not hold.! 6

7 Background: Atomicity! Atomicity a non-interference property.! " Block of code is atomic if it behaves as if executed all-at-once and without interruption. int bal = 0;! deposit(int a) {! int t = bal;! while (!CAS(&bal, t, t+a))! t = bal;! }! }! With CAS, updates to balance are atomic.! Atomicity specification does hold.! 7

8 Background: Atomicity! Formally: Two semantics for a program P with specified atomic blocks.! " Interleaved: Threads interleave normally.! Initial State s 0! interleaved execution E Final State s 1! " Serial: When one thread opens an atomic block, no other thread runs until it closes.! Initial State s 0! serial execution E Final State s 1! 8

9 Background: Atomicity! Formally, program P is atomic iff:! " For all interleaved executions E yielding s 1, there exists a serial E yielding an identical final state.! Initial State s 0! interleaved executions serial execution! Final State s 1! Final State s 1! q.equals(q )! s 1 == s 1! 9

10 Outline! Overview!! Background: Atomicity!! Specifying Semantic Atomicity!! Testing Semantic Atomicity!! Experimental Evaluation!! Conclusion! 10

11 Motivating Example ConcurrentLinkedQueue q;! q.add(1); q.add(1);! Thread 1: Thread {! q.remove(1); q.remove(1);! } }!! Michael & Scott non-blocking queue, in the Java standard library!! Internally, a linked list with lazy deletion.! 11

12 Motivating Example Thread 1: Thread {! q.remove(1); q.remove(1);! } }!! In any serial execution:! remove(1)! head:! null! 1! 1! head:! null! 1! remove(1)! head:! null! 12

13 Motivating Example Thread 1: Thread {! q.remove(1); q.remove(1);! } }!! But in an interleaved execution:! head:! null! 1! 1! remove(1)! remove(1)! head:! null! null! 13

14 Motivating Example Thread 1: Thread {! q.remove(1); q.remove(1);! } }!! Traditional atomicity requires:! null! null! Initial State s 0! interleaved executions serial execution! Final State s 1! Final State s 1! q.equals(q )! s 1 == s 1! 14

15 Motivating Example Thread 1: Thread {! q.remove(1); q.remove(1);! } }!! Traditional atomicity requires:! null! null! Initial State s 0! interleaved executions serial execution! Final State s 1! Final State s 1!! q.equals(q )! s 1 == s 1! null! 15

16 Motivating Example Thread 1: Thread {! q.remove(1); q.remove(1);! } }!! Traditional atomicity requires:! Initial State s 0! Replace with user-defined semantic equivalence.! null! null! interleaved executions serial execution! Final State s 1! Final State s 1!! q.equals(q )! s 1 == s 1! null! 16

17 Semantic Atomicity Initial State s 0! Thread 1: Thread {! q.remove(1); q.remove(1);! } }! Replace with user-defined semantic equivalence.! interleaved executions serial execution! Final State s 1! null! Final State s 1! null! "(s, s 1 1 #) q.equals(q )! null! 17

18 Semantic Atomicity Example Thread 1: Thread {! q.remove(1); q.remove(1);! } }! Atomicity predicate: q.equals(q )! Initial State s 0! interleaved executions serial execution! Final State s 1! Final State s 1! "(s, s 1 1 #) q.equals(q )! 18

19 Bridge Predicates Thread 1: Thread {! q.remove(1); q.remove(1);! } }! Atomicity predicate: q.equals(q )! Bridge predicate.!! Burnim, Sen, Asserting and Checking Determinism for Multithreaded Programs, FSE 2009, CACM 2010.! 19

20 Atomicity vs. Determinism! Semantic Atomicity:! Initial State s 0! ` interleaved executions serial execution! Final State s 1! Final State s 1! "(s, s 1 1 #)! Semantic Determinism:! Initial State s 0! ` interleaved executions interleaved executions! Final State s 1! Final State s 1! "(s, s 1 1 #) 20

21 Semantic Atomicity Example int bal = 0;! int conflicts = 0;! deposit(int a) {! int t = bal;! while (!CAS(&bal, t, t+a)) {! t = bal;! conflicts += 1;! }! }! }! Atomicity predicate: bal == bal! With CAS, updates to balance are atomic.! Performance counter of # of CAS failures.! 21

22 Semantic Atomicity Example ConcurrentList list;! Thread 1: Thread {!......! list.add(1); list.add(3);!......! list.add(2); list.add(4);! } }! Atomicity predicate: eqsets(list,list )!! If list is [1,3,2,4], an atomicity violation?! " User must specify intended atomicity.! 22

23 Outline! Introduction + Motivation!! Background: Atomicity!! Specifying Semantic Atomicity!! Testing Semantic Atomicity!! Experimental Evaluation!! Conclusion! 23

24 Testing Semantic Atomicity! Interleaved run E is semantically atomic " E " w.r.t. iff there exists a serial run s.t.:! " The final states of E, E " satisfy "(s 1, s 1 #).! E : s 0 A! B! B! A! C! D! E! D! E! s 1 Is semantically atomic w/ respect to?! E " 24

25 Testing Semantic Atomicity! Interleaved run E is semantically atomic " E " w.r.t. iff there exists a serial run s.t.:! " The final states of E, E " satisfy "(s 1, s 1 #).! E : s 0 A! B! B! A! C! D! E! D! E! s 1 E " : s 0 A! B! C! D! E! s 1 " "(s 1, s 1 #)? E " : s 0 A! C! B! D! E! s 1 " "(s 1, s 1 #)? E " : s 0 B! A! F! G! H! D! s 1 " "(s 1, s 1 #)?! 25

26 Testing Semantic Atomicity! Interleaved run E is semantically atomic w.r.t. Infeasible iff there to try exists all serial a serial executions.! " run E " s.t.:! " The final Can states we restrict of E, E " this satisfy search?! "(s 1, s 1 #).! E : s 0 A! B! B! A! C! D! E! D! E! s 1 E " : s 0 E " : s 0 E " : s 0 A! B! C! D! E! A! C! B! D! E! B! A! F! G! H! D!! s 1 " s 1 " s 1 " 26

27 Testing Semantic Atomicity 1. The final states of, satisfy.! E E " E E " "(s 1, s 1 #) 2. and execute the same atomic blocks.! E : s 0 A! B! B! A! C! D! E! D! E! s 1 E " : s 0 E " : s 0 E " : s 0 A! B! C! D! E! A! C! B! D! E! B! A!! F! G! H! D!! s 1 " s 1 " s 1 " 27

28 Testing Semantic Atomicity 1. The final states of, satisfy.! E E " E E " 2. and execute the same atomic blocks.! 3. Non-overlapping atomic blocks appear in the same order in and.! E E " "(s 1, s 1 #) E : s 0 A! B! B! A! C! D! E! D! E! s 1 E " : s 0 E " : s 0 E " : s 0 A! B! C! D! E!! A! C! B! D! E!! B! A! F! G! H! D!! s 1 " s 1 " s 1 " 28

29 Semantic Serializability! Def: Interleaved run E is semantically serializable iff exists a serial run E " s.t.:! 1. The final states of E, E " satisfy "(s 1, s 1 # ).! 2. E and E " execute the same atomic blocks.! E : s 0 A! B! B! A! C! D! E! D! E! s 1 E " : s 0 E " : s 0 E " : s 0 A! B! C! D! E! A! C! B! D! E! B! A!! F! G! H! D! s 1 " s 1 " s 1 " 29

30 Semantic Strict Serializability! Def: Interleaved E is semantically strictly serializable iff exists a serial run E " s.t.:! 1. The final states of E, E " satisfy "(s 1, s 1 #).! 2. E and E " execute the same atomic blocks.! 3. Non-overlapping atomic blocks appear in the same order in and.! E E " E : s 0 A! B! B! A! C! D! E! D! E! s 1 E " : s 0 E " : s 0 A! B! C! D! E!! A! C! B! D! E! s 1 " s 1 " 30

31 Semantic Strict Serializability! Def: Interleaved E is semantically strictly serializable iff exists a serial run E " s.t.:! 1. The final states of E, E " satisfy "(s 1, s 1 #).! 2. E and E " execute the same atomic blocks.! 3. Non-overlapping atomic blocks appear in the same order in and.! E E " E has N blocks, with K overlapping.! ==>! Can check semantic strict serializability by examining K! serial runs.! 31

32 Testing Semantic Atomicity! To test atomicity of program P:! " Systematically/randomly generate executions E with K overlapping atomic blocks.! " For each E, report a violation if not semantically strictly serializable.!! Small Scope Hypothesis: Can find bugs with small # of overlapping atomic blocks.! 32

33 Outline! Introduction + Motivation!! Background: Atomicity!! Specifying Semantic Atomicity!! Testing Semantic Atomicity!! Experimental Evaluation!! Conclusion! 33

34 Experimental Evaluation! Wrote semantic atomicity specs for several Java benchmarks.! " Concurrent data structures and parallel apps.!! Setup: For each benchmark:! " Generate random interleaved runs, with one atomic block interrupted by 4 others.! " Check semantic strict serializability of each.! " To compare, also check conflict-serializability.! 34

35 Experimental Results I Benchmark! LoC! Test Runs! Semantic Atomicity Violations! Runs! Static Blocks! Strict Atomicity! Violations! Runs! Static! Blocks! JDK LinkedQueue! ! 7 2! 7! 4! JDK SkipListMap! ! 6 2! 7! 4! JDK CwArrayList! ! 0 0! 0! 0! lock-free list! ! 57 1! 57! 2! lazy list-based set! ! 0 0! 0! 2! 35

36 Experimental Results II Benchmark! LoC! Test Runs! Semantic Atomicity Violations! Runs! Static Blocks! Strict Atomicity! Violations! Runs! Static Blocks! PJ pi! ! 5 1! 5! 1! PJ keysearch! ! 0 0! 0! 0! PJ fractal! ! 0 0! 0! 0! PJ phylogenetic! ! 27 1! 27! 2! Application benchmarks from Parallel Java Library (Kaminsky 2007), use ~15000 LoC from PJ library.! 36

37 JDK Atomicity Bug ConcurrentLinkedQueue q;! q.add(1); q.add(2);! Thread 1: Thread {! {! } sz = { }! q.add(3);! }! Atomic with respect to:! q.equals(q ) (sz == sz )!! Not atomic: q.size() can return sz=3.! 37

38 Semantic Atomicity Bug II parallel-for (t in trees) {! cost = compute_cost(t);! synchronized (min_cost) {! min_cost = min(min_cost, cost);! }! if (cost == min_cost) {! min_tree = t;! }! }! } Atomic with respect to:! min_tree.equals(min_tree )! (min_cost == min_cost )! Updates to min_tree not synchronized.! 38

39 Outline! Introduction + Motivation!! Background: Atomicity!! Specifying Semantic Atomicity!! Testing Semantic Atomicity!! Experimental Evaluation!! Conclusion! 39

40 Conclusion! Semantic atomicity.! " Generalization for capturing high-level noninterference properties of real, complex code.! " Testing via strict serializability.! " Found several unknown atomicity errors.!! Overall Goal: Lightweight specifications for parallel correctness.! " Easy for programmers to write.! " With testing, effective in finding real bugs.! " Determinism [CACMʼ10,ICSEʻ10], NDSeq [PLDI ʻ11]! 40

41 P A R A L L E L C O M P U T I N G L A B O R A T O R Y Questions?! 41

NDSeq: Runtime Checking for Nondeterministic Sequential Specs of Parallel Correctness

NDSeq: Runtime Checking for Nondeterministic Sequential Specs of Parallel Correctness EECS Electrical Engineering and Computer Sciences P A R A L L E L C O M P U T I N G L A B O R A T O R Y NDSeq: Runtime Checking for Nondeterministic Sequential Specs of Parallel Correctness Jacob Burnim,

More information

NDSeq: Runtime Checking for Nondeterministic Sequential Specifications of Parallel Correctness

NDSeq: Runtime Checking for Nondeterministic Sequential Specifications of Parallel Correctness NDSeq: Runtime Checking for Nondeterministic Sequential Specifications of Parallel Correctness Jacob Burnim Tayfun Elmas George Necula Koushik Sen Department of Electrical Engineering and Computer Sciences,

More information

DETERMIN: Inferring Likely Deterministic Specifications of Multithreaded Programs

DETERMIN: Inferring Likely Deterministic Specifications of Multithreaded Programs DETERMIN: Inferring Likely Deterministic Specifications of Multithreaded Programs Jacob Burnim EECS Department UC Berkeley, USA jburnim@cs.berkeley.edu Koushik Sen EECS Department UC Berkeley, USA ksen@cs.berkeley.edu

More information

A Serializability Violation Detector for Shared-Memory Server Programs

A Serializability Violation Detector for Shared-Memory Server Programs A Serializability Violation Detector for Shared-Memory Server Programs Min Xu Rastislav Bodík Mark Hill University of Wisconsin Madison University of California, Berkeley Serializability Violation Detector:

More information

Atomicity for Reliable Concurrent Software. Race Conditions. Motivations for Atomicity. Race Conditions. Race Conditions. 1. Beyond Race Conditions

Atomicity for Reliable Concurrent Software. Race Conditions. Motivations for Atomicity. Race Conditions. Race Conditions. 1. Beyond Race Conditions Towards Reliable Multithreaded Software Atomicity for Reliable Concurrent Software Cormac Flanagan UC Santa Cruz Joint work with Stephen Freund Shaz Qadeer Microsoft Research 1 Multithreaded software increasingly

More information

A Causality-Based Runtime Check for (Rollback) Atomicity

A Causality-Based Runtime Check for (Rollback) Atomicity A Causality-Based Runtime Check for (Rollback) Atomicity Serdar Tasiran Koc University Istanbul, Turkey Tayfun Elmas Koc University Istanbul, Turkey RV 2007 March 13, 2007 Outline This paper: Define rollback

More information

Cooperative Concurrency for a Multicore World

Cooperative Concurrency for a Multicore World Cooperative Concurrency for a Multicore World Stephen Freund Williams College Cormac Flanagan, Tim Disney, Caitlin Sadowski, Jaeheon Yi, UC Santa Cruz Controlling Thread Interference: #1 Manually x = 0;

More information

Hybrid Static-Dynamic Analysis for Statically Bounded Region Serializability

Hybrid Static-Dynamic Analysis for Statically Bounded Region Serializability Hybrid Static-Dynamic Analysis for Statically Bounded Region Serializability Aritra Sengupta, Swarnendu Biswas, Minjia Zhang, Michael D. Bond and Milind Kulkarni ASPLOS 2015, ISTANBUL, TURKEY Programming

More information

BERKELEY PAR LAB. UPC-THRILLE Demo. Chang-Seo Park

BERKELEY PAR LAB. UPC-THRILLE Demo. Chang-Seo Park BERKELEY PAR LAB UPC-THRILLE Demo Chang-Seo Park 1 Correctness Group Highlights Active Testing for Java, C, and UPC Practical, easy-to-use tools for finding bugs, with sophisticated program analysis internally

More information

Maximal Causality Reduction for TSO and PSO. Shiyou Huang Jeff Huang Parasol Lab, Texas A&M University

Maximal Causality Reduction for TSO and PSO. Shiyou Huang Jeff Huang Parasol Lab, Texas A&M University Maximal Causality Reduction for TSO and PSO Shiyou Huang Jeff Huang huangsy@tamu.edu Parasol Lab, Texas A&M University 1 A Real PSO Bug $12 million loss of equipment curpos = new Point(1,2); class Point

More information

Types for Precise Thread Interference

Types for Precise Thread Interference Types for Precise Thread Interference Jaeheon Yi, Tim Disney, Cormac Flanagan UC Santa Cruz Stephen Freund Williams College October 23, 2011 2 Multiple Threads Single Thread is a non-atomic read-modify-write

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

Active Testing for Concurrent Programs

Active Testing for Concurrent Programs Active Testing for Concurrent Programs Pallavi Joshi Mayur Naik Chang-Seo Park Koushik Sen 1/8/2009 ParLab Retreat ParLab, UC Berkeley Intel Research Overview Checking correctness of concurrent programs

More information

Active Testing for Concurrent Programs

Active Testing for Concurrent Programs Active Testing for Concurrent Programs Pallavi Joshi, Mayur Naik, Chang-Seo Park, Koushik Sen 12/30/2008 ROPAS Seminar ParLab, UC Berkeley Intel Research Overview ParLab The Parallel Computing Laboratory

More information

Tom Ball Sebastian Burckhardt Madan Musuvathi Microsoft Research

Tom Ball Sebastian Burckhardt Madan Musuvathi Microsoft Research Tom Ball (tball@microsoft.com) Sebastian Burckhardt (sburckha@microsoft.com) Madan Musuvathi (madanm@microsoft.com) Microsoft Research P&C Parallelism Concurrency Performance Speedup Responsiveness Correctness

More information

Fully Automatic and Precise Detection of Thread Safety Violations

Fully Automatic and Precise Detection of Thread Safety Violations Fully Automatic and Precise Detection of Thread Safety Violations Michael Pradel and Thomas R. Gross Department of Computer Science ETH Zurich 1 Motivation Thread-safe classes: Building blocks for concurrent

More information

CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1

CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1 CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1 1 University of California, Berkeley, USA {pallavi,parkcs,ksen}@eecs.berkeley.edu

More information

Berkeley Parlab P A R A L L E L C O M P U T I N G L A B O R A T O R Y

Berkeley Parlab P A R A L L E L C O M P U T I N G L A B O R A T O R Y EECS Electrical Engineering and Computer Sciences Berkeley Parlab P A R A L L E L C O M P U T I N G L A B O R A T O R Y CONCURRIT: Tes&ng Concurrent Programs with Programmable State- Space Explora&on (A

More information

Asserting and Checking Determinism for Multithreaded Programs

Asserting and Checking Determinism for Multithreaded Programs Asserting and Checking Determinism for Multithreaded rograms Jacob Burnim EECS Department, UC Berkeley, CA, USA jburnim@cs.berkeley.edu Koushik Sen EECS Department, UC Berkeley, CA, USA ksen@cs.berkeley.edu

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 Parameterized Type System for Race-Free Java Programs

A Parameterized Type System for Race-Free Java Programs A Parameterized Type System for Race-Free Java Programs Chandrasekhar Boyapati Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology {chandra, rinard@lcs.mit.edu Data races

More information

Synchronization. Announcements. Concurrent Programs. Race Conditions. Race Conditions 11/9/17. Purpose of this lecture. A8 released today, Due: 11/21

Synchronization. Announcements. Concurrent Programs. Race Conditions. Race Conditions 11/9/17. Purpose of this lecture. A8 released today, Due: 11/21 Announcements Synchronization A8 released today, Due: 11/21 Late deadline is after Thanksgiving You can use your A6/A7 solutions or ours A7 correctness scores have been posted Next week's recitation will

More information

Toward Efficient Strong Memory Model Support for the Java Platform via Hybrid Synchronization

Toward Efficient Strong Memory Model Support for the Java Platform via Hybrid Synchronization Toward Efficient Strong Memory Model Support for the Java Platform via Hybrid Synchronization Aritra Sengupta, Man Cao, Michael D. Bond and Milind Kulkarni 1 PPPJ 2015, Melbourne, Florida, USA Programming

More information

Foundations of the C++ Concurrency Memory Model

Foundations of the C++ Concurrency Memory Model Foundations of the C++ Concurrency Memory Model John Mellor-Crummey and Karthik Murthy Department of Computer Science Rice University johnmc@rice.edu COMP 522 27 September 2016 Before C++ Memory Model

More information

Concurrent Objects and Linearizability

Concurrent Objects and Linearizability Chapter 3 Concurrent Objects and Linearizability 3.1 Specifying Objects An object in languages such as Java and C++ is a container for data. Each object provides a set of methods that are the only way

More information

6/16/2010 Correctness Criteria for Parallelism & Concurrency 1 CORRECTNESS CRITERIA FOR CONCURRENCY & PARALLELISM

6/16/2010 Correctness Criteria for Parallelism & Concurrency 1 CORRECTNESS CRITERIA FOR CONCURRENCY & PARALLELISM 6/16/2010 Correctness Criteria for Parallelism & Concurrency 1 CORRECTNESS CRITERIA FOR CONCURRENCY & PARALLELISM 6/16/2010 Correctness Criteria for Parallelism & Concurrency 2 Contracts Correctness for

More information

Efficient Data Race Detection for Unified Parallel C

Efficient Data Race Detection for Unified Parallel C P A R A L L E L C O M P U T I N G L A B O R A T O R Y Efficient Data Race Detection for Unified Parallel C ParLab Winter Retreat 1/14/2011" Costin Iancu, LBL" Nick Jalbert, UC Berkeley" Chang-Seo Park,

More information

The New Java Technology Memory Model

The New Java Technology Memory Model The New Java Technology Memory Model java.sun.com/javaone/sf Jeremy Manson and William Pugh http://www.cs.umd.edu/~pugh 1 Audience Assume you are familiar with basics of Java technology-based threads (

More information

Legato: Bounded Region Serializability Using Commodity Hardware Transactional Memory. Aritra Sengupta Man Cao Michael D. Bond and Milind Kulkarni

Legato: Bounded Region Serializability Using Commodity Hardware Transactional Memory. Aritra Sengupta Man Cao Michael D. Bond and Milind Kulkarni Legato: Bounded Region Serializability Using Commodity Hardware al Memory Aritra Sengupta Man Cao Michael D. Bond and Milind Kulkarni 1 Programming Language Semantics? Data Races C++ no guarantee of semantics

More information

High-Level Small-Step Operational Semantics for Software Transactions

High-Level Small-Step Operational Semantics for Software Transactions High-Level Small-Step Operational Semantics for Software Transactions Katherine F. Moore Dan Grossman The University of Washington Motivating Our Approach Operational Semantics Model key programming-language

More information

DoubleChecker: Efficient Sound and Precise Atomicity Checking

DoubleChecker: Efficient Sound and Precise Atomicity Checking DoubleChecker: Efficient Sound and Precise Atomicity Checking Swarnendu Biswas, Jipeng Huang, Aritra Sengupta, and Michael D. Bond The Ohio State University PLDI 2014 Impact of Concurrency Bugs Impact

More information

the complexity of predicting atomicity violations

the complexity of predicting atomicity violations the complexity of predicting atomicity violations Azadeh Farzan Univ of Toronto P. Madhusudan Univ of Illinois at Urbana Champaign. Motivation: Interleaving explosion problem Testing is the main technique

More information

Atomicity via Source-to-Source Translation

Atomicity via Source-to-Source Translation Atomicity via Source-to-Source Translation Benjamin Hindman Dan Grossman University of Washington 22 October 2006 Atomic An easier-to-use and harder-to-implement primitive void deposit(int x){ synchronized(this){

More information

Synchronization Lecture 23 Fall 2017

Synchronization Lecture 23 Fall 2017 Synchronization Lecture 23 Fall 2017 Announcements A8 released today, Due: 11/21 Late deadline is after Thanksgiving You can use your A6/A7 solutions or ours A7 correctness scores have been posted Next

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

The Java Memory Model

The Java Memory Model Jeremy Manson 1, William Pugh 1, and Sarita Adve 2 1 University of Maryland 2 University of Illinois at Urbana-Champaign Presented by John Fisher-Ogden November 22, 2005 Outline Introduction Sequential

More information

Java Memory Model. Jian Cao. Department of Electrical and Computer Engineering Rice University. Sep 22, 2016

Java Memory Model. Jian Cao. Department of Electrical and Computer Engineering Rice University. Sep 22, 2016 Java Memory Model Jian Cao Department of Electrical and Computer Engineering Rice University Sep 22, 2016 Content Introduction Java synchronization mechanism Double-checked locking Out-of-Thin-Air violation

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

CSE 160 Lecture 7. C++11 threads C++11 memory model

CSE 160 Lecture 7. C++11 threads C++11 memory model CSE 160 Lecture 7 C++11 threads C++11 memory model Today s lecture C++ threads The C++11 Memory model 2013 Scott B. Baden / CSE 160 / Winter 2013 2 C++11 Threads Via , C++ supports a threading

More information

Transactions. Concurrency. Consistency ACID. Modeling transactions. Transactions and Concurrency Control

Transactions. Concurrency. Consistency ACID. Modeling transactions. Transactions and Concurrency Control COS 597D: Principles of Database and Information Systems Transactions and Concurrency Control Transactions Unit of update/change Viewed as indivisible Database can be inconsistent during transaction Add

More information

Data Races and Locks

Data Races and Locks Data Races and Locks Unit 2.a 1 Acknowledgments Authored by Sebastian Burckhardt, MSR Redmond 9/20/2010 2 Concepts Correctness Concept Atomicity Violations Data Races Data-Race-Free Discipline Immutability

More information

Chapter 5 Asynchronous Concurrent Execution

Chapter 5 Asynchronous Concurrent Execution Chapter 5 Asynchronous Concurrent Execution Outline 5.1 Introduction 5.2 Mutual Exclusion 5.2.1 Java Multithreading Case Study 5.2.2 Critical Sections 5.2.3 Mutual Exclusion Primitives 5.3 Implementing

More information

Production-Run Software Failure Diagnosis via Hardware Performance Counters. Joy Arulraj, Po-Chun Chang, Guoliang Jin and Shan Lu

Production-Run Software Failure Diagnosis via Hardware Performance Counters. Joy Arulraj, Po-Chun Chang, Guoliang Jin and Shan Lu Production-Run Software Failure Diagnosis via Hardware Performance Counters Joy Arulraj, Po-Chun Chang, Guoliang Jin and Shan Lu Motivation Software inevitably fails on production machines These failures

More information

C++ Memory Model. Don t believe everything you read (from shared memory)

C++ Memory Model. Don t believe everything you read (from shared memory) C++ Memory Model Don t believe everything you read (from shared memory) The Plan Why multithreading is hard Warm-up example Sequential Consistency Races and fences The happens-before relation The DRF guarantee

More information

Duet: Static Analysis for Unbounded Parallelism

Duet: Static Analysis for Unbounded Parallelism Duet: Static Analysis for Unbounded Parallelism Azadeh Farzan and Zachary Kincaid University of Toronto Abstract. Duet is a static analysis tool for concurrent programs in which the number of executing

More information

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007 CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes

More information

Beyond Reduction... Busy Acquire. Busy Acquire. alloc. alloc. Non-Serial Execution: Serial Execution: Atomic but not reducible

Beyond Reduction... Busy Acquire. Busy Acquire. alloc. alloc. Non-Serial Execution: Serial Execution: Atomic but not reducible Busy Acquire Beyond Reduction... if (CAS(m,0,1)) break; if (m == 0) { m = 1; return true; else { return false; 1 2 Busy Acquire if (CAS(m,0,1)) break; Non-Serial Execution: (fails) (fails) (succeeds) Serial

More information

Chapter 22. Transaction Management

Chapter 22. Transaction Management Chapter 22 Transaction Management 1 Transaction Support Transaction Action, or series of actions, carried out by user or application, which reads or updates contents of database. Logical unit of work on

More information

Profile-Guided Program Simplification for Effective Testing and Analysis

Profile-Guided Program Simplification for Effective Testing and Analysis Profile-Guided Program Simplification for Effective Testing and Analysis Lingxiao Jiang Zhendong Su Program Execution Profiles A profile is a set of information about an execution, either succeeded or

More information

Understanding the Interleaving Space Overlap across Inputs and So7ware Versions

Understanding the Interleaving Space Overlap across Inputs and So7ware Versions Understanding the Interleaving Space Overlap across Inputs and So7ware Versions Dongdong Deng, Wei Zhang, Borui Wang, Peisen Zhao, Shan Lu University of Wisconsin, Madison 1 Concurrency bug detec3on is

More information

Transactions. Kathleen Durant PhD Northeastern University CS3200 Lesson 9

Transactions. Kathleen Durant PhD Northeastern University CS3200 Lesson 9 Transactions Kathleen Durant PhD Northeastern University CS3200 Lesson 9 1 Outline for the day The definition of a transaction Benefits provided What they look like in SQL Scheduling Transactions Serializability

More information

Model Requirements and JAVA Programs MVP 2 1

Model Requirements and JAVA Programs MVP 2 1 Model Requirements and JAVA Programs MVP 2 1 Traditional Software The Waterfall Model Problem Area Development Analysis REVIEWS Design Implementation Costly wrt time and money. Errors are found too late

More information

Potential violations of Serializability: Example 1

Potential violations of Serializability: Example 1 CSCE 6610:Advanced Computer Architecture Review New Amdahl s law A possible idea for a term project Explore my idea about changing frequency based on serial fraction to maintain fixed energy or keep same

More information

Runtime Atomicity Analysis of Multi-threaded Programs

Runtime Atomicity Analysis of Multi-threaded Programs Runtime Atomicity Analysis of Multi-threaded Programs Focus is on the paper: Atomizer: A Dynamic Atomicity Checker for Multithreaded Programs by C. Flanagan and S. Freund presented by Sebastian Burckhardt

More information

i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture

i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture 2 Concurrency Model checking Java Pathfinder (JPF) Detecting race condition Bounded buffer problem

More information

Performance Improvement via Always-Abort HTM

Performance Improvement via Always-Abort HTM 1 Performance Improvement via Always-Abort HTM Joseph Izraelevitz* Lingxiang Xiang Michael L. Scott* *Department of Computer Science University of Rochester {jhi1,scott}@cs.rochester.edu Parallel Computing

More information

ASaP: Annotations for Safe Parallelism in Clang. Alexandros Tzannes, Vikram Adve, Michael Han, Richard Latham

ASaP: Annotations for Safe Parallelism in Clang. Alexandros Tzannes, Vikram Adve, Michael Han, Richard Latham ASaP: Annotations for Safe Parallelism in Clang Alexandros Tzannes, Vikram Adve, Michael Han, Richard Latham Motivation Debugging parallel code is hard!! Many bugs are hard to reason about & reproduce

More information

Verifying Concurrent Programs

Verifying Concurrent Programs Verifying Concurrent Programs Daniel Kroening 8 May 1 June 01 Outline Shared-Variable Concurrency Predicate Abstraction for Concurrent Programs Boolean Programs with Bounded Replication Boolean Programs

More information

Semaphores and Monitors: High-level Synchronization Constructs

Semaphores and Monitors: High-level Synchronization Constructs 1 Synchronization Constructs Synchronization Coordinating execution of multiple threads that share data structures Semaphores and Monitors High-level Synchronization Constructs A Historical Perspective

More information

Automatically Classifying Benign and Harmful Data Races Using Replay Analysis

Automatically Classifying Benign and Harmful Data Races Using Replay Analysis Automatically Classifying Benign and Harmful Data Races Using Replay Analysis Satish Narayanasamy, Zhenghao Wang, Jordan Tigani, Andrew Edwards, Brad Calder Microsoft University of California, San Diego

More information

Lightweight Data Race Detection for Production Runs

Lightweight Data Race Detection for Production Runs Lightweight Data Race Detection for Production Runs Swarnendu Biswas, UT Austin Man Cao, Ohio State University Minjia Zhang, Microsoft Research Michael D. Bond, Ohio State University Benjamin P. Wood,

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

Practical Concurrency. Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

Practical Concurrency. Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Practical Concurrency Agenda Motivation Java Memory Model Basics Common Bug Patterns JDK Concurrency Utilities Patterns of Concurrent Processing Testing Concurrent Applications Concurrency in Java 7 2

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

Distributed Data Management

Distributed Data Management Lecture Distributed Data Management Chapter 7: Lazy Replication Erik Buchmann buchmann@ipd.uka.de IPD, Forschungsbereich Systeme der Informationsverwaltung Synchronous vs. Asynchronous Updates Synchronous

More information

TRANSACTION MANAGEMENT

TRANSACTION MANAGEMENT TRANSACTION MANAGEMENT CS 564- Spring 2018 ACKs: Jeff Naughton, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? Transaction (TXN) management ACID properties atomicity consistency isolation durability

More information

Important Lessons. A Distributed Algorithm (2) Today's Lecture - Replication

Important Lessons. A Distributed Algorithm (2) Today's Lecture - Replication Important Lessons Lamport & vector clocks both give a logical timestamps Total ordering vs. causal ordering Other issues in coordinating node activities Exclusive access to resources/data Choosing a single

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

Relaxed Memory Consistency

Relaxed Memory Consistency Relaxed Memory Consistency Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3054: Multicore Systems, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

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

Transactional Memory

Transactional Memory Transactional Memory Architectural Support for Practical Parallel Programming The TCC Research Group Computer Systems Lab Stanford University http://tcc.stanford.edu TCC Overview - January 2007 The Era

More information

COMP Parallel Computing. CC-NUMA (2) Memory Consistency

COMP Parallel Computing. CC-NUMA (2) Memory Consistency COMP 633 - Parallel Computing Lecture 11 September 26, 2017 Memory Consistency Reading Patterson & Hennesey, Computer Architecture (2 nd Ed.) secn 8.6 a condensed treatment of consistency models Coherence

More information

6.830 Lecture Transactions October 23, 2017

6.830 Lecture Transactions October 23, 2017 6.830 Lecture 12 -- Transactions October 23, 2017 Quiz 1 Back? Transaction Processing: Today: Transactions -- focus on concurrency control today Transactions One of the 'big ideas in computer science'

More information

DMP Deterministic Shared Memory Multiprocessing

DMP Deterministic Shared Memory Multiprocessing DMP Deterministic Shared Memory Multiprocessing University of Washington Joe Devietti, Brandon Lucia, Luis Ceze, Mark Oskin A multithreaded voting machine 2 thread 0 thread 1 while (more_votes) { load

More information

Synchronization. Clock Synchronization

Synchronization. Clock Synchronization Synchronization Clock Synchronization Logical clocks Global state Election algorithms Mutual exclusion Distributed transactions 1 Clock Synchronization Time is counted based on tick Time judged by query

More information

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable)

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) Past & Present Have looked at two constraints: Mutual exclusion constraint between two events is a requirement that

More information

Consistency. CS 475, Spring 2018 Concurrent & Distributed Systems

Consistency. CS 475, Spring 2018 Concurrent & Distributed Systems Consistency CS 475, Spring 2018 Concurrent & Distributed Systems Review: 2PC, Timeouts when Coordinator crashes What if the bank doesn t hear back from coordinator? If bank voted no, it s OK to abort If

More information

Performance Improvement via Always-Abort HTM

Performance Improvement via Always-Abort HTM 1 Performance Improvement via Always-Abort HTM Joseph Izraelevitz* Lingxiang Xiang Michael L. Scott* *Department of Computer Science University of Rochester {jhi1,scott}@cs.rochester.edu Parallel Computing

More information

Randomized Active Atomicity Violation Detection in Concurrent Programs

Randomized Active Atomicity Violation Detection in Concurrent Programs Randomized Active Atomicity Violation Detection in Concurrent Programs Chang-Seo Park EECS Department, UC Berkeley, CA, USA. parkcs@cs.berkeley.edu Koushik Sen EECS Department, UC Berkeley, CA, USA. ksen@cs.berkeley.edu

More information

Cover Page. The handle holds various files of this Leiden University dissertation

Cover Page. The handle   holds various files of this Leiden University dissertation Cover Page The handle http://hdl.handle.net/1887/22891 holds various files of this Leiden University dissertation Author: Gouw, Stijn de Title: Combining monitoring with run-time assertion checking Issue

More information

The Java Memory Model

The Java Memory Model The Java Memory Model The meaning of concurrency in Java Bartosz Milewski Plan of the talk Motivating example Sequential consistency Data races The DRF guarantee Causality Out-of-thin-air guarantee Implementation

More information

Motivation & examples Threads, shared memory, & synchronization

Motivation & examples Threads, shared memory, & synchronization 1 Motivation & examples Threads, shared memory, & synchronization How do locks work? Data races (a lower level property) How do data race detectors work? Atomicity (a higher level property) Concurrency

More information

Finding Concurrency Bugs in Java

Finding Concurrency Bugs in Java July 25, 2004 Background Our Work Recommendations Background Our Work Programmers are Not Scared Enough Java makes threaded programming too easy Language often hides consequences of incorrect synchronization

More information

Dept. of CSE, York Univ. 1

Dept. of CSE, York Univ. 1 EECS 3221.3 Operating System Fundamentals No.5 Process Synchronization(1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Background: cooperating processes with shared

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs CSE 451: Operating Systems Winter 2005 Lecture 7 Synchronization Steve Gribble Synchronization Threads cooperate in multithreaded programs to share resources, access shared data structures e.g., threads

More information

Multi-threading in Java. Jeff HUANG

Multi-threading in Java. Jeff HUANG Multi-threading in Java Jeff HUANG Software Engineering Group @HKUST Do you use them? 2 Do u know their internals? 3 Let s see File DB How can they service so many clients simultaneously? l 4 Multi-threading

More information

Concurrency CSCI 201 Principles of Software Development

Concurrency CSCI 201 Principles of Software Development Concurrency CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Synchronization Outline USC CSCI 201L Motivation for Synchronization Thread synchronization is used

More information

COMP 346 WINTER Tutorial 2 SHARED DATA MANIPULATION AND SYNCHRONIZATION

COMP 346 WINTER Tutorial 2 SHARED DATA MANIPULATION AND SYNCHRONIZATION COMP 346 WINTER 2018 1 Tutorial 2 SHARED DATA MANIPULATION AND SYNCHRONIZATION REVIEW - MULTITHREADING MODELS 2 Some operating system provide a combined user level thread and Kernel level thread facility.

More information

More BSOD Embarrassments. Moore s Law. Programming With Threads. Moore s Law is Over. Analysis of Concurrent Software. Types for Race Freedom

More BSOD Embarrassments. Moore s Law. Programming With Threads. Moore s Law is Over. Analysis of Concurrent Software. Types for Race Freedom Moore s Law Analysis of Concurrent Software Types for Race Freedom Transistors per chip doubles every 18 months Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College Shaz Qadeer Microsoft Research

More information

A unified machine-checked model for multithreaded Java

A unified machine-checked model for multithreaded Java A unified machine-checked model for multithreaded Java Andre Lochbihler IPD, PROGRAMMING PARADIGMS GROUP, COMPUTER SCIENCE DEPARTMENT KIT - University of the State of Baden-Wuerttemberg and National Research

More information

Thin Locks: Featherweight Synchronization for Java

Thin Locks: Featherweight Synchronization for Java Thin Locks: Featherweight Synchronization for Java D. Bacon 1 R. Konuru 1 C. Murthy 1 M. Serrano 1 Presented by: Calvin Hubble 2 1 IBM T.J. Watson Research Center 2 Department of Computer Science 16th

More information

Program logics for relaxed consistency

Program logics for relaxed consistency Program logics for relaxed consistency UPMARC Summer School 2014 Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) 1st Lecture, 28 July 2014 Outline Part I. Weak memory models 1. Intro

More information

! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA

! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics! Why is synchronization needed?! Synchronization Language/Definitions:» What are race

More information

Synchronization I. Jo, Heeseung

Synchronization I. Jo, Heeseung Synchronization I Jo, Heeseung Today's Topics Synchronization problem Locks 2 Synchronization Threads cooperate in multithreaded programs To share resources, access shared data structures Also, to coordinate

More information

Advanced MEIC. (Lesson #18)

Advanced MEIC. (Lesson #18) Advanced Programming @ MEIC (Lesson #18) Last class Data races Java Memory Model No out-of-thin-air values Data-race free programs behave as expected Today Finish with the Java Memory Model Introduction

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

CS 347 Parallel and Distributed Data Processing

CS 347 Parallel and Distributed Data Processing CS 347 Parallel and Distributed Data Processing Spring 2016 Notes 5: Concurrency Control Topics Data Database design Queries Decomposition Localization Optimization Transactions Concurrency control Reliability

More information

Testing Concurrent Programs on Relaxed Memory Models

Testing Concurrent Programs on Relaxed Memory Models Testing Concurrent Programs on Relaxed Memory Models Jacob Burnim Koushik Sen Christos Stergiou Electrical Engineering and Computer Sciences University of California at Berkeley Technical Report No. UCB/EECS-2010-32

More information

The Pointer Assertion Logic Engine

The Pointer Assertion Logic Engine The Pointer Assertion Logic Engine [PLDI 01] Anders Mφller Michael I. Schwartzbach Presented by K. Vikram Cornell University Introduction Pointer manipulation is hard Find bugs, optimize code General Approach

More information

Goal of Concurrency Control. Concurrency Control. Example. Solution 1. Solution 2. Solution 3

Goal of Concurrency Control. Concurrency Control. Example. Solution 1. Solution 2. Solution 3 Goal of Concurrency Control Concurrency Control Transactions should be executed so that it is as though they executed in some serial order Also called Isolation or Serializability Weaker variants also

More information