Atomicity in Multithreaded Software

Slides:



Advertisements
Similar presentations
Supporting existing code in a transactional memory system Nate Nystrom Mukund Raghavachari IBM TRAMP 5 Mar 2007.
Advertisements

Types for Atomicity Authors: Cormac Flanagan, UC Santa Cruz Stephen Freund, Marina Lifshin, Williams College Shaz Qadeer, Microsoft Research Presentation.
Applications of Synchronization Coverage A.Bron,E.Farchi, Y.Magid,Y.Nir,S.Ur Tehila Mayzels 1.
Runtime Verification Ali Akkaya Boğaziçi University.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
1 Beyond Reduction Busy Acquire atomic void busy_acquire() { while (true) { if (CAS(m,0,1)) break; } } if (m == 0) { m = 1; return true; } else.
Atomizer: A Dynamic Atomicity Checker For Multithreaded Programs Stephen Freund Williams College Cormac Flanagan University of California, Santa Cruz.
Types for Atomicity in Multithreaded Software Shaz Qadeer Microsoft Research (Joint work with Cormac Flanagan)
Atomicity in Multi-Threaded Programs Prachi Tiwari University of California, Santa Cruz CMPS 203 Programming Languages, Fall 2004.
C. Flanagan1Types for Atomicity Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College Shaz Qadeer Microsoft Research Analysis of Concurrent.
/ PSWLAB Atomizer: A Dynamic Atomicity Checker For Multithreaded Programs By Cormac Flanagan, Stephen N. Freund 24 th April, 2008 Hong,Shin.
CS 263 Course Project1 Survey: Type Systems for Race Detection and Atomicity Feng Zhou, 12/3/2003.
ADVERSARIAL MEMORY FOR DETECTING DESTRUCTIVE RACES Cormac Flanagan & Stephen Freund UC Santa Cruz Williams College PLDI 2010 Slides by Michelle Goodstein.
Threading Part 2 CS221 – 4/22/09. Where We Left Off Simple Threads Program: – Start a worker thread from the Main thread – Worker thread prints messages.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
Atomicity: A powerful concept for analyzing concurrent software Shaz Qadeer Microsoft Research.
C. FlanaganSAS’04: Type Inference Against Races1 Type Inference Against Races Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Developing Verifiable Concurrent Software Tevfik Bultan Department of Computer Science University of California, Santa Barbara
Modular Verification of Multithreaded Software Shaz Qadeer Compaq Systems Research Center Shaz Qadeer Compaq Systems Research Center Joint work with Cormac.
C. FlanaganDynamic Analysis for Atomicity1. C. Flanagan2Dynamic Analysis for Atomicity Atomicity The method inc() is atomic if concurrent threads do not.
C. Flanagan1Atomicity for Reliable Concurrent Software - PLDI'05 Tutorial Atomicity for Reliable Concurrent Software Joint work with Stephen Freund Shaz.
Runtime Atomicity Analysis of Multi-threaded Programs Focus is on the paper: “Atomizer: A Dynamic Atomicity Checker for Multithreaded Programs” by C. Flanagan.
Types for Atomicity in Multithreaded Software Cormac Flanagan Systems Research Center HP Labs.
Concurrency and Software Transactional Memories Satnam Singh, Microsoft Faculty Summit 2005.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 A Modular Checker for Multithreaded Programs Cormac Flanagan HP Systems Research Center Joint work with Shaz Qadeer Sanjit A. Seshia.
Verifying Commit-Atomicity Using Model Checking Cormac Flanagan University of California, Santa Cruz.
Cormac Flanagan UC Santa Cruz Velodrome: A Sound and Complete Dynamic Atomicity Checker for Multithreaded Programs Jaeheon Yi UC Santa Cruz Stephen Freund.
Threading in Java – a Tutorial QMUL IEEE SB. Why Threading When we need to run two tasks concurrently So multiple parts (>=2) of a program can run simultaneously.
C. FlanaganType Systems for Multithreaded Software1 Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College Shaz Qadeer Microsoft Research.
Parallel Processing (CS526) Spring 2012(Week 8).  Thread Status.  Synchronization in Shared Memory Programming(Java threads ) ◦ Locks ◦ Barriars.
Threading and Concurrency Issues ● Creating Threads ● In Java ● Subclassing Thread ● Implementing Runnable ● Synchronization ● Immutable ● Synchronized.
/ PSWLAB Type-Based Race Detection for J AVA by Cormac Flanagan, Stephen N. Freund 22 nd Feb 2008 presented by Hong,Shin Type-Based.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Reduction: A powerful technique for analyzing concurrent software Shaz Qadeer Microsoft Research Collaborators: Cormac Flanagan, UC Santa Cruz Stephen.
Internet Software Development Controlling Threads Paul J Krause.
Verification of obstruction-free algorithm with contention management Niloufar Shafiei.
Shared Memory Consistency Models. SMP systems support shared memory abstraction: all processors see the whole memory and can perform memory operations.
The ATOMOS Transactional Programming Language Mehdi Amirijoo Linköpings universitet.
1 OS Review Processes and Threads Chi Zhang
C H A P T E R E L E V E N Concurrent Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
Week 9, Class 3: Java’s Happens-Before Memory Model (Slides used and skipped in class) SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors:
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College
1 Announcements HW9: Java Concurrency Due Monday May 9 th Tests in HW Server coming up Check your grades in Rainbow Grades! Homework Server survey:
1 Introduction to Threads Race Conditions. 2 Process Address Space Revisited Code Data OS Stack (a)Process with Single Thread (b) Process with Two Threads.
Healing Data Races On-The-Fly
Concurrency 2 CS 2110 – Spring 2016.
Threads Cannot Be Implemented As a Library
Atomicity CS 2110 – Fall 2017.
Locking cs205: engineering software
Concurrency Specification
Multithreaded Programming in Java
Threads and Memory Models Hal Perkins Autumn 2011
More on Thread Safety CSE451 Andrew Whitaker.
Threads and Memory Models Hal Perkins Autumn 2009
Concurrency in Java Last Updated: Fall 2010 Paul Ammann SWE 619.
CSCI1600: Embedded and Real Time Software
CS333 Intro to Operating Systems
Lecture 8 Thread Safety.
CSCI1600: Embedded and Real Time Software
Problems with Locks Andrew Whitaker CSE451.
CSE 332: Concurrency and Locks
Controlled Interleaving for Transactions
Synchronization CS Spring 2002.
Threads CSE451 Andrew Whitaker TODO: print handouts for AspectRatio.
Presentation transcript:

Atomicity in Multithreaded Software Cormac Flanagan UC Santa Cruz C. Flanagan Atomicity in Multithreaded Software

Multithreaded Software Multithreading increasingly ubiquitous Current software lock-based synchronization painful, error prone, non-compositional Is there a better way transactions? yields transactions C. Flanagan Atomicity in Multithreaded Software

Race Conditions Race freedom is not sufficient to prevent errors A race condition occurs if two threads access a shared variable at the same time, and at least one of those accesses is a write int i; lock m; void inc() { acquire(m); int t = i; i = t+1; release(m); } int i; lock m; void inc() { acquire(m); int t = i; release(m); i = t+1; } race-free behaves correctly race-free behaves incorrectly Race freedom is not sufficient to prevent errors due to unexpected interactions between threads C. Flanagan Atomicity in Multithreaded Software

Atomicity in Multithreaded Software inc is atomic (serializable) if for each interleaved execution  acq(m) t=i i=t+1 rel(m) x y z there is a serial execution with same behavior  acq(m) t=i i=t+1 rel(m) x y z Atomicity simplifies method specifications informal: /* inc() increments i */ formal: ensures i == \old(i)+1 Atomicity methods are extremely common in existing code Atomicity enables sequential reasoning, simplifying: informal reasoning code inspection testing static analysis model checking formal verification C. Flanagan Atomicity in Multithreaded Software

Atomicity in Multithreaded Software Verifying Atomicity int i; lock m; void inc() { acquire(m); int t = i; i = t+1; release(m); } synchronization specification atomic Atomicity checkers synchronization implementation C. Flanagan Atomicity in Multithreaded Software

Experimental results: Atomicity in Java Most methods are atomic Most code will be transactional, many transactions will be long Protected locks common Nested transactions will be common Client-side locking common Code must work in transactions & non-transactional contexts C. Flanagan Atomicity in Multithreaded Software

java.lang.StringBuffer /** ... String buffers are safe for use by multiple threads. The methods are synchronized so that ... [atomic] */ class StringBuffer { private int count; synchronized int length() { return count; } synchronized void getChars(...) { ... } atomic synchronized void append(StringBuffer sb){ int len = sb.length(); ... sb.getChars(...,len,...); } StringIndexOutOfBoundsException C. Flanagan Atomicity in Multithreaded Software

java.lang.StringBuffer /** ... String buffers are safe for use by multiple threads. The methods are synchronized so that ... [atomic] */ class StringBuffer { private int count; synchronized int length() { return count; } synchronized void getChars(...) { ... } atomic synchronized void append(StringBuffer sb){ synchronized (sb) { int len = sb.length(); ... sb.getChars(...,len,...); } Deadlock C. Flanagan Atomicity in Multithreaded Software

Atomicity in Multithreaded Software Conclusions Current software is already “transactional” (via clumsy, error-prone locking) most code is transactional some transactions are long nested transactions are common Need to support modular software architectures C. Flanagan Atomicity in Multithreaded Software