Concurrent programming in Java
|
|
|
- Mariah Johnson
- 10 years ago
- Views:
Transcription
1 Concurrent programming in Java INF Lecture 5 0 Book: Andrews - ch.05 (5.4) Book: Magee & Kramer ch.04 - ch.07 INF4140 ( ) Concurrent programming in Java Lecture 5 1 / 33
2 Outline 1 Monitors: review 2 Threads in Java: Thread class Runnable interface 3 Example: Interference and Java threads 4 Synchronized blocks and methods: (atomic regions and monitors) 5 Example: No interference and Java threads 6 Example:The ornamental garden 7 Condition synchronization (wait and signal) 8 Example: Mutual exclusion 9 Example: Readers/writers INF4140 ( ) Concurrent programming in Java Lecture 5 2 / 33
3 Summary of the Last Lecture A monitor encapsulates data, which can only be observed and modified by the monitor s procedures. Contains variables that describe the state Variables can be changed only through the available procedures Implicit mutex: Only a procedure may be active at a time. Two procedures in the same monitor are never executed concurrently Condition synchronization (block a process until a particular condition holds) is given by condition variables. Signaling disciplines: Signal and Wait (SW): the signaller waits, and the signalled process gets to execute immediately Signal and Continue (SC): the signaller continues, and the signalled process executes later INF4140 ( ) Concurrent programming in Java Lecture 5 3 / 33
4 Java From Wikipedia:... Java is a general-purpose, concurrent, class-based, object-oriented language... INF4140 ( ) Concurrent programming in Java Lecture 5 4 / 33
5 Threads in Java A thread (processes from previous lectures) in Java has its own stack, its own execution context and it has access to a share state. Threads may be created and deleted dynamically. Thread run() MyThread run() The Thread class executes instructions from its method run(). The actual code executed depends on the implementation provided for run() in a derived class. c l a s s MyThread extends Thread { p u b l i c v o i d run ( ) { // // C r e a t i n g a t h r e a d o b j e c t : Thread a = new MyThread ( ) ; a. s t a r t ( ) ; INF4140 ( ) Concurrent programming in Java Lecture 5 5 / 33
6 Threads in Java Since Java does not permit multiple inheritance, we often implement the run() method in a class not derived from Thread but from the interface Runnable. Runnable target Thread run() MyRun run() public interface Runnable { public abstract void run(); class MyRun implements Runnable { public void run() { //... // C r e a t i n g a t h r e a d o b j e c t : Runnable b = new MyRun ( ) ; new Thread ( b ). s t a r t ( ) ; INF4140 ( ) Concurrent programming in Java Lecture 5 6 / 33
7 Threads in Java To summarize: Four steps to create a thread in Java: 1 Define a new class that extends the Java Thread class or that implements the Runnable interface. 2 Define a run method in the new class. 3 Create an instance of the new class. 4 Start the thread. INF4140 ( ) Concurrent programming in Java Lecture 5 7 / 33
8 Example: Interference and Java Threads... c l a s s S t o r e { p r i v a t e i n t data = 0 ; p u b l i c v o i d update ( ) { data++;... // i n a method : S t o r e s = new S t o r e ( ) ; // t h e t h r e a d s below have a c c e s s to s t1 = new FooThread ( s ) ; t1. s t a r t ( ) ; t2 = new FooThread ( s ) ; t2. s t a r t ( ) ; Threads t1 and t2 could execute s.update() concurrently! Interference between t1 and t2 may lose updates to data. INF4140 ( ) Concurrent programming in Java Lecture 5 8 / 33
9 Synchronized Methods To avoid interference: Threads synchronize access to shared data Mechanism: 1 One unique lock for each object o. 2 mutex: at most one thread T can lock o at any time. 3 T makes a request to lock o in order to execute the block (statements) B as follows: s y n c h r o n i z e d ( o ) { B or T makes a request to lock o in order to execute the whole method m as follows: s y n c h r o n i z e d Type m (... ) {... INF4140 ( ) Concurrent programming in Java Lecture 5 9 / 33
10 Example part II: No Interference Solution to earlier problem: lock the Store objects before executing problematic method: c l a s s S t o r e { p r i v a t e i n t data = 0 ; or p u b l i c v o i d update ( ) { s y n c h r o n i z e d ( t h i s ) { data++; c l a s s S t o r e { p r i v a t e i n t data = 0 ; p u b l i c s y n c h r o n i z e d v o i d update ( ) { data++;... // i n s i d e a method : S t o r e s = new S t o r e ( ) ; Now only one thread at a time can run s.update(). INF4140 ( ) Concurrent programming in Java Lecture 5 10 / 33
11 Java Examples Book: Concurrency: State Models & Java Programs, 2 nd Edition Jeff Magee & Jeff Kramer Wiley Examples in Java: INF4140 ( ) Concurrent programming in Java Lecture 5 11 / 33
12 Ornamental Garden Problem People enter an ornamental garden through either of two turnstiles. Management wants to know how many people are in the garden at any time. The concurrent program consists of: Two concurrent threads Shared counter object INF4140 ( ) Concurrent programming in Java Lecture 5 12 / 33
13 Ornamental Garden Problem: Class Diagram The Turnstile thread simulates the periodic arrival of a visitor to the garden every second by sleeping for a second and then invoking the increment() method of the counter object. INF4140 ( ) Concurrent programming in Java Lecture 5 13 / 33
14 Ornamental Garden Problem c l a s s Counter { i n t v a l u e = 0 ; NumberCanvas d i s p l a y ; Counter ( NumberCanvas n ) { d i s p l a y. s e t v a l u e ( v a l u e ) ; v o i d i n c r e m e n t ( ) { i n t temp = v a l u e ; // r e a d [ v ] S i m u l a t e. HWinterrupt ( ) ; v a l u e = temp + 1 ; // w r i t e [ v +1] d i s p l a y. s e t v a l u e ( v a l u e ) ; d i s p l a y = n ; INF4140 ( ) Concurrent programming in Java Lecture 5 14 / 33
15 Ornamental Garden Problem c l a s s T u r n s t i l e extends Thread { NumberCanvas d i s p l a y ; // i n t e r f a c e Counter p e o p l e ; // s h a r e data T u r n s t i l e ( NumberCanvas n, Counter c ) { // c o n s t r u c t o r d i s p l a y = n ; p e o p l e = c ; p u b l i c v o i d run ( ) { t r y { d i s p l a y. s e t v a l u e ( 0 ) ; f o r ( i n t i = 1 ; i <= Garden.MAX; i ++) { Thread. s l e e p ( ) ; // 0. 5 second d i s p l a y. s e t v a l u e ( i ) ; p e o p l e. i n c r e m e n t ( ) ; // i n c r e m e n t t h e c o u n t e r catch ( I n t e r r u p t e d E x c e p t i o n e ) { INF4140 ( ) Concurrent programming in Java Lecture 5 15 / 33
16 Ornamental Garden Program The Counter object and Turnstile threads are created by the go() method of the Garden applet: p r i v a t e v o i d go ( ) { c o u n t e r = new Counter ( counterd ) ; west = new T u r n s t i l e ( westd, c o u n t e r ) ; e a s t = new T u r n s t i l e ( eastd, c o u n t e r ) ; west. s t a r t ( ) ; e a s t. s t a r t ( ) ; INF4140 ( ) Concurrent programming in Java Lecture 5 16 / 33
17 Ornamental Garden Program: DEMO DEMO After the East and West turnstile threads have each incremented its counter 20 times, the garden people counter is not the sum of the counts displayed. Counter increments have been lost. Why? INF4140 ( ) Concurrent programming in Java Lecture 5 17 / 33
18 Mutual Exclusion: The Ornamental Garden c l a s s S y n c h r o n i z e d C o u n t e r extends Counter { S y n c h r o n i z e d C o u n t e r ( NumberCanvas n ) { s u p e r ( n ) ; s y n c h r o n i z e d v o i d i n c r e m e n t ( ) { s u p e r. i n c r e m e n t ( ) ; INF4140 ( ) Concurrent programming in Java Lecture 5 18 / 33
19 Mutual Exclusion: The Ornamental Garden - DEMO DEMO INF4140 ( ) Concurrent programming in Java Lecture 5 19 / 33
20 Condition Synchronization (Monitors) The following statements are defined for an arbitrary Java object o and must be executed within synchronized portions of code: o.wait(): release lock on o, enter o s wait queue and wait o.notify(): wake up one thread in o s wait queue o.notifyall(): wake up all threads in o s wait queue There is only one (implicit) condition variable per object (wait queue). Objects that wait on o (o.wait()) are in this implicit queue. The ordering of the wait queue is implementation-dependent (usually FIFO). Signaling Discipline: Signal and Continue An awakened thread has no advantage in the competition for the lock to o. INF4140 ( ) Concurrent programming in Java Lecture 5 20 / 33
21 A Semaphore Implementation in Java // up ( ) i s t h e V o p e r a t i o n // down ( ) i s t h e P o p e r a t i o n p u b l i c c l a s s Semaphore { p r i v a t e i n t v a l u e ; p u b l i c Semaphore ( i n t i n i t i a l ) { v a l u e = i n i t i a l ; s y n c h r o n i z e d p u b l i c v o i d up ( ) { ++v a l u e ; n o t i f y A l l ( ) ; s y n c h r o n i z e d p u b l i c v o i d down ( ) throws I n t e r r u p t e d E x c e p t i o n { w h i l e ( v a l u e ==0) w a i t ( ) ; v a l u e ; INF4140 ( ) Concurrent programming in Java Lecture 5 21 / 33
22 Mutual Exclusion with Sempahores INF4140 ( ) Concurrent programming in Java Lecture 5 22 / 33
23 Mutual Exclusion with Sempahores c l a s s MutexLoop implements Runnable { Semaphore mutex ; MutexLoop ( Semaphore sema ) { mutex=sema ; p u b l i c v o i d run ( ) { t r y { w h i l e ( t r u e ) { w h i l e (! ThreadPanel. r o t a t e ( ) ) ; // g e t mutual e x c l u s i o n mutex. down ( ) ; w h i l e ( ThreadPanel. r o t a t e ( ) ) ; // c r i t i c a l s e c t i o n // r e l e a s e mutual e x c l u s i o n mutex. up ( ) ; catch ( I n t e r r u p t e d E x c e p t i o n e ){ DEMO INF4140 ( ) Concurrent programming in Java Lecture 5 23 / 33
24 Readers and Writers problem A shared database is accessed by two kinds of processes. Readers execute transactions that examine the database while Writers both examine and update the database. A Writer must have exclusive access to the database; any number of Readers may concurrently access it. INF4140 ( ) Concurrent programming in Java Lecture 5 24 / 33
25 Readers and Writers problem c l a s s Reader implements Runnable { ReadWrite m o n i t o r ; Reader ( ReadWrite m o n i t o r ) { m o n i t o r = m o n i t o r ; p u b l i c v o i d run ( ) { t r y { w h i l e ( t r u e ) { w h i l e (! ThreadPanel. r o t a t e ( ) ) ; // b e g i n c r i t i c a l s e c t i o n m o n i t o r. a c q u i r e R e a d ( ) ; w h i l e ( ThreadPanel. r o t a t e ( ) ) ; m o n i t o r. r e l e a s e R e a d ( ) ; catch ( I n t e r r u p t e d E x c e p t i o n e ){ INF4140 ( ) Concurrent programming in Java Lecture 5 25 / 33
26 Readers and Writers problem c l a s s W r i t e r implements Runnable { ReadWrite m o n i t o r ; W r i t e r ( ReadWrite m o n i t o r ) { m o n i t o r = m o n i t o r ; p u b l i c v o i d run ( ) { t r y { w h i l e ( t r u e ) { w h i l e (! ThreadPanel. r o t a t e ( ) ) ; // b e g i n c r i t i c a l s e c t i o n m o n i t o r. a c q u i r e W r i t e ( ) ; w h i l e ( ThreadPanel. r o t a t e ( ) ) ; m o n i t o r. r e l e a s e W r i t e ( ) ; catch ( I n t e r r u p t e d E x c e p t i o n e ){ INF4140 ( ) Concurrent programming in Java Lecture 5 26 / 33
27 Readers and Writers problem i n t e r f a c e ReadWrite { p u b l i c v o i d a c q u i r e R e a d ( ) throws I n t e r r u p t e d E x c e p t i o n ; p u b l i c v o i d r e l e a s e R e a d ( ) ; p u b l i c v o i d a c q u i r e W r i t e ( ) throws I n t e r r u p t e d E x c e p t i o n ; p u b l i c v o i d r e l e a s e W r i t e ( ) ; INF4140 ( ) Concurrent programming in Java Lecture 5 27 / 33
28 Readers and Writers problem c l a s s ReadWriteSafe implements ReadWrite { p r i v a t e i n t r e a d e r s =0; p r i v a t e boolean w r i t i n g = f a l s e ; p u b l i c s y n c h r o n i z e d v o i d a c q u i r e R e a d ( ) throws I n t e r r u p t e d E x c e p t i o n { w h i l e ( w r i t i n g ) w a i t ( ) ; ++r e a d e r s ; p u b l i c s y n c h r o n i z e d v o i d r e l e a s e R e a d ( ) { r e a d e r s ; i f ( r e a d e r s ==0) n o t i f y A l l ( ) ; p u b l i c s y n c h r o n i z e d v o i d a c q u i r e W r i t e ( ) {... p u b l i c s y n c h r o n i z e d v o i d r e l e a s e W r i t e ( ) {... INF4140 ( ) Concurrent programming in Java Lecture 5 28 / 33
29 Readers and Writers problem c l a s s ReadWriteSafe implements ReadWrite { p r i v a t e i n t r e a d e r s =0; p r i v a t e boolean w r i t i n g = f a l s e ; p u b l i c s y n c h r o n i z e d v o i d a c q u i r e R e a d ( ) {... p u b l i c s y n c h r o n i z e d v o i d r e l e a s e R e a d ( ) {... p u b l i c s y n c h r o n i z e d v o i d a c q u i r e W r i t e ( ) throws I n t e r r u p t e d E x c e p t i o n { w h i l e ( r e a d e r s >0 w r i t i n g ) w a i t ( ) ; w r i t i n g = t r u e ; p u b l i c s y n c h r o n i z e d v o i d r e l e a s e W r i t e ( ) { w r i t i n g = f a l s e ; n o t i f y A l l ( ) ; DEMO INF4140 ( ) Concurrent programming in Java Lecture 5 29 / 33
30 Readers and Writers problem - Fairness INF4140 ( ) Concurrent programming in Java Lecture 5 30 / 33
31 Readers and Writers problem c l a s s R e a d W r i t e F a i r implements ReadWrite { p r i v a t e i n t r e a d e r s =0; p r i v a t e boolean w r i t i n g = f a l s e ; p r i v a t e i n t waitingw = 0 ; // no o f w a i t i n g W r i t e r s. p r i v a t e boolean r e a d e r s t u r n = f a l s e ; s y n c h r o n i z e d p u b l i c v o i d a c q u i r e R e a d ( ) throws I n t e r r u p t e d E x c e p t i o n { w h i l e ( w r i t i n g ( waitingw >0 &&! r e a d e r s t u r n ) ) w a i t ( ) ; ++r e a d e r s ; s y n c h r o n i z e d p u b l i c v o i d r e l e a s e R e a d ( ) { r e a d e r s ; r e a d e r s t u r n=f a l s e ; i f ( r e a d e r s ==0) n o t i f y A l l ( ) ; s y n c h r o n i z e d p u b l i c v o i d a c q u i r e W r i t e ( ) {... s y n c h r o n i z e d p u b l i c v o i d r e l e a s e W r i t e ( ) {... INF4140 ( ) Concurrent programming in Java Lecture 5 31 / 33
32 Readers and Writers problem c l a s s R e a d W r i t e F a i r implements ReadWrite { p r i v a t e i n t r e a d e r s =0; p r i v a t e boolean w r i t i n g = f a l s e ; p r i v a t e i n t waitingw = 0 ; // no o f w a i t i n g W r i t e r s. p r i v a t e boolean r e a d e r s t u r n = f a l s e ; s y n c h r o n i z e d p u b l i c v o i d a c q u i r e R e a d ( ) {... s y n c h r o n i z e d p u b l i c v o i d r e l e a s e R e a d ( ) {... s y n c h r o n i z e d p u b l i c v o i d a c q u i r e W r i t e ( ) throws I n t e r r u p t e d E x c e p t i o n { ++waitingw ; w h i l e ( r e a d e r s >0 w r i t i n g ) w a i t ( ) ; waitingw ; w r i t i n g = t r u e ; s y n c h r o n i z e d p u b l i c v o i d r e l e a s e W r i t e ( ) { w r i t i n g = f a l s e ; r e a d e r s t u r n=t r u e ; n o t i f y A l l ( ) ; INF4140 ( ) Concurrent programming in Java Lecture 5 32 / 33
33 Readers and Writers problem DEMO INF4140 ( ) Concurrent programming in Java Lecture 5 33 / 33
Monitors & Condition Synchronization
Chapter 5 Monitors & Condition Synchronization 1 monitors & condition synchronization Concepts: monitors: encapsulated data + access procedures mutual exclusion + condition synchronization nested monitors
Outline of this lecture G52CON: Concepts of Concurrency
Outline of this lecture G52CON: Concepts of Concurrency Lecture 10 Synchronisation in Java Natasha Alechina School of Computer Science [email protected] mutual exclusion in Java condition synchronisation
Parallel Programming
Parallel Programming 0024 Recitation Week 7 Spring Semester 2010 R 7 :: 1 0024 Spring 2010 Today s program Assignment 6 Review of semaphores Semaphores Semaphoren and (Java) monitors Semaphore implementation
Lecture 6: Introduction to Monitors and Semaphores
Concurrent Programming 19530-V (WS01) Lecture 6: Introduction to Monitors and Semaphores Dr. Richard S. Hall [email protected] Concurrent programming November 27, 2001 Abstracting Locking Details
Chapter 6 Concurrent Programming
Chapter 6 Concurrent Programming Outline 6.1 Introduction 6.2 Monitors 6.2.1 Condition Variables 6.2.2 Simple Resource Allocation with Monitors 6.2.3 Monitor Example: Circular Buffer 6.2.4 Monitor Example:
Monitors, Java, Threads and Processes
Monitors, Java, Threads and Processes 185 An object-oriented view of shared memory A semaphore can be seen as a shared object accessible through two methods: wait and signal. The idea behind the concept
Lecture 6: Semaphores and Monitors
HW 2 Due Tuesday 10/18 Lecture 6: Semaphores and Monitors CSE 120: Principles of Operating Systems Alex C. Snoeren Higher-Level Synchronization We looked at using locks to provide mutual exclusion Locks
Last Class: Semaphores
Last Class: Semaphores A semaphore S supports two atomic operations: S Wait(): get a semaphore, wait if busy semaphore S is available. S Signal(): release the semaphore, wake up a process if one is waiting
SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I)
SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics
CS11 Java. Fall 2014-2015 Lecture 7
CS11 Java Fall 2014-2015 Lecture 7 Today s Topics! All about Java Threads! Some Lab 7 tips Java Threading Recap! A program can use multiple threads to do several things at once " A thread can have local
A Survey of Parallel Processing in Linux
A Survey of Parallel Processing in Linux Kojiro Akasaka Computer Science Department San Jose State University San Jose, CA 95192 408 924 1000 [email protected] ABSTRACT Any kernel with parallel processing
3C03 Concurrency: Condition Synchronisation
3C03 Concurrency: Condition Synchronisation Mark Handley 1 Goals n Introduce concepts of Condition synchronisation Fairness Starvation n Modelling: Relationship between guarded actions and condition synchronisation?
Concurrent Programming
Concurrent Programming Shared Memory Passing the baton Monitors Verónica Gaspes www.hh.se/staff/vero CERES, November 2, 2007 ceres Outline 1 Recap 2 Readers & Writers Readers & writers (mutual exclusion)
Traditional Software Development. Model Requirements and JAVA Programs. Formal Verification & Validation. What is a state?
Mel Requirements and JAVA Programs MVP The Waterfall Mel Problem Area Traditional Software Develoment Analysis REVIEWS Design Costly wrt time and money. Errors are found too late (or maybe never). SPIN/PROMELA
Semaphores and Monitors: High-level Synchronization Constructs
Semaphores and Monitors: High-level Synchronization Constructs 1 Synchronization Constructs Synchronization Coordinating execution of multiple threads that share data structures Past few lectures: Locks:
! Past few lectures: Ø Locks: provide mutual exclusion Ø Condition variables: provide conditional synchronization
1 Synchronization Constructs! Synchronization Ø Coordinating execution of multiple threads that share data structures Semaphores and Monitors: High-level Synchronization Constructs! Past few lectures:
Concurrent Programming
Concurrent Programming Principles and Practice Gregory R. Andrews The University of Arizona Technische Hochschule Darmstadt FACHBEREICH INFCRMATIK BIBLIOTHEK Inventar-Nr.:..ZP.vAh... Sachgebiete:..?r.:..\).
OBJECT ORIENTED PROGRAMMING LANGUAGE
UNIT-6 (MULTI THREADING) Multi Threading: Java Language Classes The java.lang package contains the collection of base types (language types) that are always imported into any given compilation unit. This
Java Memory Model: Content
Java Memory Model: Content Memory Models Double Checked Locking Problem Java Memory Model: Happens Before Relation Volatile: in depth 16 March 2012 1 Java Memory Model JMM specifies guarantees given by
Computing Concepts with Java Essentials
2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Computing Concepts with Java Essentials 3rd Edition Cay Horstmann
Advanced Multiprocessor Programming
Advanced Multiprocessor Programming Jesper Larsson Träff [email protected] Research Group Parallel Computing aculty of nformatics, nstitute of nformation Systems Vienna University of Technology (TU
Chapter 8 Implementing FSP Models in Java
Chapter 8 Implementing FSP Models in Java 1 8.1.1: The Carpark Model A controller is required for a carpark, which only permits cars to enter when the carpark is not full and does not permit cars to leave
Thread Synchronization and the Java Monitor
Articles News Weblogs Buzz Chapters Forums Table of Contents Order the Book Print Email Screen Friendly Version Previous Next Chapter 20 of Inside the Java Virtual Machine Thread Synchronization by Bill
4. Monitors. Monitors support data encapsulation and information hiding and are easily adapted to an object-oriented environment.
4. Monitors Problems with semaphores: - shared variables and the semaphores that protect them are global variables - Operations on shared variables and semaphores distributed throughout program - difficult
Lecture 8: Safety and Liveness Properties
Concurrent Programming 19530-V (WS01) 1 Lecture 8: Safety and Liveness Properties Dr. Richard S. Hall [email protected] Concurrent programming December 11, 2001 Safety Properties 2 A safety property
Mutual Exclusion using Monitors
Mutual Exclusion using Monitors Some programming languages, such as Concurrent Pascal, Modula-2 and Java provide mutual exclusion facilities called monitors. They are similar to modules in languages that
Design Patterns in C++
Design Patterns in C++ Concurrency Patterns Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa May 4, 2011 G. Lipari (Scuola Superiore Sant Anna) Concurrency Patterns May 4,
Java SE 7 Programming
Java SE 7 Programming The second of two courses that cover the Java Standard Edition 7 (Java SE 7) Platform, this course covers the core Application Programming Interfaces (API) you will use to design
Chapter 6, The Operating System Machine Level
Chapter 6, The Operating System Machine Level 6.1 Virtual Memory 6.2 Virtual I/O Instructions 6.3 Virtual Instructions For Parallel Processing 6.4 Example Operating Systems 6.5 Summary Virtual Memory General
Priority Inversion Problem and Deadlock Situations
INTER-PROCESS COMMUNICATION AND SYNCHRONISATION: Lesson-11: Priority Inversion Problem and Deadlock Situations 1 1. Priority Inversion 2 Assume Priorities of tasks be in an order such that task I highest
SYSTEM ecos Embedded Configurable Operating System
BELONGS TO THE CYGNUS SOLUTIONS founded about 1989 initiative connected with an idea of free software ( commercial support for the free software ). Recently merged with RedHat. CYGNUS was also the original
Real Time Programming: Concepts
Real Time Programming: Concepts Radek Pelánek Plan at first we will study basic concepts related to real time programming then we will have a look at specific programming languages and study how they realize
Resurrecting Ada s Rendez-Vous in Java
Resurrecting Ada s Rendez-Vous in Java Luis Mateu, José M. Piquer and Juan León DCC - Universidad de Chile Casilla 2777, Santiago, Chile [email protected] Abstract Java is a programming language designed
Programming real-time systems with C/C++ and POSIX
Programming real-time systems with C/C++ and POSIX Michael González Harbour 1. Introduction The C language [1], developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories, is the most widely
Java Concurrency Framework. Sidartha Gracias
Java Concurrency Framework Sidartha Gracias Executive Summary This is a beginners introduction to the java concurrency framework Some familiarity with concurrent programs is assumed However the presentation
Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 SOLUTIONS.
Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 Name: SOLUTIONS Athena* User Name: Instructions This quiz is 50 minutes long. It contains
Overview. CMSC 330: Organization of Programming Languages. Synchronization Example (Java 1.5) Lock Interface (Java 1.5) ReentrantLock Class (Java 1.
CMSC 330: Organization of Programming Languages Java 1.5, Ruby, and MapReduce Overview Java 1.5 ReentrantLock class Condition interface - await( ), signalall( ) Ruby multithreading Concurrent programming
Monitors and Semaphores
Monitors and Semaphores Annotated Condition Variable Example Condition *cv; Lock* cvmx; int waiter = 0; await() { cvmx->lock(); waiter = waiter + 1; /* I m sleeping */ cv->wait(cvmx); /* sleep */ cvmx->unlock();
Topics. Producing Production Quality Software. Concurrent Environments. Why Use Concurrency? Models of concurrency Concurrency in Java
Topics Producing Production Quality Software Models of concurrency Concurrency in Java Lecture 12: Concurrent and Distributed Programming Prof. Arthur P. Goldberg Fall, 2005 2 Why Use Concurrency? Concurrent
Java SE 8 Programming
Oracle University Contact Us: 1.800.529.0165 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming
Java the UML Way: Integrating Object-Oriented Design and Programming
Java the UML Way: Integrating Object-Oriented Design and Programming by Else Lervik and Vegard B. Havdal ISBN 0-470-84386-1 John Wiley & Sons, Ltd. Table of Contents Preface xi 1 Introduction 1 1.1 Preliminaries
TESTING JAVA MONITORS BY STATE SPACE EXPLORATION MONICA HERNANDEZ. Presented to the Faculty of the Graduate School of
TESTING JAVA MONITORS BY STATE SPACE EXPLORATION by MONICA HERNANDEZ Presented to the Faculty of the Graduate School of The University of Texas at Arlington in Partial Fulfillment of the Requirements for
Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture
Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts
Operating Systems and Networks
recap Operating Systems and Networks How OS manages multiple tasks Virtual memory Brief Linux demo Lecture 04: Introduction to OS-part 3 Behzad Bordbar 47 48 Contents Dual mode API to wrap system calls
MonitorExplorer: A State Exploration-Based Approach to Testing Java Monitors
Department of Computer Science and Engineering University of Texas at Arlington Arlington, TX 76019 MonitorExplorer: A State Exploration-Based Approach to Testing Java Monitors Y. Lei, R. Carver, D. Kung,
Web Development in Java
Web Development in Java Detailed Course Brochure @All Rights Reserved. Techcanvass, 265, Powai Plaza, Hiranandani Garden, Powai, Mumbai www.techcanvass.com Tel: +91 22 40155175 Mob: 773 877 3108 P a g
Java SE 7 Programming
Oracle University Contact Us: 1.800.529.0165 Java SE 7 Programming Duration: 5 Days What you will learn This Java SE 7 Programming training explores the core Application Programming Interfaces (API) you'll
Java SE 7 Programming
Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 4108 4709 Java SE 7 Programming Duration: 5 Days What you will learn This Java Programming training covers the core Application Programming
Tasks Schedule Analysis in RTAI/Linux-GPL
Tasks Schedule Analysis in RTAI/Linux-GPL Claudio Aciti and Nelson Acosta INTIA - Depto de Computación y Sistemas - Facultad de Ciencias Exactas Universidad Nacional del Centro de la Provincia de Buenos
Java Virtual Machine Locks
Java Virtual Machine Locks SS 2008 Synchronized Gerald SCHARITZER (e0127228) 2008-05-27 Synchronized 1 / 13 Table of Contents 1 Scope...3 1.1 Constraints...3 1.2 In Scope...3 1.3 Out of Scope...3 2 Logical
Distributed Systems [Fall 2012]
Distributed Systems [Fall 2012] [W4995-2] Lec 6: YFS Lab Introduction and Local Synchronization Primitives Slide acks: Jinyang Li, Dave Andersen, Randy Bryant (http://www.news.cs.nyu.edu/~jinyang/fa10/notes/ds-lec2.ppt,
The Little Book of Semaphores
The Little Book of Semaphores Allen B. Downey Version 2.1.2 2 The Little Book of Semaphores Second Edition Version 2.1.2 Copyright 2005, 2006, 2007 Allen B. Downey Permission is granted to copy, distribute
This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues 1. 2004 Goodrich, Tamassia
This lecture Abstract data types Stacks Queues ADTs, Stacks, Queues 1 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations
Shared Address Space Computing: Programming
Shared Address Space Computing: Programming Alistair Rendell See Chapter 6 or Lin and Synder, Chapter 7 of Grama, Gupta, Karypis and Kumar, and Chapter 8 of Wilkinson and Allen Fork/Join Programming Model
Designing Real-Time and Embedded Systems with the COMET/UML method
By Hassan Gomaa, Department of Information and Software Engineering, George Mason University. Designing Real-Time and Embedded Systems with the COMET/UML method Most object-oriented analysis and design
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
JAVA - MULTITHREADING
JAVA - MULTITHREADING http://www.tutorialspoint.com/java/java_multithreading.htm Copyright tutorialspoint.com Java is amulti threaded programming language which means we can develop multi threaded program
Concurrency and Parallelism
Concurrency and Parallelism 480/571 G. Castagna (CNRS) Cours de Programmation Avancée 480 / 571 Outline 39 Concurrency 40 Preemptive multi-threading 41 Locks, Conditional Variables, Monitors 42 Doing without
Hoare-Style Monitors for Java
Hoare-Style Monitors for Java Theodore S Norvell Electrical and Computer Engineering Memorial University February 17, 2006 1 Hoare-Style Monitors Coordinating the interactions of two or more threads can
Threads 1. When writing games you need to do more than one thing at once.
Threads 1 Threads Slide 1 When writing games you need to do more than one thing at once. Threads offer a way of automatically allowing more than one thing to happen at the same time. Java has threads as
A Comparison of the Concurrency and Real-Time Features of Ada 95 and Java
A Comparison of the Concurrency and Real-Time Features of Ada 95 and Java Benjamin M. Brosgol Ada Core Technologies 79 Tobey Road Belmont, MA 02478 USA +1.617.489.4027 (Phone) +1.617.489.4009 (FAX) [email protected]
Built-in Concurrency Primitives in Java Programming Language. by Yourii Martiak and Mahir Atmis
Built-in Concurrency Primitives in Java Programming Language by Yourii Martiak and Mahir Atmis Overview One of the many strengths of Java is the built into the programming language support for concurrency
Operating Systems for Parallel Processing Assistent Lecturer Alecu Felician Economic Informatics Department Academy of Economic Studies Bucharest
Operating Systems for Parallel Processing Assistent Lecturer Alecu Felician Economic Informatics Department Academy of Economic Studies Bucharest 1. Introduction Few years ago, parallel computers could
Fundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
Java EE Web Development Course Program
Java EE Web Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive types, variables, basic operators, expressions,
Port of the Java Virtual Machine Kaffe to DROPS by using L4Env
Port of the Java Virtual Machine Kaffe to DROPS by using L4Env Alexander Böttcher [email protected] Technische Universität Dresden Faculty of Computer Science Operating System Group July 2004
Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:
Chapter 7 OBJECTIVES Operating Systems Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the concept of virtual memory. Understand the
First-class User Level Threads
First-class User Level Threads based on paper: First-Class User Level Threads by Marsh, Scott, LeBlanc, and Markatos research paper, not merely an implementation report User-level Threads Threads managed
Far-western University Central Office, Mahendranagar Operating System
Far-western University Central Office, Mahendranagar Operating System Course Title: Operating Systems Credit: 3+1 Course No: B.Sc. CS OS 231 hour 45+15 Nature of the Course: Theory + Lab Year: 2 nd, Semester:
Chapter 2 Process, Thread and Scheduling
Chapter 2 Process, Thread and Scheduling Scheduler Class and Priority XIANG Yong [email protected] Outline Scheduling Class and Priority Dispatch Queues & Dispatch Tables Thread Priorities & Scheduling
REAL TIME OPERATING SYSTEMS. Lesson-10:
REAL TIME OPERATING SYSTEMS Lesson-10: Real Time Operating System 1 1. Real Time Operating System Definition 2 Real Time A real time is the time which continuously increments at regular intervals after
CS4410 - Fall 2008 Homework 2 Solution Due September 23, 11:59PM
CS4410 - Fall 2008 Homework 2 Solution Due September 23, 11:59PM Q1. Explain what goes wrong in the following version of Dekker s Algorithm: CSEnter(int i) inside[i] = true; while(inside[j]) inside[i]
Deadlock Victim. dimanche 6 mai 12
Deadlock Victim by Dr Heinz Kabutz && Olivier Croisier The Java Specialists Newsletter && The Coder's Breakfast [email protected] && [email protected] 1 You discover a race condition 2
Kernel Synchronization and Interrupt Handling
Kernel Synchronization and Interrupt Handling Oliver Sengpie, Jan van Esdonk Arbeitsbereich Wissenschaftliches Rechnen Fachbereich Informatik Fakultt fr Mathematik, Informatik und Naturwissenschaften Universitt
OPERATING SYSTEMS PROCESS SYNCHRONIZATION
OPERATING SYSTEMS PROCESS Jerry Breecher 6: Process Synchronization 1 OPERATING SYSTEM Synchronization What Is In This Chapter? This is about getting processes to coordinate with each other. How do processes
Design Pattern for the Adaptive Scheduling of Real-Time Tasks with Multiple Versions in RTSJ
Design Pattern for the Adaptive Scheduling of Real-Time Tasks with Multiple Versions in RTSJ Rodrigo Gonçalves, Rômulo Silva de Oliveira, Carlos Montez LCMI Depto. de Automação e Sistemas Univ. Fed. de
Monitor Object. An Object Behavioral Pattern for Concurrent Programming. Douglas C. Schmidt
Monitor Object An Object Behavioral Pattern for Concurrent Programming Douglas C. Schmidt [email protected] Department of Computer Science Washington University, St. Louis 1 Intent The Monitor Object
RT Language Classes. Real-Time Programming Languages (ADA and Esterel as Examples) Implementation. Synchroneous Systems Synchronous Languages
RT Language Classes Real-Time Programming Languages (ADA and Esterel as Examples) HLL suitable for RT-Analysis (e.g., rms or time-driven) Synchronous HLL (clock driven) Esterel Lustre (State Charts) RT-Euclid
Linux Driver Devices. Why, When, Which, How?
Bertrand Mermet Sylvain Ract Linux Driver Devices. Why, When, Which, How? Since its creation in the early 1990 s Linux has been installed on millions of computers or embedded systems. These systems may
COS 318: Operating Systems. Semaphores, Monitors and Condition Variables
COS 318: Operating Systems Semaphores, Monitors and Condition Variables Prof. Margaret Martonosi Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall11/cos318/
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
Gildart Haase School of Computer Sciences and Engineering
Gildart Haase School of Computer Sciences and Engineering Metropolitan Campus I. Course: CSCI 6638 Operating Systems Semester: Fall 2014 Contact Hours: 3 Credits: 3 Class Hours: W 10:00AM 12:30 PM DH1153
Priority Based Implementation in Pintos
Priority Based Implementation in Pintos Deepa D 1, Nivas K S 2, Preethi V 3 1, 2, 3 Students M-Tech, Dept. of Information Technology, SNS College of Engg., Coimbatore. Abstract Pintos is a simple operating
Getting Started with the Internet Communications Engine
Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2
Multithreaded Programming
Java Multithreaded Programming This chapter presents multithreading, which is one of the core features supported by Java. The chapter introduces the need for expressing concurrency to support simultaneous
Concurrency in Object-Oriented Programming Languages
Chapter 2 Concurrency in Object-Oriented Programming Languages Michael Papathomas Abstract An essential motivation behind concurrent object-oriented programming is to exploit the software reuse potential
Exercises : Real-time Scheduling analysis
Exercises : Real-time Scheduling analysis Frank Singhoff University of Brest June 2013 Exercise 1 : Fixed priority scheduling and Rate Monotonic priority assignment Given a set of tasks defined by the
Android Application Development Course Program
Android Application Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive data types, variables, basic operators,
Course: Programming II - Abstract Data Types. The ADT Queue. (Bobby, Joe, Sue, Ellen) Add(Ellen) Delete( ) The ADT Queues Slide Number 1
Definition Course: Programming II - Abstract Data Types The ADT Queue The ADT Queue is a linear sequence of an arbitrary number of items, together with access procedures. The access procedures permit addition
Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition
Java 6 'th edition Concepts INTERNATIONAL STUDENT VERSION CONTENTS PREFACE vii SPECIAL FEATURES xxviii chapter i INTRODUCTION 1 1.1 What Is Programming? 2 J.2 The Anatomy of a Computer 3 1.3 Translating
Effective Computing with SMP Linux
Effective Computing with SMP Linux Multi-processor systems were once a feature of high-end servers and mainframes, but today, even desktops for personal use have multiple processors. Linux is a popular
OVERVIEW OF THE PROJECT...
SYSTEMS ENGINEERING DESIGN PROJECT ENPM 643, Fall 2006 Instructor Authors ENPM643 Dr. M Austin Atul Mehta & Felipe Leite Fall 2006 TABLE OF CONTENTS Section Page 1 OVERVIEW OF THE PROJECT... 3 1.1 PURPOSE...
