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

Size: px
Start display at page:

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

Transcription

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

2 A Real PSO Bug $12 million loss of equipment curpos = new Point(1,2); class Point { int x, y; } Thread 1: newpos = new Point(curPos.x+1, curpos.y+1); Thread 2: while (newpos!= null) if (newpos.x+1!= newpos.y) ERROR x=0 y=0 x=curpos.x+1 y=curpos.y+1 curpos = object 2

3 Memory Consistencies 3

4 TSO and PSO Total Store Ordering (TSO) For a write w and a read r by the same thread, the read r can be reordered with the write w if the two operations access different locations. Partial Store Ordering (PSO) For a write w1 and a write w2 by the same thread, the write w2 can be reordered with the write w1 if the two operations access different locations. 4

5 New State Generated under TSO/PSO thread 1: x = 1 //a1 a = y //a2 Init: x=y=0 thread 2: y = 1 //b1 b = x //b2 Assert (a==1 b==1) b2 a1 a2 b1 (a=0, b=0) 5

6 Huge Interleaving Space #interleaving = & &!( # N % %'( ) ('* N ( (M : #threads and N i : #accesses by thread i) (Lu et al. FSE 07) M=4, N1=N2=N3=N4=4, #interleavings > 60 million 6

7 Related Work Dynamic Partial Order Reduction (DPOR) [Flanagan et al., POPL 05] Maximal Causality Reduction [Huang, PLDI 15] rinspect [Zhang et al., PLDI 15] SATCheck [Demsky and Lam, OOPSLA 15] 7

8 Maximal Causality Reduction (MCR) Given an executed trace, MCR generates new interleavings to explore the program state space. Each new interleaving (called seed interleaving) enforces at least one read to read a new value. 8

9 Workflow of MCR 1 Scheduler 2 Interleaving Seed Trace Interleavings Interleaving 1 3 Constraints Formula Interleaving 2 Formula... Interleaving n New Seed Interleavings 5 SMT Solver Solution Interleaving Builder 4 9

10 Workflow of MCR 1 Scheduler 2 Interleaving Seed Trace Interleavings Interleaving 1 Following a seed interleaving Formula will produce a new state Interleaving 2... Interleaving n New Seed Interleavings 5 3 Constraints Formula SMT Solver Solution Interleaving Builder 4 10

11 Constraints (ϕ) happens-before r and constructs the following constraints for V (l 1, u 1 ) and (l 2, u 2 ): O u1 <O l2 _ O u2 <O l1 lock-mutual-exclusion validity new state te constraint that ensures r to read a value v: value(r, v) W ( validity (w) ^ O w <O r V w2wv x (O w 0 <O w _ O r <O w 0)) w6=w 0 2W x 11

12 Constraints (ϕ) happens-before r and constructs the following constraints for V (l 1, u 1 ) and (l 2, u 2 ): O u1 <O l2 _ O u2 <O l1 lock-mutual-exclusion validity te constraint that ensures r to read a value v: value(r, v) W ( validity (w) ^ O w <O r V w2wv x (O w 0 <O w _ O r <O w 0)) w6=w 0 2W x An event is feasible if every read in the seed interleaving returns the same value as that in new the previous state trace. 12

13 Constraints (ϕ) happens-before r and constructs the following constraints for V (l 1, u 1 ) and (l 2, u 2 ): O u1 <O l2 _ O u2 <O l1 lock-mutual-exclusion validity new state te constraint that ensures r to read a value v: value(r, v) W ( validity (w) ^ O w <O r V w2wv x (O w 0 <O w _ O r <O w 0)) w6=w 0 2W x 13

14 An Example Init: x=y=0 thread 1: x = 1 //a1 a = y //a2 thread 2: y = 1 //b1 b = x //b2 O b1 < O a2 O a1 < O a2 S0: a1-a2-b1-b2 (a=0, b=1) S1: a1- b1 - a2 (a=1, b=1) 3 executions O b2 < O a1 O b1 < O b2 S2: b1 - b2 (a=1, b=0) 14

15 Limitation of MCR The original MCR only checks the program under sequential consistency. 15

16 Limitation of MCR thread 1: x = 1 //a1 a = y //a2 Init: x=y=0 thread 2: y = 1 //b1 b = x //b2 Assert (a==1 b==1) 16

17 Contributions Extend MCR for TSO and PSO Present a new replay algorithm Evaluation on various applications Explore 5x 10x fewer executions than DPOR 17

18 Two Challenges 1. Relax the happens-before constraints 2. Replay a schedule out of the program order 18

19 Happens-before Relaxation Relax the happens-before relation of the write-read and writewrite events by the same thread: ɸ hb = ɸ rr ɸ addr r1 r2, iff r1,r2 Reads e1 e2, iff addr(e1) = addr(e2) ɸ r-w r w, iff r Reads && w Writes ɸ w-w w1 w2, iff w1,w2 Writes 19

20 Example Init: x=y=0 thread 1: x = 1 //a1 a = y //a2 thread 2: y = 1 //b1 b = x //b2 Under SC: O a1 < O a2 O b1 < O b2 Under TSO/PSO O a1, O a2, O b1, O b2 20

21 Replay thread 1: thread 2: x = 1 //a1 y = 1 a = y //a2 b = x Expecting: b2 a1 a2 b1 T2 T1 T1 T2 //b1 //b2 Can t decide whether to buffer Actual: b1 a1 a2 b2 21

22 Replay Interleaving : a sequence of schedule choices, with each schedule choice c(tid, addr). A concurrent program t1: x = 1; addr conflicts t2: y = 1; Store Buffer B 2 buffer y=1... Case 1: when addr(e) addr(c), buffer e a = y; b = x; addr matches, so t 2 :y must correspond to W(y) Case 2: when addr(c) = addr(w), w is buffered, Schedule Choice: update w 22

23 Constraints Construction Initially x=1, y=2, z=0 Thread 1: Thread 2: thread2.start() 1 z = 0 2 x = 0 3 y = 0 4 x = 2 5 y = 3 6 z = 1 thread2.join() if (z==1) if (x+1!= y) ERROR Execution: SC/TSO O 1 < O 2 < O 3 < O 4 < O 5 < O 6 O 7 < O 1 8 < O2 8 PSO O 1 < O 6 O 2 < O 4 O 3 < O 5 O 7 < O 1 8 < O2 8 PSO: O 1 =1, O 2 =2, O 3 =3, O 4 =7, O 5 =8, O 6 =4, O 7 =5, O 1=6 8 A feasible schedule: that can trigger the error! 23

24 Replay thread 1: 1. z=0 2. x=0 3. y=0 4. x=1 5. y=2 6. z=1 x=1 thread 2: 7. if (z>0) 8. assert( x+1 == y) Addr doesn t match Addr doesn t match y=2 Replay: Scheduler T z 1 -Tx 1 -Ty 1 -Tz 1 -Tz 2 -Tx 2 -Tx 1 -Ty 1 1:z=0 2:x=0 3:y=0 6:z=1 7:z>0 8:x+1 4:x=1 24

25 Evaluation Java implementation using ASM and Z3 Compared with rinspect [Zhang et al., PLDI 15] and SATCheck [Demsky and Lam, OOPSLA 15] Ø States pace exploration effectiveness Ø Efficiency of finding errors A collection of benchmarks with known errors 25

26 Benchmarks 7 popular small benchmarks 6 real Java applications including a large one weblech Program LoC #Thrd #Evt Description Dekker Two critical sections with 3 shared variables. Lamport Two critical sections with 4 variables. bakery n critical sections using 2n shared variables. We take n=2. Peterson Two critical sections with 3 variables StackUnsafe Unsafe operations on a stack by two threads, which cause the stack underflow. RVExample An example from original MCR [21], which contains a very tricky error Example The example program from Figure 6 with loop number from 1 to 4. Account Concurrent account deposits and withdrawals suffering from atomicity violations. Airline A race condition causing the tickets oversold. Allocation An atomicity violation causing the same block allocated or freed twice. PingPong The player is set to null by one thread and dereferenced by another throwing NPE. StringBuf An atomicity violation in Java StringBuffer causing StringIndexOutOfBoundsException. Weblech 35K A tool for downloading websites and enumerating standard web-browser behavior. 26

27 State Space Exploration Program DPOR (rinspect) MCR (our approach) #Executions Reduction SC TSO PSO SC TSO PSO SC TSO PSO Dekker X 2.6X 3.3X Lamport X 2.3X 29.4X Bakery X 7.1X 12.4X Peterson X 5.3X 6.3X StackUnsafe X 5.5X 2.3X RVExample X X 2.0X X 2.4X X 14.5X X 5.4X - Avg X 5.0X 10.9X Example (N=1 to 4) 27

28 State Space Exploration Program DPOR (rinspect) MCR (our approach) #Executions Reduction SC TSO PSO SC TSO PSO SC TSO PSO Dekker X 2.6X 3.3X Lamport X 2.3X 29.4X Bakery X 7.1X 12.4X Peterson Our 36 approach explores x 19 10x 2.8X fewer 5.3X 6.3X StackUnsafe X 5.5X 2.3X executions than DPOR. RVExample X X 2.0X X 2.4X X 14.5X X 5.4X - Avg X 5.0X 10.9X Example (N=1 to 4) 28

29 Finding Bugs Program DPOR SATCheck MCR (our approach) SC TSO PSO SC TSO SC TSO PSO Dekker ! 68735! Lamport Bakery Peterson * 34282! StackUnsafe RVExample ! 70365! Example 14840* 14840* - 1* 1* 2767* 2767* 3 Avg !: repeat the same execution *: finish without finding the bug 29

30 Finding Bugs Program DPOR SATCheck MCR (our approach) SC TSO PSO SC TSO SC TSO PSO Dekker ! 68735! Our approach needs 2X- 3X fewer Lamport Bakery executions than DPOR and SATCheck Peterson * 34282! StackUnsafe RVExample ! 70365! Example 14840* 14840* - 1* 1* 2767* 2767* 3 Avg !: repeat the same execution *: finish without finding the bug to find the bugs 30

31 Conclusion 1. MCR for TSO and PSO Relax the happens-before constraints Faithfully replay the TSO/PSO interleavings 2. Explore 5X 10X fewer executions than DPOR 3. Take fewer executions to find the bugs 31

32 Acknowledgement Brian Demsky University of California, Irvine Patrick Lam University of Waterloo 32

33 Thank you & Questions? 33

Parallel Computer Architecture Spring Memory Consistency. Nikos Bellas

Parallel Computer Architecture Spring Memory Consistency. Nikos Bellas Parallel Computer Architecture Spring 2018 Memory Consistency Nikos Bellas Computer and Communications Engineering Department University of Thessaly Parallel Computer Architecture 1 Coherence vs Consistency

More information

CS5460: Operating Systems

CS5460: Operating Systems CS5460: Operating Systems Lecture 9: Implementing Synchronization (Chapter 6) Multiprocessor Memory Models Uniprocessor memory is simple Every load from a location retrieves the last value stored to that

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

! 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

Semantic Atomicity for Multithreaded Programs!

Semantic Atomicity for Multithreaded Programs! 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!

More information

Chapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization?

Chapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization? 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 conditions?»

More information

Towards Production-Run Heisenbugs Reproduction on Commercial Hardware

Towards Production-Run Heisenbugs Reproduction on Commercial Hardware Towards Production-Run Heisenbugs Reproduction on Commercial Hardware Shiyou Huang, Bowen Cai, and Jeff Huang, Texas A&M University https://www.usenix.org/conference/atc17/technical-sessions/presentation/huang

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

SPIN, PETERSON AND BAKERY LOCKS

SPIN, PETERSON AND BAKERY LOCKS Concurrent Programs reasoning about their execution proving correctness start by considering execution sequences CS4021/4521 2018 jones@scss.tcd.ie School of Computer Science and Statistics, Trinity College

More information

Weak memory models. Mai Thuong Tran. PMA Group, University of Oslo, Norway. 31 Oct. 2014

Weak memory models. Mai Thuong Tran. PMA Group, University of Oslo, Norway. 31 Oct. 2014 Weak memory models Mai Thuong Tran PMA Group, University of Oslo, Norway 31 Oct. 2014 Overview 1 Introduction Hardware architectures Compiler optimizations Sequential consistency 2 Weak memory models TSO

More information

Vulcan: Hardware Support for Detecting Sequential Consistency Violations Dynamically

Vulcan: Hardware Support for Detecting Sequential Consistency Violations Dynamically Vulcan: Hardware Support for Detecting Sequential Consistency Violations Dynamically Abdullah Muzahid, Shanxiang Qi, and University of Illinois at Urbana-Champaign http://iacoma.cs.uiuc.edu MICRO December

More information

CSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization?

CSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization? Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions: What are race conditions? What

More information

Beyond Sequential Consistency: Relaxed Memory Models

Beyond Sequential Consistency: Relaxed Memory Models 1 Beyond Sequential Consistency: Relaxed Memory Models Computer Science and Artificial Intelligence Lab M.I.T. Based on the material prepared by and Krste Asanovic 2 Beyond Sequential Consistency: Relaxed

More information

NOW Handout Page 1. Memory Consistency Model. Background for Debate on Memory Consistency Models. Multiprogrammed Uniprocessor Mem.

NOW Handout Page 1. Memory Consistency Model. Background for Debate on Memory Consistency Models. Multiprogrammed Uniprocessor Mem. Memory Consistency Model Background for Debate on Memory Consistency Models CS 258, Spring 99 David E. Culler Computer Science Division U.C. Berkeley for a SAS specifies constraints on the order in which

More information

Predicate Abstraction for Relaxed Memory Models

Predicate Abstraction for Relaxed Memory Models Predicate Abstraction for Relaxed Memory Models Andrei Dan 1, Yuri Meshman 2, Martin Vechev 1, and Eran Yahav 2 1 ETH Zurich {andrei.dan, martin.vechev}@inf.ethz.ch 2 Technion {yurime, yahave}@cs.technion.ac.il

More information

CIS Operating Systems Synchronization based on Busy Waiting. Professor Qiang Zeng Spring 2018

CIS Operating Systems Synchronization based on Busy Waiting. Professor Qiang Zeng Spring 2018 CIS 3207 - Operating Systems Synchronization based on Busy Waiting Professor Qiang Zeng Spring 2018 Previous class IPC for passing data Pipe FIFO Message Queue Shared Memory Compare these IPCs for data

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

Predicting Null-Pointer Dereferences in Concurrent Programs. Parthasarathy Madhusudan Niloofar Razavi Francesco Sorrentino

Predicting Null-Pointer Dereferences in Concurrent Programs. Parthasarathy Madhusudan Niloofar Razavi Francesco Sorrentino Predicting Null-Pointer Dereferences in Concurrent Programs After work by: Azadeh Farzan Parthasarathy Madhusudan Niloofar Razavi Francesco Sorrentino Overview The problem The idea The solution The evaluation

More information

CMSC 714 Lecture 14 Lamport Clocks and Eraser

CMSC 714 Lecture 14 Lamport Clocks and Eraser Notes CMSC 714 Lecture 14 Lamport Clocks and Eraser Midterm exam on April 16 sample exam questions posted Research project questions? Alan Sussman (with thanks to Chris Ackermann) 2 Lamport Clocks Distributed

More information

Reasoning About The Implementations Of Concurrency Abstractions On x86-tso. By Scott Owens, University of Cambridge.

Reasoning About The Implementations Of Concurrency Abstractions On x86-tso. By Scott Owens, University of Cambridge. Reasoning About The Implementations Of Concurrency Abstractions On x86-tso By Scott Owens, University of Cambridge. Plan Intro Data Races And Triangular Races Examples 2 sequential consistency The result

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

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

Symmetric Multiprocessors: Synchronization and Sequential Consistency

Symmetric Multiprocessors: Synchronization and Sequential Consistency Constructive Computer Architecture Symmetric Multiprocessors: Synchronization and Sequential Consistency Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November

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

Synchronization I. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Synchronization I. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Synchronization I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Synchronization problem Locks 2 Synchronization Threads cooperate

More information

Pattern-based Synthesis of Synchronization for the C++ Memory Model

Pattern-based Synthesis of Synchronization for the C++ Memory Model Pattern-based Synthesis of Synchronization for the C++ Memory Model Yuri Meshman Technion Noam Rinetzky Tel Aviv University Eran Yahav Technion Abstract We address the problem of synthesizing efficient

More information

+ Today. Lecture 26: Concurrency 3/31/14. n Reading. n Objectives. n Announcements. n P&C Section 7. n Race conditions.

+ Today. Lecture 26: Concurrency 3/31/14. n Reading. n Objectives. n Announcements. n P&C Section 7. n Race conditions. + Lecture 26: Concurrency Slides adapted from Dan Grossman + Today n Reading n P&C Section 7 n Objectives n Race conditions n Announcements n Quiz on Friday 1 + This week s programming assignment n Answer

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

Introducing Shared-Memory Concurrency

Introducing Shared-Memory Concurrency Race Conditions and Atomic Blocks November 19, 2007 Why use concurrency? Communicating between threads Concurrency in Java/C Concurrency Computation where multiple things happen at the same time is inherently

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

3/25/14. Lecture 25: Concurrency. + Today. n Reading. n P&C Section 6. n Objectives. n Concurrency

3/25/14. Lecture 25: Concurrency. + Today. n Reading. n P&C Section 6. n Objectives. n Concurrency + Lecture 25: Concurrency + Today n Reading n P&C Section 6 n Objectives n Concurrency 1 + Concurrency n Correctly and efficiently controlling access by multiple threads to shared resources n Programming

More information

Weak Memory Models: an Operational Theory

Weak Memory Models: an Operational Theory Opening Weak Memory Models: an Operational Theory INRIA Sophia Antipolis 9th June 2008 Background on weak memory models Memory models, what are they good for? Hardware optimizations Contract between hardware

More information

An introduction to weak memory consistency and the out-of-thin-air problem

An introduction to weak memory consistency and the out-of-thin-air problem An introduction to weak memory consistency and the out-of-thin-air problem Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) CONCUR, 7 September 2017 Sequential consistency 2 Sequential

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

Lecture 13: Consistency Models. Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models

Lecture 13: Consistency Models. Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models Lecture 13: Consistency Models Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models 1 Coherence Vs. Consistency Recall that coherence guarantees

More information

Optimistic Shared Memory Dependence Tracing

Optimistic Shared Memory Dependence Tracing Optimistic Shared Memory Dependence Tracing Yanyan Jiang1, Du Li2, Chang Xu1, Xiaoxing Ma1 and Jian Lu1 Nanjing University 2 Carnegie Mellon University 1 powered by Understanding Non-determinism Concurrent

More information

Shared Memory Consistency Models: A Tutorial

Shared Memory Consistency Models: A Tutorial Shared Memory Consistency Models: A Tutorial By Sarita Adve, Kourosh Gharachorloo WRL Research Report, 1995 Presentation: Vince Schuster Contents Overview Uniprocessor Review Sequential Consistency Relaxed

More information

Announcements. ECE4750/CS4420 Computer Architecture L17: Memory Model. Edward Suh Computer Systems Laboratory

Announcements. ECE4750/CS4420 Computer Architecture L17: Memory Model. Edward Suh Computer Systems Laboratory ECE4750/CS4420 Computer Architecture L17: Memory Model Edward Suh Computer Systems Laboratory suh@csl.cornell.edu Announcements HW4 / Lab4 1 Overview Symmetric Multi-Processors (SMPs) MIMD processing cores

More information

Taming release-acquire consistency

Taming release-acquire consistency Taming release-acquire consistency Ori Lahav Nick Giannarakis Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) POPL 2016 Weak memory models Weak memory models provide formal sound semantics

More information

1. Introduction to Concurrent Programming

1. Introduction to Concurrent Programming 1. Introduction to Concurrent Programming A concurrent program contains two or more threads that execute concurrently and work together to perform some task. When a program is executed, the operating system

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

7/6/2015. Motivation & examples Threads, shared memory, & synchronization. Imperative programs

7/6/2015. Motivation & examples Threads, shared memory, & synchronization. Imperative programs 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 exceptions

More information

Declarative semantics for concurrency. 28 August 2017

Declarative semantics for concurrency. 28 August 2017 Declarative semantics for concurrency Ori Lahav Viktor Vafeiadis 28 August 2017 An alternative way of defining the semantics 2 Declarative/axiomatic concurrency semantics Define the notion of a program

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track

More information

Runtime Support for Scalable Task-parallel Programs

Runtime Support for Scalable Task-parallel Programs Runtime Support for Scalable Task-parallel Programs Pacific Northwest National Lab xsig workshop May 2018 http://hpc.pnl.gov/people/sriram/ Single Program Multiple Data int main () {... } 2 Task Parallelism

More information

Patrick Trentin Formal Methods Lab Class, March 03, 2017

Patrick Trentin  Formal Methods Lab Class, March 03, 2017 Spin: Introduction Patrick Trentin patrick.trentin@unitn.it http://disi.unitn.it/trentin Formal Methods Lab Class, March 03, 2017 These slides are derived from those by Stefano Tonetta, Alberto Griggio,

More information

CS 252 Graduate Computer Architecture. Lecture 11: Multiprocessors-II

CS 252 Graduate Computer Architecture. Lecture 11: Multiprocessors-II CS 252 Graduate Computer Architecture Lecture 11: Multiprocessors-II Krste Asanovic Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~krste http://inst.eecs.berkeley.edu/~cs252

More information

Multicore Programming Java Memory Model

Multicore Programming Java Memory Model p. 1 Multicore Programming Java Memory Model Peter Sewell Jaroslav Ševčík Tim Harris University of Cambridge MSR with thanks to Francesco Zappa Nardelli, Susmit Sarkar, Tom Ridge, Scott Owens, Magnus O.

More information

Motivations. Shared Memory Consistency Models. Optimizations for Performance. Memory Consistency

Motivations. Shared Memory Consistency Models. Optimizations for Performance. Memory Consistency Shared Memory Consistency Models Authors : Sarita.V.Adve and Kourosh Gharachorloo Presented by Arrvindh Shriraman Motivations Programmer is required to reason about consistency to ensure data race conditions

More information

Automatic Verification of RMA Programs via Abstraction Extrapolation

Automatic Verification of RMA Programs via Abstraction Extrapolation Automatic Verification of RMA Programs via Abstraction Extrapolation Cedric Baumann 1, Andrei Marian Dan 1, Yuri Meshman 2, Torsten Hoefler 1, and Martin Vechev 1 1 Department of Computer Science, ETH

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

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Synchronization in Java Department of Computer Science University of Maryland, College Park Multithreading Overview Motivation & background Threads Creating Java

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

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

Memory Consistency Models

Memory Consistency Models Memory Consistency Models Contents of Lecture 3 The need for memory consistency models The uniprocessor model Sequential consistency Relaxed memory models Weak ordering Release consistency Jonas Skeppstedt

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

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

The C/C++ Memory Model: Overview and Formalization

The C/C++ Memory Model: Overview and Formalization The C/C++ Memory Model: Overview and Formalization Mark Batty Jasmin Blanchette Scott Owens Susmit Sarkar Peter Sewell Tjark Weber Verification of Concurrent C Programs C11 / C++11 In 2011, new versions

More information

Review of last lecture. Peer Quiz. DPHPC Overview. Goals of this lecture. Is coherence everything?

Review of last lecture. Peer Quiz. DPHPC Overview. Goals of this lecture. Is coherence everything? Review of last lecture Design of Parallel and High-Performance Computing Fall Lecture: Memory Models Motivational video: https://www.youtube.com/watch?v=twhtg4ous Instructor: Torsten Hoefler & Markus Püschel

More information

Thread-Local. Lecture 27: Concurrency 3. Dealing with the Rest. Immutable. Whenever possible, don t share resources

Thread-Local. Lecture 27: Concurrency 3. Dealing with the Rest. Immutable. Whenever possible, don t share resources Thread-Local Lecture 27: Concurrency 3 CS 62 Fall 2016 Kim Bruce & Peter Mawhorter Some slides based on those from Dan Grossman, U. of Washington Whenever possible, don t share resources Easier to have

More information

CSE332: Data Abstractions Lecture 25: Deadlocks and Additional Concurrency Issues. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 25: Deadlocks and Additional Concurrency Issues. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 25: Deadlocks and Additional Concurrency Issues Tyler Robison Summer 2010 1 Where we are We ve covered basic concurrency, then some odds and ends: Readers/writer locks

More information

CS 152 Computer Architecture and Engineering. Lecture 19: Synchronization and Sequential Consistency

CS 152 Computer Architecture and Engineering. Lecture 19: Synchronization and Sequential Consistency CS 152 Computer Architecture and Engineering Lecture 19: Synchronization and Sequential Consistency Krste Asanovic Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~krste

More information

CLAP: Recording Local Executions to Reproduce Concurrency Failures

CLAP: Recording Local Executions to Reproduce Concurrency Failures CLAP: Recording Local Executions to Reproduce Concurrency Failures Jeff Huang Hong Kong University of Science and Technology smhuang@cse.ust.hk Charles Zhang Hong Kong University of Science and Technology

More information

Memory Consistency Models. CSE 451 James Bornholt

Memory Consistency Models. CSE 451 James Bornholt Memory Consistency Models CSE 451 James Bornholt Memory consistency models The short version: Multiprocessors reorder memory operations in unintuitive, scary ways This behavior is necessary for performance

More information

CS510 Advanced Topics in Concurrency. Jonathan Walpole

CS510 Advanced Topics in Concurrency. Jonathan Walpole CS510 Advanced Topics in Concurrency Jonathan Walpole Threads Cannot Be Implemented as a Library Reasoning About Programs What are the valid outcomes for this program? Is it valid for both r1 and r2 to

More information

G52CON: Concepts of Concurrency

G52CON: Concepts of Concurrency G52CON: Concepts of Concurrency Lecture 6: Algorithms for Mutual Natasha Alechina School of Computer Science nza@cs.nott.ac.uk Outline of this lecture mutual exclusion with standard instructions example:

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

[537] Locks. Tyler Harter

[537] Locks. Tyler Harter [537] Locks Tyler Harter Review: Threads+Locks CPU 1 CPU 2 running thread 1 running thread 2 RAM PageDir A PageDir B CPU 1 CPU 2 running thread 1 running thread 2 RAM PageDir A PageDir B Virt Mem (PageDir

More information

G52CON: Concepts of Concurrency

G52CON: Concepts of Concurrency G52CON: Concepts of Concurrency Lecture 11: Semaphores I" Brian Logan School of Computer Science bsl@cs.nott.ac.uk Outline of this lecture" problems with Peterson s algorithm semaphores implementing semaphores

More information

Sharing Objects Ch. 3

Sharing Objects Ch. 3 Sharing Objects Ch. 3 Visibility What is the source of the issue? Volatile Dekker s algorithm Publication and Escape Thread Confinement Immutability Techniques of safe publication Assignment 1 Visibility

More information

CHESS: Analysis and Testing of Concurrent Programs

CHESS: Analysis and Testing of Concurrent Programs CHESS: Analysis and Testing of Concurrent Programs Sebastian Burckhardt, Madan Musuvathi, Shaz Qadeer Microsoft Research Joint work with Tom Ball, Peli de Halleux, and interns Gerard Basler (ETH Zurich),

More information

Precise and Maximal Race Detection from Incomplete Traces

Precise and Maximal Race Detection from Incomplete Traces Precise and Maximal Race Detection from Incomplete Traces Jeff Huang Texas A&M University, USA jeff@cse.tamu.edu Arun K. Rajagopalan Texas A&M University, USA arunxls@tamu.edu Abstract We present RDIT,

More information

Predicting Data Races from Program Traces

Predicting Data Races from Program Traces Predicting Data Races from Program Traces Luis M. Carril IPD Tichy Lehrstuhl für Programmiersysteme KIT die Kooperation von Forschungszentrum Karlsruhe GmbH und Universität Karlsruhe (TH) Concurrency &

More information

Synchronization via Transactions

Synchronization via Transactions Synchronization via Transactions 1 Concurrency Quiz If two threads execute this program concurrently, how many different final values of X are there? Initially, X == 0. Thread 1 Thread 2 void increment()

More information

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce

More information

Software Architecture and Engineering: Part II

Software Architecture and Engineering: Part II Software Architecture and Engineering: Part II ETH Zurich, Spring 2016 Prof. http://www.srl.inf.ethz.ch/ Framework SMT solver Alias Analysis Relational Analysis Assertions Second Project Static Analysis

More information

Atom-Aid: Detecting and Surviving Atomicity Violations

Atom-Aid: Detecting and Surviving Atomicity Violations Atom-Aid: Detecting and Surviving Atomicity Violations Abstract Writing shared-memory parallel programs is an error-prone process. Atomicity violations are especially challenging concurrency errors. They

More information

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing

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

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

Relaxed Memory: The Specification Design Space

Relaxed Memory: The Specification Design Space Relaxed Memory: The Specification Design Space Mark Batty University of Cambridge Fortran meeting, Delft, 25 June 2013 1 An ideal specification Unambiguous Easy to understand Sound w.r.t. experimentally

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

CS 152 Computer Architecture and Engineering. Lecture 19: Synchronization and Sequential Consistency

CS 152 Computer Architecture and Engineering. Lecture 19: Synchronization and Sequential Consistency CS 152 Computer Architecture and Engineering Lecture 19: Synchronization and Sequential Consistency Krste Asanovic Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~krste

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

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 22 Shared-Memory Concurrency 1 Administrivia HW7 due Thursday night, 11 pm (+ late days if you still have any & want to use them) Course

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

Synchronization COMPSCI 386

Synchronization COMPSCI 386 Synchronization COMPSCI 386 Obvious? // push an item onto the stack while (top == SIZE) ; stack[top++] = item; // pop an item off the stack while (top == 0) ; item = stack[top--]; PRODUCER CONSUMER Suppose

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

A Revisionist History of Denotational Semantics

A Revisionist History of Denotational Semantics A Revisionist History of Denotational Semantics Stephen Brookes Carnegie Mellon University Domains XIII July 2018 1 / 23 Denotational Semantics Compositionality Principle The meaning of a complex expression

More information

CMSC Computer Architecture Lecture 15: Memory Consistency and Synchronization. Prof. Yanjing Li University of Chicago

CMSC Computer Architecture Lecture 15: Memory Consistency and Synchronization. Prof. Yanjing Li University of Chicago CMSC 22200 Computer Architecture Lecture 15: Memory Consistency and Synchronization Prof. Yanjing Li University of Chicago Administrative Stuff! Lab 5 (multi-core) " Basic requirements: out later today

More information

Getting Rid of Store-Buffers in TSO Analysis

Getting Rid of Store-Buffers in TSO Analysis Getting Rid of Store-Buffers in TSO Analysis Mohamed Faouzi Atig 1, Ahmed Bouajjani 2, and Gennaro Parlato 2 1 Uppsala University, Sweden mohamed faouzi.atig@it.uu.se 2 LIAFA, CNRS and University Paris

More information

Programmazione di sistemi multicore

Programmazione di sistemi multicore Programmazione di sistemi multicore A.A. 2015-2016 LECTURE 14 IRENE FINOCCHI http://wwwusers.di.uniroma1.it/~finocchi/ Programming with locks and critical sections MORE BAD INTERLEAVINGS GUIDELINES FOR

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

Getting Rid of Store-Buffers in TSO Analysis

Getting Rid of Store-Buffers in TSO Analysis Getting Rid of Store-Buffers in TSO Analysis Mohamed Faouzi Atig 1, Ahmed Bouajjani 2, and Gennaro Parlato 2 1 Uppsala University, Sweden, email: mohamed faouzi.atig@it.uu.se 2 LIAFA, CNRS and University

More information

11/19/2013. Imperative programs

11/19/2013. Imperative programs if (flag) 1 2 From my perspective, parallelism is the biggest challenge since high level programming languages. It s the biggest thing in 50 years because industry is betting its future that parallel programming

More information

4/6/2011. Model Checking. Encoding test specifications. Model Checking. Encoding test specifications. Model Checking CS 4271

4/6/2011. Model Checking. Encoding test specifications. Model Checking. Encoding test specifications. Model Checking CS 4271 Mel Checking LTL Property System Mel Mel Checking CS 4271 Mel Checking OR Abhik Roychoudhury http://www.comp.nus.edu.sg/~abhik Yes No, with Counter-example trace 2 Recap: Mel Checking for mel-based testing

More information

Don t sit on the fence: A static analysis approach to automatic fence insertion

Don t sit on the fence: A static analysis approach to automatic fence insertion Don t sit on the fence: A static analysis approach to automatic fence insertion Power, ARM! SC! \ / ~. ~ ) / ( / / \_/ \ / /\ / \ Jade Alglave, Daniel Kroening, Vincent Nimal, Daniel Poetzl University

More information

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019 CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?

More information

Reasoning about the C/C++ weak memory model

Reasoning about the C/C++ weak memory model Reasoning about the C/C++ weak memory model Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) 13 October 2014 Talk outline I. Introduction Weak memory models The C11 concurrency model

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