A Parameterized Type System for Race-Free Java Programs Paper by Boyapti & Rinard, 2001 Christopher Dentel ETH, Concepts of Concurrent Computation, 2012.

Slides:



Advertisements
Similar presentations
Chapter 4 Constructors and Destructors. Objectives Constructors – introduction and features The zero-argument constructor Parameterized constructors Creating.
Advertisements

Eiffel: Analysis, Design and Programming Bertrand Meyer (Nadia Polikarpova) Chair of Software Engineering.
CPSC 388 – Compiler Design and Construction
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, toString reading: self-checks: #13-18,
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
1 COSC2767: Object-Oriented Programming Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University.
C. FlanaganSAS’04: Type Inference Against Races1 Type Inference Against Races Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College.
Unit 4II 1 More about classes H Defining classes revisited H Constructors H Defining methods and passing parameters H Visibility modifiers and encapsulation.
Ownership Types for Safe Programming: Preventing Data Races and Deadlocks Chandrasekhar Boyapati Robert Lee Martin Rinard Laboratory for Computer Science.
Synchronization in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
A Parameterized Type System for Race-Free Java Programs Chandrasekhar Boyapati Martin Rinard Laboratory for Computer Science Massachusetts Institute of.
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
Threads CNS What is a thread?  an independent unit of execution within a process  a "lightweight process"  an independent unit of execution within.
1 Further OO Concepts II – Java Program at run-time Overview l Steps in Executing a Java Program. l Loading l Linking l Initialization l Creation of Objects.
0wn3rship Types John Whaley CS343 Stanford University May 19, 2004.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Comparison of OO Programming Languages © Jason Voegele, 2003.
Appendix A.2: Review of Java and Object-Oriented Programming: Part 2 “For the object-oriented project, remember that the primary unit of decomposition.
Modern Concurrency Abstractions for C# by Nick Benton, Luca Cardelli & C´EDRIC FOURNET Microsoft Research.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
16 - Generics. 2 NOEA2009Java-kursus – Generics ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Static and Dynamic Behavior CMPS Power of OOP Derives from the ability of objects to change their behavior dynamically at run time. Static – refers.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Threading and Concurrency Issues ● Creating Threads ● In Java ● Subclassing Thread ● Implementing Runnable ● Synchronization ● Immutable ● Synchronized.
The University of Adelaide, School of Computer Science
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
C++ Function 1. Function allow to structure programs in segment of code to perform individual tasks. In C++, a function is a group of statements that.
/ PSWLAB Type-Based Race Detection for J AVA by Cormac Flanagan, Stephen N. Freund 22 nd Feb 2008 presented by Hong,Shin Type-Based.
Introduction to Object Oriented Programming CMSC 331.
1 SystemVerilog Enhancement Requests Daniel Schostak Principal Engineer February 26 th 2010.
Threads and Thread Control Thread Concepts Pthread Creation and Termination Pthread synchronization Threads and Signals.
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
November 2005Scott Stoller, Stony Brook University1 Detecting Potential Deadlocks with Static Analysis and Run-Time Monitoring Rahul Agarwal, Liqiang Wang,
15.1 Threads and Multi- threading Understanding threads and multi-threading In general, modern computers perform one task at a time It is often.
SPL/2010 Synchronization 1. SPL/2010 Overview ● synchronization mechanisms in modern RTEs ● concurrency issues ● places where synchronization is needed.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
ICBT  Basura Ramanayaka  Eshani werapitiya  Hasitha Dananjaya.
12/22/ Thread Model for Realizing Concurrency B. Ramamurthy.
A Thread-Parallel Geant4 with Shared Geometry Gene Cooperman and Xin Dong College of Computer and Information Science Northeastern University 360 Huntington.
Threads. Objectives You must be able to answer the following questions –What code does a thread execute? –What states can a thread be in? –How does a.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
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.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
(c) University of Washington06-1 CSC 143 Java Inheritance Tidbits.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Fall, Privacy&Security - Virginia Tech – Computer Science Click to edit Master title style JFlow: Practical Mostly-Static Information Flow Control.
Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College
1 Towards Automated Verification Through Type Discovery Joint work with Rahul Agarwal Scott D. Stoller State University of New York at Stony Brook.
Type Checking and Type Inference
Advanced Topics in Concurrency and Reactive Programming: Asynchronous Programming Majeed Kassis.
Computer Engg, IIT(BHU)
Realizing Concurrency using Posix Threads (pthreads)
Multithreading.
Realizing Concurrency using Posix Threads (pthreads)
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CIS 199 Final Review.
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
SPL – PS3 C++ Classes.
Previous Lecture: Today’s Lecture: Reading (JV):
Presentation transcript:

A Parameterized Type System for Race-Free Java Programs Paper by Boyapti & Rinard, 2001 Christopher Dentel ETH, Concepts of Concurrent Computation, 2012

Concurrent “Gold Standard” Expressive, flexible system Data races are impossible Reduce unnecessary lock acquisitions

Parameterized Race Free Java (PRFJ) Based on Concurrent Java Static type system for multithreaded Java Guarantees all well-typed systems are race free Classes have “generic” locking implementation Different instances can have different lock synchronization behavior Minimal programming overhead

How does PRFJ accomplish this? Goal: Race-Free Programs Objects must be “owned” by Themselves, Other objects, OR Thread (local to thread) Ownership does not change Ownership declared as first generic parameter

Consequences of Ownership “Forest of rooted trees, where the roots can have self loops” Necessary and sufficient for object to hold root lock Thread implicitly holds lock on objects it owns

PRFJ Accounts class Account { int balance = 0; int deposit(int x) requires (this) { this.balance = this.balance + x; } Account a1 = new Account ; a1.deposit(10); Account a2 = new Account ; fork(a2) {synchronized (a2) in { a2.deposit(10)}};

Unique ownership mechanism Unique: only one pointer at a time If only one pointer exists, then no need for locks Producer consumer design pattern Can “hand off” object to another thread or safely pass Accomplished through 2 mechanisms Pointer surrendering Sharing pointer with “non escaping” methods

Pointer Surrendering Queue > q = new Queue >(); T t1 = new T ; T t2 = new T ; synchronized (q) in {q.offer( t1-- );} synchronized (q) in {q.offer( t2-- );} fork(q) {synchronized(q) in {T t=q.poll();}} Surrender pointer using ‘*--‘ syntax

Sharing pointer with “non escaping” methods Keep object in the same thread Methods denote this by appending ‘!e’ to the type class Message {…} class Util { void display(Message<MsgOwner !e m) requires(m){…} } Util u = new Util ; Message m = new Message u.display(m);

Implementation Overhead

Runtime Overhead Statically Typed Ownership relations only checked at compile time PRFJ can be compiled to Concurrent Java But further optimizations can be made Heap-space allocation

Limitations and Criticisms Runtime Casts No way to check ownership at runtime Static Variables Must hold lock for class

Parameterized Race Free Java Flexible Generic protection mechanisms Efficient Runtime Implementation Avoids unnecessary locks

Default Types Single-Threaded Program Ownership of class constrained to thisThread Any unparameterized instance variables owned by thisThread Any unparameterized methods have empty requires clause Multithreaded Programs Ownership of class constrained to thisOwner Unparamaterized instance variables owned by thisOwner Unparamterized methods require this and all arguments

Self Synchronization class SharedAccount extends Account { int deposit(int x) requires () { syncrhonized(this) in {super.deposit(x);} } SharedAccount a = new SharedAccount ; fork(a) {a.deposit(10)}; Constant value used instead of a formal parameter