Jcc:TimedDefault cc Programming in JAVA Vijay Saraswat, IBM Research Radha Jagadeesan, DePaul University Vineet Gupta, Google.

Slides:



Advertisements
Similar presentations
System Integration and Performance
Advertisements

Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
1 Chapter 1 Why Parallel Computing? An Introduction to Parallel Programming Peter Pacheco.
Locks (Java 1.5) Only one thread can hold a lock at once –Other threads that try to acquire it block (or become suspended) until lock becomes available.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
CS444/CS544 Operating Systems Introduction to Synchronization 2/07/2007 Prof. Searleman
Getting Started with MPI Self Test with solution.
CS444/CS544 Operating Systems Synchronization 2/16/2006 Prof. Searleman
Threads Load new page Page is loading Browser still responds to user (can read pages in other tabs)
Introduction to Input and Output. Layers (or Tiers) of an Application  Software in the real world normally takes the form of a number of independent.
CS 584. A Parallel Programming Model We need abstractions to make it simple. The programming model needs to fit our parallel machine model. Abstractions.
Programming Language Semantics Java Threads and Locks Informal Introduction The Java Specification Language Chapter 17.
CS444/CS544 Operating Systems Synchronization 2/21/2007 Prof. Searleman
Chapter 11 Operating Systems
Threads A thread is a program unit that is executed independently of other parts of the program A thread is a program unit that is executed independently.
29-Jun-15 Java Concurrency. Definitions Parallel processes—two or more Threads are running simultaneously, on different cores (processors), in the same.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
User-Level Interprocess Communication for Shared Memory Multiprocessors Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented.
© The McGraw-Hill Companies, 2006 Chapter 7 Implementing classes.
1 Thread-specific Storage (TSS) Storage/space (a variable) per thread. –A variable is associated with a thread. –The per-thread variable is never touched.
1 Advanced Computer Programming Concurrency Multithreaded Programs Copyright © Texas Education Agency, 2013.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
1 Advanced Flow of Control - Introduction - zTwo additional mechanisms for controlling process execution are exceptions and threads zChapter 14 focuses.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Object Oriented Programming Lecture 8: Introduction to laboratorial exercise – part II, Introduction to GUI frames in Netbeans, Introduction to threads.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
Multi-core systems System Architecture COMP25212 Daniel Goodman Advanced Processor Technologies Group.
Threading and Concurrency Issues ● Creating Threads ● In Java ● Subclassing Thread ● Implementing Runnable ● Synchronization ● Immutable ● Synchronized.
TCC, With History RADHA JAGADEESAN (WITH VINEET GUPTA AND VIJAY SARASWAT)
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
1 Concurrent Languages – Part 1 COMP 640 Programming Languages.
Object-Oriented Programming (OOP). Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package.
Java Software Solutions Lewis and Loftus Chapter 14 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Advanced Flow of Control --
Practical OOP using Java Basis Faqueer Tanvir Ahmed, 08 Jan 2012.
Multithreading : synchronization. Avanced Programming 2004, Based on LYS Stefanus’s slides slide 4.2 Solving the Race Condition Problem A thread must.
1 Lecture 5 (part2) : “Interprocess communication” n reasons for process cooperation n types of message passing n direct and indirect message passing n.
Internet Software Development Controlling Threads Paul J Krause.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
OPERATING SYSTEMS Frans Sanen.  Recap of threads in Java  Learn to think about synchronization problems in Java  Solve synchronization problems in.
Computing Simulation in Orders Based Transparent Parallelizing Pavlenko Vitaliy Danilovich, Odessa National Polytechnic University Burdeinyi Viktor Viktorovych,
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
Session 13 Pinball Game Construction Kit (Version 3):
CS 838: Pervasive Parallelism Introduction to pthreads Copyright 2005 Mark D. Hill University of Wisconsin-Madison Slides are derived from online references.
Department of Computer Science and Software Engineering
12/22/ Thread Model for Realizing Concurrency B. Ramamurthy.
Transactions. Transaction: Informal Definition A transaction is a piece of code that accesses a shared database such that each transaction accesses shared.
Programming Languages and Paradigms Activation Records in Java.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
Fall 2008Programming Development Techniques 1 Topic 20 Concurrency Section 3.4.
 Program Abstractions  Concepts  ACE Structure.
1 Ivan Marsic Rutgers University LECTURE 19: Concurrent Programming.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
1 Java Programming Java Programming II Concurrent Programming: Threads ( I)
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Agenda  Quick Review  Finish Introduction  Java Threads.
Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Transactions.
Concurrency and Immutability
Rick Molloy Senior Developer Microsoft Startup Business Group
Java Concurrency.
Introduction to Object-Oriented Programming
CSE 153 Design of Operating Systems Winter 2019
Java Concurrency.
CSE 332: Concurrency and Locks
Presentation transcript:

jcc:TimedDefault cc Programming in JAVA Vijay Saraswat, IBM Research Radha Jagadeesan, DePaul University Vineet Gupta, Google

Concurrent programming in Java Threads, shared heap, separate stack Synchronization based on locking mutable objects in shared heap Rules to govern information flow between thread-specific data structures (heap cache, stack) and shared store.

Concurrent programming in Java `` Unfortunately the current specification has been found to be hard to understand and has subtle, often unintended, implications….. Several important issues [….] simply aren't discussed in the existing specification.''

Concurrent programming in Java Concurrent execution in Java is the default. Every line of Java code could be executed in parallel by multiple threads on the same object.

The Jcc model jcc= JAVA −Threads +Vats +Promises +Agents

Jcc Design Goals Interoperability with Java: source code, JVM, and type system API for the programmer to add new constraint systems Support for reflective meta-programming The implementation should be usable for medium-sized programs.

Rest of the talk  An example Bank application  The design elements of Jcc.

The bank application Withdrawal Deposit

The Bank application: Withdrawals Withdrawals succeed if balance is large enough. If not, repeat withdrawal after each of the next n deposits. If balance still not large enough, it is rejected.

The bank application Ravi Withdrawal Account1 (zero) Account2 Deposit(100)suspend

The bank application Ravi Withdrawal Account1 (25) Account2 Deposit(100) Deposits 25 suspend

The bank application Ravi Withdrawal Account1 (100) Account2 Deposit(100) Deposits 25 each

Rest of the talk  An example Bank application  The design elements of Jcc.

Vats and ports Stack Heap Ports Local stack/heap Single threaded JVM = Multiple vats + Shared heap of immutable objects

Communication: Ports Each port is located at a vat and is “read” only by code at that vat Each port can have multiple writers/tellers at other vats Objects written into ports are deep-copied from source to target vat

Vats and ports in the bank application Ravi Withdrawal Account1 (zero) Account2 Deposit(100)suspend

Execution in a Vat Process 1 message at a time to completion before getting another message: create new local heap objects invoke methods on objects in heap send objects to ports in another vat All these operations do not block! Bounded response guarantees?

Logical time A logical time-step: receive input compute response Correspondence to physical time if bounded response can be guaranteed cf. Esterel.

Logical time in the bank application Withdrawal Account1 (zero) Time steps: 0. Withdrawal(100) 1. Deposit(25) 2. Deposit(25) 3. Deposit(25) 4. Deposit(25)

Time based control constructs 1) next {S}. S is stored and executed in the next time instant. 2) always {S}: Run S at EVERY time instant Oops! Many programs can be executing at the same time instant

Mutiple programs in the Account1 vat of the bank application Withdrawal Account1 (zero) Time steps: 0. Withdrawal(100): “withdrawal code” 1. Deposit(25): “withdrawal, deposit code” 2. Deposit(25): “withdrawal, deposit code” 3. Deposit(25): as above 4. Deposit(25): as above

Constraints for Intra-Vat communication How to achieve determinate concurrency? Concurrent constraint programming! Store

Constraint stores in Jcc Each vat has its own store All items in a store are dropped at the end of a time instant: programmer carries items into following time instant explicitly using next. Constraints via promises (= typed logical variables) in Jcc.

Promises Promise in Jcc = java.lang.Object in Java 1.Unrealized and unwatched. [new variables] 2.Realized [new constants] 3.Bound [o.equate(p) ] 4.Unrealized and watched

Watchers for promises When (p) do S If p is realized, run S. Otherwise, suspend S on p. S is a watcher for p Effect of p.equate(q)??

Watchers for promises every (p) do S run S in every time instant in which p is realized

Code for Account public BankAccount() { every (balanceUpdate) { // check if pending withdrawals // can be satisfied }

Code for Account public Confirmation deposit(Integer amount){ Confirmation result = new Confirmation(); when (amount) { // update balance result.equate(“Success”); } return result; }

Code for Account public Confirmation withdraw(Integer amount){ Confirmation result = new Confirmation(); when (amount) { // check balance // if balance sufficient result.equate(“Success”); //if balance not sufficient, add to pending list } return result; }

Conclusions jcc= JAVA −Threads +Vats +Promises +Agents Full power of Timed Default cc in Java.