Checking Concurrent Java Programs
|
|
- Darrell Smith
- 6 years ago
- Views:
Transcription
1 Checking Concurrent Java Programs On Event Spaces Néstor CATAÑO INRIA Sophia-Antipolis, France ModoCop,1st July 2002 p.1/22
2 Outline Concurrent Java programs Event Spaces Constructing Event Spaces Checking specifications using Event Spaces Checking JINI Properties Future work ModoCop,1st July 2002 p.2/22
3 Concurrent Java programs Threads ModoCop,1st July 2002 p.3/22
4 Concurrent Java programs Threads Shared variables ModoCop,1st July 2002 p.3/22
5 Concurrent Java programs Threads Shared variables synchronized ModoCop,1st July 2002 p.3/22
6 Concurrent Java programs Threads Shared variables synchronized notifyall ModoCop,1st July 2002 p.3/22
7 Concurrent Java programs Threads Shared variables synchronized notifyall wait ModoCop,1st July 2002 p.3/22
8 Concurrent Java programs Threads Shared variables synchronized notifyall wait notify ModoCop,1st July 2002 p.3/22
9 Threads communication protocol Main memory M.M. buffer Local buffer Working memory ModoCop,1st July 2002 p.4/22
10 Threads communication protocol Main memory M.M. buffer read Local buffer Working memory ModoCop,1st July 2002 p.4/22
11 Threads communication protocol Main memory M.M. buffer read load Local buffer Working memory ModoCop,1st July 2002 p.4/22
12 Threads communication protocol Main memory M.M. buffer read load Local buffer use Working memory ModoCop,1st July 2002 p.4/22
13 Threads communication protocol Main memory M.M. buffer read load Local buffer use Working memory assign ModoCop,1st July 2002 p.4/22
14 Threads communication protocol Main memory M.M. buffer read load store Local buffer use Working memory assign ModoCop,1st July 2002 p.4/22
15 Threads communication protocol write Main memory M.M. buffer read load store Local buffer use Working memory assign ModoCop,1st July 2002 p.4/22
16 Threads communication protocol write lock Main memory M.M. buffer read load store Local buffer use Working memory assign ModoCop,1st July 2002 p.4/22
17 Threads communication protocol write lock Main memory M.M. buffer read load store unlock Local buffer use Working memory assign ModoCop,1st July 2002 p.4/22
18 Outline Concurrent Java programs Event Spaces Constructing Event Spaces Checking specifications using Event Spaces Checking JINI Properties Future work ModoCop,1st July 2002 p.5/22
19 Event Spaces [ Pietro Cenciarelli, Alexander Knapp, Bernhard Reus, Tatjana Hein, Marting Wirsing] at LMU Universität München. ModoCop,1st July 2002 p.6/22
20 Event Spaces [ Pietro Cenciarelli, Alexander Knapp, Bernhard Reus, Tatjana Hein, Marting Wirsing] at LMU Universität München. The actions performed by the main memory for any one variable are totally ordered; that is, for any two actions performed by the main memory on the same variable, one action precedes the other. ModoCop,1st July 2002 p.6/22
21 Event Spaces [ Pietro Cenciarelli, Alexander Knapp, Bernhard Reus, Tatjana Hein, Marting Wirsing] at LMU Universität München. The actions performed by the main memory for any one variable are totally ordered; that is, for any two actions performed by the main memory on the same variable, one action precedes the other. Formally where and are instances of {Write(,l,v), Read(,l,v)} ModoCop,1st July 2002 p.6/22
22 Event Spaces The actions performed by any one thread are totally ordered; that is, for any two actions performed by a thread, one action precedes the other. Formally where and are instances of {Lock( Use( Load(,obj), Unlock(,l,v), Assign(,l,v), Store(,obj),,l,v),,l,v)} ModoCop,1st July 2002 p.7/22
23 Operational Semantics ModoCop,1st July 2002 p.8/22
24 Outline Concurrent Java programs Event Spaces Constructing Event Spaces Checking specifications using Event Spaces Checking JINI Properties Future work ModoCop,1st July 2002 p.9/22
25 Constructing Event Spaces class C int a=1, b=2; } synchronized void p(){ a=b; } synchronized void q(){ b=a; } ModoCop,1st July 2002 p.10/22
26 Constructing Event Spaces synchronized void p(){a=b;} a=b ModoCop,1st July 2002 p.11/22
27 Constructing Event Spaces use b synchronized void p(){a=b;} assign a ModoCop,1st July 2002 p.11/22
28 Constructing Event Spaces use b assign a synchronized void p(){a=b;} A thread must perform an assign or load action on a variable before performing a use or store ModoCop,1st July 2002 p.11/22
29 Constructing Event Spaces load b use b synchronized void p(){a=b;} assign a ModoCop,1st July 2002 p.11/22
30 Constructing Event Spaces load b use b assign a synchronized void p(){a=b;} For every load action performed by any thread on its working copy of a variable, there must be a corresponding preceding read action by the main memory on the master copy of, and the load action must put into the working copy the data transmitted by the corresponding read action ModoCop,1st July 2002 p.11/22
31 Constructing Event Spaces read b load b use b synchronized void p(){a=b;} assign a ModoCop,1st July 2002 p.11/22
32 Constructing Event Spaces read b load b use b assign a synchronized void p(){a=b;} Before executing a synchronized method, the corresponding object must be locked ModoCop,1st July 2002 p.11/22
33 Constructing Event Spaces lock c read b load b use b synchronized void p(){a=b;} assign a ModoCop,1st July 2002 p.11/22
34 Constructing Event Spaces lock c read b load b use b assign a synchronized void p(){a=b;} Between an assign action by on and a subsequent unlock action by on, a store action by on must intervene; moreover, the write action corresponding to that blue store must precede the unlock action, as seen by main memory ModoCop,1st July 2002 p.11/22
35 Constructing Event Spaces lock c read b load b use b synchronized void p(){a=b;} assign a store a write a unlock c ModoCop,1st July 2002 p.11/22
36 Constructing Event Spaces lock c read b load b use b assign a synchronized void p(){a=b;} synchronized void q(){b=a;} store a write a unlock c ModoCop,1st July 2002 p.11/22
37 Constructing Event Spaces lock c read b load b use b load a use a lock c read a synchronized void p(){a=b;} assign a store a assign b store b synchronized void q(){b=a;} unlock c write a unlock c write b ModoCop,1st July 2002 p.11/22
38 Outline Concurrent Java programs Event Spaces Constructing Event Spaces Checking specifications using Event Spaces Checking JINI Properties Future work ModoCop,1st July 2002 p.12/22
39 Chec.spec. using Event Spaces public class Sample{ int a=1, b=2; ensures(this): this.a==this.b; synchronized void p(){ a=b; } //@ ensures(this): this.b==this.a; synchronized void q(){ b=a; } /*@ forall[s:sample, thp:myrunnerp, thq:myrunnerq]. AG((MyRunnerP_INSTANCE(s) AND MyRunnerQ_INSTANCE(s)) --> AG((MyRunnerP_RUN(thp) MyRunnerQ_RUN(thq)) --> AF(s.a==1 AND s.b==1) OR (s.a=2 AND s.a==2==s.b))) */ public static void main(string args[]){ Sample s = new Sample(); MyRunnerP thp = new MyRunnerP(s); MyRunnerQ thq = new MyRunnerQ(s); thp.start(); thq.start(); } } ModoCop,1st July 2002 p.13/22
40 Check.spec. using Event Spaces public class MyRunnerP extends java.lang.thread{ Sample mysample_p; ensures mysample_p == s; MyRunnerP(Sample s){ super(); mysample_p = s; } } //@ ensures Sample_p_ENS(mysample_p); public void run(){ mysample_p.p(); } ModoCop,1st July 2002 p.14/22
41 Check.spec. using Event Spaces lock c read b load b use b assign a store a write a unlock c lock c read a load a use a assign b store b write b unlock c ModoCop,1st July 2002 p.15/22
42 Check.spec. using Event Spaces lock c read b load b use b assign a store a write a lock c read a load a use a assign b store b write b read a write a, write b read b unlock c unlock c ModoCop,1st July 2002 p.15/22
43 Check.spec. using Event Spaces lock c read b load b use b assign a store a write a load a use a assign b store b lock c read a write b read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) unlock c unlock c ModoCop,1st July 2002 p.15/22
44 Check.spec. using Event Spaces lock c read b load b use b assign a store a write a load a use a assign b store b lock c read a write b read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) write a read a, read b write b unlock c unlock c ModoCop,1st July 2002 p.15/22
45 Check.spec. using Event Spaces lock c read b load b use b assign a store a write a load a use a assign b store b lock c read a write b read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) write a read a, read b write b (pa=2,pb=2,ma=2,mb=2,qa=2,qb=2) unlock c unlock c ModoCop,1st July 2002 p.15/22
46 Check.spec. using Event Spaces lock c read b load b use b load a use a lock c read a read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) write a read a, read b write b (pa=2,pb=2,ma=2,mb=2,qa=2,qb=2) assign a assign b write b read b, write a read a store a store b unlock c write a unlock c write b ModoCop,1st July 2002 p.15/22
47 Check.spec. using Event Spaces lock c read b load b use b load a use a lock c read a read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) write a read a, read b write b (pa=2,pb=2,ma=2,mb=2,qa=2,qb=2) assign a assign b write b read b, write a read a store a write a store b (It is not permitted for an action to follow itself) write b unlock c unlock c ModoCop,1st July 2002 p.15/22
48 Check.spec. using Event Spaces lock c read b load b use b load a use a lock c read a read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) write a read a, read b write b (pa=2,pb=2,ma=2,mb=2,qa=2,qb=2) assign a assign b write b read b, write a read a store a write a store b (It is not permitted for an action to follow itself) write b read b write b, read a write a unlock c unlock c ModoCop,1st July 2002 p.15/22
49 Check.spec. using Event Spaces lock c read b load b use b load a use a lock c read a read a write a, write b read b (pa=1,pb=1,ma=1,mb=1,qa=1,qb=1) write a read a, read b write b (pa=2,pb=2,ma=2,mb=2,qa=2,qb=2) assign a assign b write b read b, write a read a store a write a store b (It is not permitted for an action to follow itself) write b read b write b, read a write a [lock-unlock] unlock c unlock c ModoCop,1st July 2002 p.15/22
50 Outline Concurrent Java programs Event Spaces Constructing Event Spaces Checking specifications using Event Spaces Checking JINI Properties Future work ModoCop,1st July 2002 p.16/22
51 What is JINI Lookup Service Sproxy 1. The service S registers a Sproxy to the lookup service 2. Requiring a service fulfilling the type SInterface Service S 3. Requiring directly services Client C SInterface Sproxy by using the proxy Sproxy Sproxy ModoCop,1st July 2002 p.17/22
52 Checking JINI Properties Class LookupDiscovery is composed by thread inner classes that communicate with each other by shared variables ModoCop,1st July 2002 p.18/22
53 Checking JINI Properties Class LookupDiscovery is composed by thread inner classes that communicate with each other by shared variables Shared variables correspond to instances of collection classes: Collection, ArryList, HashMap, etc. ModoCop,1st July 2002 p.18/22
54 Checking JINI Properties Class LookupDiscovery is composed by thread inner classes that communicate with each other by shared variables Shared variables correspond to instances of collection classes: Collection, ArryList, HashMap, etc. If a certain client carries out successfully a matching protocol, then whenever there exists an adequate announcement coming from the net, the client will be informed. ModoCop,1st July 2002 p.18/22
55 Checking JINI Properties /* * forall[b:lookupdiscovery, inc:incomingmulticastannouncement]. * AG(if(b.LookupDiscovery_LookupDiscovery_CALL(String groups[]) & * b.lookupdiscovery_adddiscoverylistener_call(listener list) * ) --> * AF(forall[inc:IncomingMulticastAnnouncement]. * if(inc.serviceid IN registrars & * groupsoverlap(b,inc.groups) & * inc.locator!in b.pendingdiscoveries * ) --> * AF(if(list.groups IN inc.groups) * if(list.eventtype == LookupDiscovery.DISCOVERED) * list.discovered(); * else if(list.eventtype == LookupDiscovery.DISCARDED) * list.discarded(); * else if(list.eventtype == LookupDiscovery.CHANGED) * list.changed(); * ) * ) ModoCop,1st July 2002 p.19/22
56 Outline Concurrent Java programs Event Spaces Constructing Event Spaces Checking specifications using Event Spaces Checking JINI Properties Future work ModoCop,1st July 2002 p.20/22
57 Future work loops: if( ){ }, while( ){ }, and so on. ModoCop,1st July 2002 p.21/22
58 Future work loops: if( ){ }, while( ){ }, and so on. Generate automatically Event Spaces for Java programs. ModoCop,1st July 2002 p.21/22
59 Future work loops: if( ){ }, while( ){ }, and so on. Generate automatically Event Spaces for Java programs. Establish whether an Event Space respects a property. ModoCop,1st July 2002 p.21/22
60 Future work loops: if( ){ }, while( ){ }, and so on. Generate automatically Event Spaces for Java programs. Establish whether an Event Space respects a property. Compute Event Spaces parameterized by the property we check. ModoCop,1st July 2002 p.21/22
61 Future work loops: if( ){ }, while( ){ }, and so on. Generate automatically Event Spaces for Java programs. Establish whether an Event Space respects a property. Compute Event Spaces parameterized by the property we check. Event spaces and JavaCard 2.2: there is limited concurrency. ModoCop,1st July 2002 p.21/22
62 Future work loops: if( ){ }, while( ){ }, and so on. Generate automatically Event Spaces for Java programs. Establish whether an Event Space respects a property. Compute Event Spaces parameterized by the property we check. Event spaces and JavaCard 2.2: there is limited concurrency. Diving into the Jini problem. ModoCop,1st July 2002 p.21/22
63 Thanks Any suggestions? ModoCop,1st July 2002 p.22/22
CS 153 Lab4 and 5. Kishore Kumar Pusukuri. Kishore Kumar Pusukuri CS 153 Lab4 and 5
CS 153 Lab4 and 5 Kishore Kumar Pusukuri Outline Introduction A thread is a straightforward concept : a single sequential flow of control. In traditional operating systems, each process has an address
More informationPart IV Other Systems: I Java Threads
Part IV Other Systems: I Java Threads Spring 2019 C is quirky, flawed, and an enormous success. 1 Dennis M. Ritchie Java Threads: 1/6 Java has two ways to create threads: Create a new class derived from
More informationCOMPSCI 230 Threading Week8. Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/]
COMPSCI 230 Threading Week8 Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/] Synchronization Lock DeadLock Why do we need Synchronization in Java? If your code is executing
More informationCMSC330 Spring 2014 Midterm 2 Solutions
CMSC330 Spring 2014 Midterm 2 Solutions 1. (16 pts) OCaml Types and Type Inference Give the type of the following OCaml expressions: a. (2 pts) fun b -> b + 8 Type = int -> int b. (3 pts) fun b -> b 8
More informationWeak 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 informationWriting Parallel Programs COMP360
Writing Parallel Programs COMP360 We stand at the threshold of a many core world. The hardware community is ready to cross this threshold. The parallel software community is not. Tim Mattson principal
More informationWhat's wrong with Semaphores?
Next: Monitors and Condition Variables What is wrong with semaphores? Monitors What are they? How do we implement monitors? Two types of monitors: Mesa and Hoare Compare semaphore and monitors Lecture
More informationThreads and Parallelism in Java
Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program
More informationMulti-threaded programming in Java
Multi-threaded programming in Java Java allows program to specify multiple threads of execution Provides instructions to ensure mutual exclusion, and selective blocking/unblocking of threads What is a
More informationECE 587 Hardware/Software Co-Design Lecture 07 Concurrency in Practice Shared Memory I
ECE 587 Hardware/Software Co-Design Spring 2018 1/15 ECE 587 Hardware/Software Co-Design Lecture 07 Concurrency in Practice Shared Memory I Professor Jia Wang Department of Electrical and Computer Engineering
More informationCS18000: Programming I
CS18000: Programming I Synchronization 22 February, 2010 Prof. Chris Clifton Concurrency Example: Banking class ATM { public void withdrawcash(acct a) { Scanner sc = new Scanner(System.in); int amount
More informationProducing Production Quality Software. Lecture 12: Concurrent and Distributed Programming Prof. Arthur P. Goldberg Fall, 2004
Producing Production Quality Software Lecture 12: Concurrent and Distributed Programming Prof. Arthur P. Goldberg Fall, 2004 Topics Models of concurrency Concurrency in Java 2 Why Use Concurrency? Enable
More informationLecture 29: Java s synchronized statement
COMP 322: Fundamentals of Parallel Programming Lecture 29: Java s synchronized statement Vivek Sarkar Department of Computer Science, Rice University vsarkar@rice.edu https://wiki.rice.edu/confluence/display/parprog/comp322
More informationThe Proxy Pattern. Design Patterns In Java Bob Tarr
The Proxy Pattern Intent Provide a surrogate or placeholder for another object to control access to it Also Known As Surrogate Motivation A proxy is a person authorized to act for another person an agent
More informationProblems with Concurrency. February 19, 2014
with Concurrency February 19, 2014 s with concurrency interleavings race conditions dead GUI source of s non-determinism deterministic execution model 2 / 30 General ideas Shared variable Access interleavings
More informationPerformance Throughput Utilization of system resources
Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency
More informationSynchronization in Concurrent Programming. Amit Gupta
Synchronization in Concurrent Programming Amit Gupta Announcements Project 1 grades are out on blackboard. Detailed Grade sheets to be distributed after class. Project 2 grades should be out by next Thursday.
More informationCOMP31212: Concurrency A Review of Java Concurrency. Giles Reger
COMP31212: Concurrency A Review of Java Concurrency Giles Reger Outline What are Java Threads? In Java, concurrency is achieved by Threads A Java Thread object is just an object on the heap, like any other
More informationsimilar structures in operational semantics, a technique which is new, to our knowledge, we obtain an abstract \declarative" description of the Java t
From Sequential to Multi-Threaded Java: an Event-Based Operational Semantics Pietro Cenciarelli, Alexander Knapp, Bernhard Reus, and Martin Wirsing Ludwig{Maximilians{Universitat Munchen fcenciare,knapp,reus,wirsingg@informatik.uni-muenchen.de
More informationClass definition. complete definition. public public class abstract no instance can be created final class cannot be extended
JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can
More informationCS 556 Distributed Systems
CS 556 Distributed Systems Tutorial on 4 Oct 2002 Threads A thread is a lightweight process a single sequential flow of execution within a program Threads make possible the implementation of programs that
More informationMonitors; Software Transactional Memory
Monitors; Software Transactional Memory Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico October 18, 2012 CPD (DEI / IST) Parallel and
More informationMonitors CSCI 201 Principles of Software Development
Monitors CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline Monitors Program USC CSCI 201L Monitor Overview A monitor is an object with mutual exclusion and
More informationC++ Concurrency - Formalised
C++ Concurrency - Formalised Salomon Sickert Technische Universität München 26 th April 2013 Mutex Algorithms At most one thread is in the critical section at any time. 2 / 35 Dekker s Mutex Algorithm
More informationCMSC 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 informationRemote Procedure Call
Remote Procedure Call Suited for Client-Server structure. Combines aspects of monitors and synchronous message passing: Module (remote object) exports operations, invoked with call. call blocks (delays
More informationCOMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors
COMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors Howard Barringer Room KB2.20: email: Howard.Barringer@manchester.ac.uk February 2009 Outline Monitors FSP Models-to-Java Monitors Producers/Consumers
More informationUser Space Multithreading. Computer Science, University of Warwick
User Space Multithreading 1 Threads Thread short for thread of execution/control B efore create Global During create Global Data Data Executing Code Code Stack Stack Stack A fter create Global Data Executing
More informationCSCI 201L Final Written SOLUTION. 13% of course grade
SOLUTION 13% of course grade 1. Generics C++ has had templates long before Java even existed as a language. When Java was created, there were no templates or generics. It wasn t until many years and many
More informationMVP1: Introduction to concurrency in JAVA
MVP1: Introduction to concurrency in JAVA Concurrency? A naive definition: More than one thing (activity) at a time. Independent activities: web download, number crunching, program editing, print. Dependent
More informationProgramming in Parallel COMP755
Programming in Parallel COMP755 All games have morals; and the game of Snakes and Ladders captures, as no other activity can hope to do, the eternal truth that for every ladder you hope to climb, a snake
More informationReal-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify
http://cs.lth.se/eda040 Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify Klas Nilsson 2016-09-20 http://cs.lth.se/eda040 F4: Monitors: synchronized, wait and
More informationPSis - Programação de Sistemas 2014/2015 Exame 1ª Época, 8 de Junho de 2015, 8h00, Duração: 2h
Software Design 1. [1 value] One of the key principles of systems design is the Principle of Least Knowledge. Describe this principle Explaining the problems that arise by not following it. Explain how
More informationMultiple Inheritance. Computer object can be viewed as
Multiple Inheritance We have seen that a class may be derived from a given parent class. It is sometimes useful to allow a class to be derived from more than one parent, inheriting members of all parents.
More informationLecture 9: Introduction to Monitors
COMP 150-CCP Concurrent Programming Lecture 9: Introduction to Monitors Dr. Richard S. Hall rickhall@cs.tufts.edu Concurrent programming February 14, 2008 Abstracting Locking Details Recall our discussion
More informationSynchronization II: EventBarrier, Monitor, and a Semaphore. COMPSCI210 Recitation 4th Mar 2013 Vamsi Thummala
Synchronization II: EventBarrier, Monitor, and a Semaphore COMPSCI210 Recitation 4th Mar 2013 Vamsi Thummala Check point: Mission in progress Master synchronization techniques Develop best practices for
More informationMultitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit
Threads Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multitasking Thread-based multitasking Multitasking
More informationMultithreaded Programming
Multithreaded Programming Multithreaded programming basics Concurrency is the ability to run multiple parts of the program in parallel. In Concurrent programming, there are two units of execution: Processes
More informationOperating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst
Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Clicker Question #1 If we have 100 threads and 100 processors, how often does Hello get printed? (A) 100 times per
More informationWhat is a thread anyway?
Concurrency in Java What is a thread anyway? Smallest sequence of instructions that can be managed independently by a scheduler There can be multiple threads within a process Threads can execute concurrently
More informationCSCI 201L Written Exam #2. 10% of course grade
Name Final Score ID Extra Credit Section (circle one): MW 3:30-6:30 CSCI 201L Written Exam #2 10% of course grade 1. Anonymous Inner Classes In lecture we walked through the following: 1. Having two classes
More informationThe Java Memory Model
The Java Memory Model What is it and why would I want one? Jörg Domaschka. ART Group, Institute for Distributed Systems Ulm University, Germany December 14, 2009 public class WhatDoIPrint{ static int x
More informationSynchronization in Java
Synchronization in Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park Synchronization Overview Unsufficient atomicity Data races Locks Deadlock Wait /
More informationSynchronization
Synchronization 10-28-2013 Synchronization Coming next: Multithreading in JavaFX (javafx.concurrent) Read: Java Tutorial on concurrency JavaFX Tutorial on concurrency Effective Java, Chapter 9 Project#1:
More informationOperating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst
Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst What is a Monitor? Ties data and the synchronization operations together Monitors guarantee mutual exclusion, i.e.,
More informationCS 3430/5430 Homework 3 Solution Due: Saturday, Feb. 25 (11:59 PM)
From the on-line textbook, pp. 147-154 do: Ch 4 Exercises (pencil-and-paper): 4.6 Programming Project: 4.8 and 4.11 Exploration Projects: 4.2 Extra Credit: Programming Project: 4.9 or 4.10 Exercises: 4.6
More informationNeed for synchronization: If threads comprise parts of our software systems, then they must communicate.
Thread communication and synchronization There are two main aspects to Outline for Lecture 19 multithreaded programming in Java: I. Thread synchronization. thread lifecycle, and thread synchronization.
More informationThe Singleton Pattern. Design Patterns In Java Bob Tarr
The Singleton Pattern Intent Ensure a class only has one instance, and provide a global point of access to it Motivation Sometimes we want just a single instance of a class to exist in the system For example,
More informationA 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 informationwait with priority An enhanced version of the wait operation accepts an optional priority argument:
wait with priority An enhanced version of the wait operation accepts an optional priority argument: syntax: .wait the smaller the value of the parameter, the highest the priority
More informationSkeleton programming environments Using ProActive Calcium
Skeleton programming environments Using ProActive Calcium Patrizio Dazzi ISTI - CNR Pisa Research Campus mail: patrizio.dazzi@isti.cnr.it Master Degree (Laurea Magistrale) in Computer Science and Networking
More informationMore Synchronization; Concurrency in Java. CS 475, Spring 2018 Concurrent & Distributed Systems
More Synchronization; Concurrency in Java CS 475, Spring 2018 Concurrent & Distributed Systems Review: Semaphores Synchronization tool that provides more sophisticated ways (than Mutex locks) for process
More informationTHE UNIVERSITY OF WESTERN AUSTRALIA SAMPLE EXAM QUESTIONS 2007 WITH SOLUTIONS SCHOOL OF COMPUTER SCIENCE CITS3213 CONCURRENT PROGRAMMING (PART II)
THE UNIVERSITY OF WESTERN AUSTRALIA SAMPLE EXAM QUESTIONS 2007 WITH SOLUTIONS SCHOOL OF COMPUTER SCIENCE CITS3213 CONCURRENT PROGRAMMING (PART II) The exam will contain: 6 questions (3 for each part) Time
More informationFAKULTÄT FÜR INFORMATIK
FAKULTÄT FÜR INFORMATIK DER TECHNISCHEN UNIVERSITÄT MÜNCHEN Master-Seminar Software Verification Author: Lukas Erlacher Advisor: Prof. Andrey Rybalchenko, Dr. Corneliu Popeea Submission: April, 2013 Contents
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationA 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 informationThreads Chate Patanothai
Threads Chate Patanothai Objectives Knowing thread: 3W1H Create separate threads Control the execution of a thread Communicate between threads Protect shared data C. Patanothai Threads 2 What are threads?
More informationMonitors; Software Transactional Memory
Monitors; Software Transactional Memory Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico March 17, 2016 CPD (DEI / IST) Parallel and Distributed
More informationPrinciples of Software Construction: Concurrency, Part 2
Principles of Software Construction: Concurrency, Part 2 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 5a due now Homework 5 framework goals: Functionally correct Well documented
More informationFormal Methods for Java
Formal Methods for Java Lecture 1: Introduction Jochen Hoenicke Software Engineering Albert-Ludwigs-University Freiburg October 26, 2011 Jochen Hoenicke (Software Engineering) Formal Methods for Java October
More informationConcurrency. Fundamentals of Computer Science
Concurrency http://csunplugged.org/routing-and-deadlock Fundamentals of Computer Science Outline Multi-threaded programs Multiple simultaneous paths of execution Seemingly at once (single core) Actually
More informationException Analysis for Multithreaded Java Programs
Exception Analysis for Multithreaded Java Programs Sukyoung Ryu and Kwangkeun Yi Department of Computer Science Korea Advanced Institute of Science and Technology 373-1 Kusong-dong Yusong-gu, Daejeon 305-701,
More informationSynchronization. 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 informationLe L c e t c ur u e e 7 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Multithreading
Course Name: Advanced Java Lecture 7 Topics to be covered Multithreading Thread--An Introduction Thread A thread is defined as the path of execution of a program. It is a sequence of instructions that
More informationExercises and Labs. Part I. Exercises
Exercises and Labs Part I Exercises 7 Exercises and Labs Exercise 1 Semaphores Answer the questions below: 1. Sometimes, multiple threads in a program write to the same file concurrently. One example
More informationCS 6400 Lecture 11 Name:
Readers and Writers Example - Granularity Issues. Multiple concurrent readers, but exclusive access for writers. Original Textbook code with ERRORS - What are they? Lecture 11 Page 1 Corrected Textbook
More informationLecture 32: Volatile variables, Java memory model
COMP 322: Fundamentals of Parallel Programming Lecture 32: Volatile variables, Java memory model Vivek Sarkar Department of Computer Science, Rice University vsarkar@rice.edu https://wiki.rice.edu/confluence/display/parprog/comp322
More informationC09: Process Synchronization
CISC 7310X C09: Process Synchronization Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/29/2018 CUNY Brooklyn College 1 Outline Race condition and critical regions The bounded
More informationCOMP 346 WINTER Tutorial 5 MONITORS
COMP 346 WINTER 2018 1 Tutorial 5 MONITORS WHY DO WE NEED MONITORS? Semaphores are very useful for solving concurrency problems But it s easy to make mistakes! If proper usage of semaphores is failed by
More informationIntroduction to Java Threads
Object-Oriented Programming Introduction to Java Threads RIT CS 1 "Concurrent" Execution Here s what could happen when you run this Java program and launch 3 instances on a single CPU architecture. The
More informationThreads. Definitions. Process Creation. Process. Thread Example. Thread. From Volume II
Definitions A glossary Threads From Volume II Copyright 1998-2002 Delroy A. Brinkerhoff. All Rights Reserved. Threads Slide 1 of 30 PMultitasking: (concurrent ramming, multiramming) the illusion of running
More informationOutline of lecture. i219 Software Design Methodology 10. Multithreaded programming. Kazuhiro Ogata (JAIST)
i219 Software Design Methodology 10. Multithreaded programming Kazuhiro Ogata (JAIST) Outline of lecture 2 Thread Race condition Synchronization Deadlock Bounded buffer problem Thread (1) 3 Units of execution.
More informationComputation 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 informationJava Time Machine. Wang Yang
Java Time Machine Wang Yang Arrays binarysearch only work for sorted array!! Arrays How to print the content of the Array Arrays How to compare whether two arrays are equal? refer_1!= refer_2 content_1
More informationSynchronisation in Java - Java Monitor
Synchronisation in Java - Java Monitor -Every object and class is logically associated with a monitor - the associated monitor protects the variable in the object/class -The monitor of an object/class
More informationMCS-378 Intraterm Exam 1 Serial #:
MCS-378 Intraterm Exam 1 Serial #: This exam is closed-book and mostly closed-notes. You may, however, use a single 8 1/2 by 11 sheet of paper with hand-written notes for reference. (Both sides of the
More informationJava s Implementation of Concurrency, and how to use it in our applications.
Java s Implementation of Concurrency, and how to use it in our applications. 1 An application running on a single CPU often appears to perform many tasks at the same time. For example, a streaming audio/video
More informationChair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: concurrency Outline Java threads thread implementation sleep, interrupt, and join threads that return values Thread synchronization
More informationDeadlock. Only one process can use the resource at a time but once it s done it can give it back for use by another process.
Deadlock A set of processes is deadlocked if each process in the set is waiting for an event that can be caused by another process in the set. The events that we are mainly concerned with are resource
More informationpublic class Shared0 { private static int x = 0, y = 0;
A race condition occurs anytime that the execution of one thread interferes with the desired behavior of another thread. What is the expected postcondition for the following bump() method? What should
More informationWeek 7. Concurrent Programming: Thread Synchronization. CS 180 Sunil Prabhakar Department of Computer Science Purdue University
Week 7 Concurrent Programming: Thread Synchronization CS 180 Sunil Prabhakar Department of Computer Science Purdue University Announcements Exam 1 tonight 6:30 pm - 7:30 pm MTHW 210 2 Outcomes Understand
More informationi219 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 informationMichele Van Dyne MUS 204B https://katie.mtech.edu/classes/csci136. Concurrency Issues
Michele Van Dyne MUS 204B mvandyne@mtech.edu https://katie.mtech.edu/classes/csci136 Concurrency Issues Multi-threaded programs Multiple simultaneous paths of execution Seemingly at once (single core)
More informationProgrammazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci
v1.0 20130323 Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci [module lab 2.1] CONCURRENT PROGRAMMING IN JAVA: INTRODUCTION 1 CONCURRENT
More informationJAVA CONCURRENCY FRAMEWORK. Kaushik Kanetkar
JAVA CONCURRENCY FRAMEWORK Kaushik Kanetkar Old days One CPU, executing one single program at a time No overlap of work/processes Lots of slack time CPU not completely utilized What is Concurrency Concurrency
More informationLast Class: Synchronization. Review. Semaphores. Today: Semaphores. MLFQ CPU scheduler. What is test & set?
Last Class: Synchronization Review Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical
More informationClasses and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?
Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable
More informationJava Threads. Introduction to Java Threads
Java Threads Resources Java Threads by Scott Oaks & Henry Wong (O Reilly) API docs http://download.oracle.com/javase/6/docs/api/ java.lang.thread, java.lang.runnable java.lang.object, java.util.concurrent
More informationSynchronization 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 informationMonitors & Condition Synchronization
Feb. 15, 2012 Monitors & condition Synchronization Concepts: monitors: encapsulated data + access procedures mutual exclusion + condition synchronization single access procedure active in the monitor Models:
More informationSummary Semaphores. Passing the Baton any await statement. Synchronisation code not linked to the data
Lecture 4 Monitors Summary Semaphores Good news Simple, efficient, expressive Passing the Baton any await statement Bad news Low level, unstructured omit a V: deadlock omit a P: failure of mutex Synchronisation
More informationGet Unique study materials from
Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code
More informationCS193k, Stanford Handout #12. Threads 4 / RMI
CS193k, Stanford Handout #12 Spring, 99-00 Nick Parlante Threads 4 / RMI Semaphore1 Semaphore1 from last time uses the count in a precise way to know exactly how many threads are waiting. In this way,
More information1) Discuss the mutual exclusion mechanism that you choose as implemented in the chosen language and the associated basic syntax
Lab report Project 3 Mihai Ene I have implemented the solution in Java. I have leveraged its threading mechanisms and concurrent API (i.e. concurrent package) in order to achieve the required functionality
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationFaculty of Computers & Information Computer Science Department
Cairo University Faculty of Computers & Information Computer Science Department Theoretical Part 1. Introduction to Critical Section Problem Critical section is a segment of code, in which the process
More informationConcurrency. CSCI 136: Fundamentals of Computer Science II Keith Vertanen
Concurrency http://csunplugged.org/routing-and-deadlock CSCI 136: Fundamentals of Computer Science II Keith Vertanen Overview Multi-threaded programs Multiple simultaneous paths of execution Seemingly
More informationCOURSE 11 PROGRAMMING III OOP. JAVA LANGUAGE
COURSE 11 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Input/Output Streams Text Files Byte Files RandomAcessFile Exceptions Serialization NIO COURSE CONTENT Threads Threads lifecycle Thread
More informationOS06: Monitors in Java
OS06: Monitors in Java Based on Chapter 4 of [Hai17] Jens Lechtenbörger Computer Structures and Operating Systems 2018 1 Introduction 1.1 OS Plan ˆ OS Motivation (Wk 23) ˆ OS Introduction (Wk 23) ˆ Interrupts
More informationOverview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1
CMSC 433 Programming Language Technologies and Paradigms Spring 2003 Threads and Synchronization April 1, 2003 Overview What are threads? Thread scheduling, data races, and synchronization Thread mechanisms
More information