The Problem with Treads

Size: px
Start display at page:

Download "The Problem with Treads"

Transcription

1 The Problem with Treads Edward A. Lee Programming Technology Lecture 2 11/09/08

2 Background on Edward A. Lee Bachelors degree (Yale University) (1979) Master degree (MIT) (1981) Ph.D. (U. C. Berkeley) (1986) Fellow of the IEEE Robert S. Pepper Distinguished Professor Former chair of the Electrical Engineering and Computer Sciences department at U.C. Berkeley Director of Berkeley Center for Hybrid and Embedded Software Systems Director of the Berkeley Ptolemy project He is co-author of five books and numerous papers.

3 About IEEE Computer The largest society in IEEE Founded i 1946 "Dedicated to advancing the theory and application of computer and information-processing technology" Known worldwide for its computer-standards activities The CS promotes an active exchange of ideas and technological innovation among its members

4 Intro Concurrent programming is difficult. Concurrent programming is becoming more urgent. The performance gains in computing, must be done by exploiting parallelism Automatic exploitation of parallelism in sequential programs Automatic program parallelization of sequential programs Automatic techniques have been pushed about as far as it will go It capable of exploiting only modest parallelism

5 Human vs. concurrency Physical world is highly concurrent survival depends on our ability to reason about concurrent physical dynamic Concurrent abstractions Not resemble the concurrency of the physical world Used to these computational abstractions That we think that the can not change The paper argue that the difficulty of concurrent programming is a consequence of the abstractions, the problem will be fixable if let go of those abstractions.

6 Threads The dominating approach to concurrent programming Sequential processes that share memory Key concurrency model supported by modern computers programming languages operating systems Symmetric multiprocessors are direct hardware realizations of the thread abstraction Can effectively be used by Webserver independence of these applications more like processes than threads where memory is not shared database abstractions However client-side applications are not so simple.

7 Threads Not the only possibility data parallel language extensions message passing libraries These are often used in scientific computing where threads not are the dominating solution This often differ significantly from so-called general purpose architectures In embedded applications reliability and predictability over expressiveness or performance The paper argues that achieving reliability and predictability using threads is essentially impossible for many applications.

8 Threads The core abstraction, which all widely-used programming languages are built on, emphasizes deterministic composition of deterministic components Threads are wildly nondeterministic The programmer has the job to prune away that nondeterminism by using Semaphores Monitors The Paper argue that we must (and can) build concurrent models of computation that are far more deterministic, and that we must judiciously and carefully introduce nondeterminism where needed.

9 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { value = newvalue; Iterator i = listeners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

10 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { value = newvalue; Iterator i = listeners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

11 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { value = newvalue; Iterator i = listeners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

12 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public synchronized void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { List copyoflisteners; synchronized(this) { value = newvalue; copyoflisteners = new LinkedList(listeners); Iterator i = copyoflisteners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

13 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public synchronized void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { List copyoflisteners; synchronized(this) { value = newvalue; copyoflisteners = new LinkedList(listeners); Iterator i = copyoflisteners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

14 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public synchronized void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { List copyoflisteners; synchronized(this) { value = newvalue; copyoflisteners = new LinkedList(listeners); Iterator i = copyoflisteners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

15 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public synchronized void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { List copyoflisteners; synchronized(this) { value = newvalue; copyoflisteners = new LinkedList(listeners); Iterator i = copyoflisteners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

16 public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valuechanged(int newvalue); public synchronized void addlistener(listener listener) { listeners.add(listener); public void setvalue(int newvalue) { List copyoflisteners; synchronized(this) { value = newvalue; copyoflisteners = new LinkedList(listeners); Iterator i = copyoflisteners.iterator(); while(i.hasnext()) { ((Listener)i.next()).valueChanged(newValue);

17 Fixing Threads by More Aggressive Pruning Better software engineering processes Ptolemy Project (2000) code maturity rating system design reviews code reviews nightly builds regression tests 100 percent code coverage No problems were observed until the code deadlocked four years later The paper conclude that testing may never reveal all the problems in nontrivial multithreaded code. Quick fix: always acquire locks in the same order method signature do not indicates what locks, it needs

18 Fixing Threads by More Aggressive Pruning 2 Software engineering process improvements alone will not do the job Use transactions, like in databases well-suited for multiple actors compete nondeterministically for resources not well-suited for building determinate concurrent interactions Concurrency is encapsulated into libraries by experts Using Proxies of the data Introduces formal program analysis to identify potential concurrency bugs in multi threaded programs still require considerable expertise Fix some but not all still result in highly nondeterministic programs

19 Fixing Threads by More Aggressive Pruning 2 Instead of startingwith a highly nondeterministic mechanism like threads, and relying on the programmer to prune that nondeterminacy, we should start with deterministic, and introduce nondeterminism only where needed

20 Alternatives to Threads

21 Alternatives to Threads 2

22 Alternatives to Threads 3 everything about the program is deterministic except the explicitly nondeterministic interaction specified by the Merge block

23 Challenges and Opportunities alternatives to threads have been around for a long time the core abstractions of computation, are deeply rooted in the sequential paradigm threads are either a minor extension to these languages java, just an external library. We should not replace established languages. We should instead build on them. The paper believe that the right answer is coordination languages. But coordination languages have also been around for a long time failed because of the homogeneity

24 Conclusion Concurrency in software is difficult blame ourselves of the abstractions for concurrency that we have chosen The dominant one is Threads We can improve by using design patterns better granularity of atomicity (e.g. transactions) improved languages formal methods Concurrent programming models can be constructed that are much more predictable and understandable than threads Nondeterminism should be introduced where needed, and should be explicit in programs

25 My Conclusion Threads are generally not bad Too much work in not using them Know what, you are doing, when programming

26 Reviewer Questions

The Problem with Threads

The Problem with Threads The Problem with Threads Author Edward A Lee Presented by - Varun Notibala Dept of Computer & Information Sciences University of Delaware Threads Thread : single sequential flow of control Model for concurrent

More information

Understandable Concurrency

Understandable Concurrency Edward A. Lee Professor, Chair of EE, and Associate Chair of EECS Director, CHESS: Center for Hybrid and Embedded Software Systems Director, Ptolemy Project UC Berkeley Chess Review November 21, 2005 Berkeley,

More information

Concurrent programming is difficult,1 yet many

Concurrent programming is difficult,1 yet many C O V E R F E A T U R E The Problem with Threads Edward A. Lee University of California, Berkeley For concurrent programming to become mainstream, we must discard threads as a programming model. Nondeterminism

More information

Concurrency & Multithreading

Concurrency & Multithreading Concurrency & Multithreading Multithreaded Programming Pieter Hijma Multithreaded Programming Multithreaded Programming is really difficult. Problems race conditions non-determinism deadlock termination

More information

Concurrent Semantics without the Notions of State or State Transitions

Concurrent Semantics without the Notions of State or State Transitions Concurrent Semantics without the Notions of State or State Transitions Edward A. Lee Robert S. Pepper Distinguished Professor Chair of EECS UC Berkeley Invited talk FORMATS 2006: 4-th International Conference

More information

fakultät für informatik informatik 12 technische universität dortmund Specifications Peter Marwedel TU Dortmund, Informatik /11/15

fakultät für informatik informatik 12 technische universität dortmund Specifications Peter Marwedel TU Dortmund, Informatik /11/15 12 Specifications Peter Marwedel TU Dortmund, Informatik 12 2008/11/15 Graphics: Alexandra Nolte, Gesine Marwedel, 2003 Structure of this course Application Knowledge 3: Embedded System HW 2: Specifications

More information

Concurrent Models of Computation

Concurrent Models of Computation Concurrent Models of Computation Edward A. Lee Robert S. Pepper Distinguished Professor, UC Berkeley EECS 219D: Concurrent Models of Computation Fall 2011 Copyright 2011, Edward A. Lee, All rights reserved

More information

Concurrency Demands New Foundations for Computing

Concurrency Demands New Foundations for Computing Concurrency Demands New Foundations for Computing Edward A. Lee Robert S. Pepper Distinguished Professor Chair of EECS UC Berkeley Invited Talk ARTIST2 Workshop on MoCC Models of Computation and Communication

More information

Making Concurrency Mainstream

Making Concurrency Mainstream Making Concurrency Mainstream Edward A. Lee Professor, Chair of EECS UC Berkeley Joint Invited Talk CONCUR: Concurrency Theory & FMICS: Formal Methods for Industrial Critical Systems Bonn, Germany, August

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Introduction to Embedded Systems Edward A. Lee & Sanjit Seshia UC Berkeley EECS 124 Spring 2008 Copyright 2008, Edward A. Lee & Sanjit Seshia, All rights reserved Lecture 17: Concurrency 2: Threads Definition

More information

Specifications and Modeling

Specifications and Modeling 12 Specifications and Modeling Peter Marwedel TU Dortmund, Informatik 12 2009/10/20 Graphics: Alexandra Nolte, Gesine Marwedel, 2003 Structure of this course 2: Specification Design repository Design Application

More information

SCCharts. Sequentially Constructive Charts

SCCharts. Sequentially Constructive Charts SCCharts Sequentially Constructive Charts Reinhard von Hanxleden, Björn Duderstadt, Christian Motika, Steven Smyth, Michael Mendler, Joaquin Aguado, Stephen Mercer, and Owen O Brien Real-Time Systems and

More information

Disciplined Concurrent Models of Computation for Parallel Software

Disciplined Concurrent Models of Computation for Parallel Software Disciplined Concurrent Models of Computation for Parallel Software Edward A. Lee Robert S. Pepper Distinguished Professor and UC Berkeley Invited Keynote Talk 2008 Summer Institute The Concurrency Challenge:

More information

Concurrent Models of Computation

Concurrent Models of Computation Concurrent Models of Computation Edward A. Lee Robert S. Pepper Distinguished Professor, UC Berkeley EECS 219D Concurrent Models of Computation Fall 2011 Copyright 2009-2011, Edward A. Lee, All rights

More information

EE382N.23: Embedded System Design and Modeling

EE382N.23: Embedded System Design and Modeling EE38N.3: Embedded System Design and Modeling Lecture 5 Process-Based MoCs Andreas Gerstlauer Electrical and Computer Engineering University of Texas at Austin gerstl@ece.utexas.edu Lecture 5: Outline Process-based

More information

Future Directions. Edward A. Lee. Berkeley, CA May 12, A New Computational Platform: Ubiquitous Networked Embedded Systems. actuate.

Future Directions. Edward A. Lee. Berkeley, CA May 12, A New Computational Platform: Ubiquitous Networked Embedded Systems. actuate. Future Directions Edward A. Lee 6th Biennial Ptolemy Miniconference Berkeley, CA May 12, 2005 A New Computational Platform: Ubiquitous Networked Embedded Systems sense actuate control Ptolemy II support

More information

An Introduction to Parallel Programming

An Introduction to Parallel Programming An Introduction to Parallel Programming Ing. Andrea Marongiu (a.marongiu@unibo.it) Includes slides from Multicore Programming Primer course at Massachusetts Institute of Technology (MIT) by Prof. SamanAmarasinghe

More information

Synchronization in Concurrent Programming. Amit Gupta

Synchronization 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 information

Actor-Oriented Design: Concurrent Models as Programs

Actor-Oriented Design: Concurrent Models as Programs Actor-Oriented Design: Concurrent Models as Programs Edward A. Lee Professor, UC Berkeley Director, Center for Hybrid and Embedded Software Systems (CHESS) Parc Forum Palo Alto, CA May 13, 2004 Abstract

More information

Introduction to Locks. Intrinsic Locks

Introduction to Locks. Intrinsic Locks CMSC 433 Programming Language Technologies and Paradigms Spring 2013 Introduction to Locks Intrinsic Locks Atomic-looking operations Resources created for sequential code make certain assumptions, a large

More information

The Problem With Threads

The Problem With Threads The Problem With Threads Edward A. Lee Robert S. Pepper Distinguished Professor and Chair of EECS UC Berkeley -and - Senior Technical Adviser, director, and co-founder of BDTI Class #: ESC-211 Embedded

More information

Imperative model of computation

Imperative model of computation 12 Imperative model of computation Jian-Jia Chen (Slides are based on Peter Marwedel) Informatik 12 TU Dortmund Germany Springer, 2010 2016 年 11 月 09 日 These slides use Microsoft clip arts. Microsoft copyright

More information

Synchronization 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 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 information

Multiple Inheritance. Computer object can be viewed as

Multiple 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 information

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II)

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics

More information

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 13 Robert Grimm, New York University 1 Review Last week Exceptions 2 Outline Concurrency Discussion of Final Sources for today s lecture: PLP, 12

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

Midterm Exam Amy Murphy 19 March 2003

Midterm Exam Amy Murphy 19 March 2003 University of Rochester Midterm Exam Amy Murphy 19 March 2003 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your

More information

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

Sharing Objects Ch. 3

Sharing Objects Ch. 3 Sharing Objects Ch. 3 Visibility What is the source of the issue? Volatile Dekker s algorithm Publication and Escape Thread Confinement Immutability Techniques of safe publication Assignment 1 Visibility

More information

Midterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100

Midterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100 Midterm Exam CS169 Fall 2009 November 17, 2009 Please read all instructions (including these) carefully. Write your name, login, and SID. There are 12 pages in this exam and 6 questions, each with multiple

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 9: Readers-Writers and Language Support for Synchronization 9.1.2 Constraints 1. Readers can access database

More information

CMSC 433 Programming Language Technologies and Paradigms. Concurrency

CMSC 433 Programming Language Technologies and Paradigms. Concurrency CMSC 433 Programming Language Technologies and Paradigms Concurrency What is Concurrency? Simple definition Sequential programs have one thread of control Concurrent programs have many Concurrency vs.

More information

Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019

Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019 Threads and Too Much Milk! CS439: Principles of Computer Systems February 6, 2019 Bringing It Together OS has three hats: What are they? Processes help with one? two? three? of those hats OS protects itself

More information

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Poor co-ordination that exists in threads on JVM is bottleneck

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Introduction to Embedded Systems Sanjit A. Seshia UC Berkeley EECS 149/249A Fall 2015 2008-2015: E. A. Lee, A. L. Sangiovanni-Vincentelli, S. A. Seshia. All rights reserved. Chapter 3: Discrete Dynamics,

More information

Interface Automata and Actif Actors

Interface Automata and Actif Actors Interface Automata and Actif Actors H. John Reekie Dept. of Electrical Engineering and Computer Science University of California at Berkeley johnr@eecs.berkeley.edu Abstract This technical note uses the

More information

MODERN MULTITHREADING

MODERN MULTITHREADING MODERN MULTITHREADING Implementing, Testing, and Debugging Multithreaded Java and C++/Pthreads/Win32 Programs RICHARD H. CARVER KUO-CHUNG TAI A JOHN WILEY & SONS, INC., PUBLICATION MODERN MULTITHREADING

More information

Lecture 8: September 30

Lecture 8: September 30 CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate

More information

Balance between Formal and Informal Methods, Engineering and Artistry, Evolution and Rebuild

Balance between Formal and Informal Methods, Engineering and Artistry, Evolution and Rebuild Balance between Formal and Informal Methods, Engineering and Artistry, Evolution and Rebuild Edward A. Lee, Professor, UC Berkeley, eal@eecs.berkeley.edu Technical Memorandum UCB/ERL M04/19 July 4, 2004

More information

Threads and Parallelism in Java

Threads 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 information

Parallel Programming Multicore systems

Parallel Programming Multicore systems FYS3240 PC-based instrumentation and microcontrollers Parallel Programming Multicore systems Spring 2011 Lecture #9 Bekkeng, 4.4.2011 Introduction Until recently, innovations in processor technology have

More information

Classes and Inheritance in Actor- Oriented Models

Classes and Inheritance in Actor- Oriented Models Classes and Inheritance in Actor- Oriented Models Stephen Neuendorffer Edward Lee UC Berkeley Chess Review May 8, 2003 Berkeley, CA Introduction Component-based design Object-oriented components Actor-oriented

More information

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 Learning from Bad Examples CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 1 Goals Demonstrate techniques to design for shared mutability Build on an example where multiple threads

More information

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some

More information

CS510 Advanced Topics in Concurrency. Jonathan Walpole

CS510 Advanced Topics in Concurrency. Jonathan Walpole CS510 Advanced Topics in Concurrency Jonathan Walpole Threads Cannot Be Implemented as a Library Reasoning About Programs What are the valid outcomes for this program? Is it valid for both r1 and r2 to

More information

3/25/14. Lecture 25: Concurrency. + Today. n Reading. n P&C Section 6. n Objectives. n Concurrency

3/25/14. Lecture 25: Concurrency. + Today. n Reading. n P&C Section 6. n Objectives. n Concurrency + Lecture 25: Concurrency + Today n Reading n P&C Section 6 n Objectives n Concurrency 1 + Concurrency n Correctly and efficiently controlling access by multiple threads to shared resources n Programming

More information

CS5460: Operating Systems

CS5460: Operating Systems CS5460: Operating Systems Lecture 9: Implementing Synchronization (Chapter 6) Multiprocessor Memory Models Uniprocessor memory is simple Every load from a location retrieves the last value stored to that

More information

CS140 Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming Midterm Exam CS140 Operating Systems and Systems Programming Midterm Exam October 31 st, 2003 (Total time = 50 minutes, Total Points = 50) Name: (please print) In recognition of and in the spirit of the Stanford University

More information

Atomicity CS 2110 Fall 2017

Atomicity CS 2110 Fall 2017 Atomicity CS 2110 Fall 2017 Parallel Programming Thus Far Parallel programs can be faster and more efficient Problem: race conditions Solution: synchronization Are there more efficient ways to ensure the

More information

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Last Time CPU Scheduling discussed the possible policies the scheduler may use to choose the next process (or thread!)

More information

THREADS AND CONCURRENCY

THREADS AND CONCURRENCY THREADS AND CONCURRENCY Lecture 22 CS2110 Spring 2013 Graphs summary 2 Dijkstra: given a vertex v, finds shortest path from v to x for each vertex x in the graph Key idea: maintain a 5-part invariant on

More information

Embedded Tutorial CPS Foundations

Embedded Tutorial CPS Foundations Embedded Tutorial CPS Foundations Edward A. Lee Robert S. Pepper Distinguished Professor UC Berkeley Special Session: Cyber-Physical Systems Demystified Design Automation Conference (DAC 2010) Annaheim,

More information

Performance Throughput Utilization of system resources

Performance 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 information

Cover Page. The handle holds various files of this Leiden University dissertation

Cover Page. The handle   holds various files of this Leiden University dissertation Cover Page The handle http://hdl.handle.net/1887/22891 holds various files of this Leiden University dissertation Author: Gouw, Stijn de Title: Combining monitoring with run-time assertion checking Issue

More information

Thread-Local. Lecture 27: Concurrency 3. Dealing with the Rest. Immutable. Whenever possible, don t share resources

Thread-Local. Lecture 27: Concurrency 3. Dealing with the Rest. Immutable. Whenever possible, don t share resources Thread-Local Lecture 27: Concurrency 3 CS 62 Fall 2016 Kim Bruce & Peter Mawhorter Some slides based on those from Dan Grossman, U. of Washington Whenever possible, don t share resources Easier to have

More information

Concurrent Models of Computation

Concurrent Models of Computation Concurrent Models of Computation Edward A. Lee Robert S. Pepper Distinguished Professor, UC Berkeley EECS 290n Advanced Topics in Systems Theory Concurrent Models of Computation Spring 2009 Copyright 2009,

More information

EE382V: Embedded System Design and Modeling

EE382V: Embedded System Design and Modeling EE382V: Embedded System Design and Models of Computation Andreas Gerstlauer Electrical and Computer Engineering University of Texas at Austin gerstl@ece.utexas.edu : Outline Models of Computation (MoCs)

More information

Introducing Embedded Systems: A Cyber- Physical Systems Approach

Introducing Embedded Systems: A Cyber- Physical Systems Approach Introducing Embedded Systems: A Cyber- Physical Systems Approach Edward A. Lee Robert S. Pepper Distinguished Professor UC Berkeley CPS PI Meeting Education Keynote With special thanks to my collaborators:

More information

CS 31: Intro to Systems Threading & Parallel Applications. Kevin Webb Swarthmore College November 27, 2018

CS 31: Intro to Systems Threading & Parallel Applications. Kevin Webb Swarthmore College November 27, 2018 CS 31: Intro to Systems Threading & Parallel Applications Kevin Webb Swarthmore College November 27, 2018 Reading Quiz Making Programs Run Faster We all like how fast computers are In the old days (1980

More information

Concurrent ML. John Reppy January 21, University of Chicago

Concurrent ML. John Reppy January 21, University of Chicago Concurrent ML John Reppy jhr@cs.uchicago.edu University of Chicago January 21, 2016 Introduction Outline I Concurrent programming models I Concurrent ML I Multithreading via continuations (if there is

More information

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to

More information

THE 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 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 information

Today: Synchronization. Recap: Synchronization

Today: Synchronization. Recap: Synchronization Today: Synchronization Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical section

More information

Runtime Atomicity Analysis of Multi-threaded Programs

Runtime Atomicity Analysis of Multi-threaded Programs Runtime Atomicity Analysis of Multi-threaded Programs Focus is on the paper: Atomizer: A Dynamic Atomicity Checker for Multithreaded Programs by C. Flanagan and S. Freund presented by Sebastian Burckhardt

More information

MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE

MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE 163103058 April 2017 Basic of Concurrency In multiple processor system, it is possible not only to interleave processes/threads but

More information

Concurrency: State Models & Design Patterns

Concurrency: State Models & Design Patterns Concurrency: State Models & Design Patterns Practical Session Week 02 1 / 13 Exercises 01 Discussion Exercise 01 - Task 1 a) Do recent central processing units (CPUs) of desktop PCs support concurrency?

More information

RACE CONDITIONS AND SYNCHRONIZATION

RACE CONDITIONS AND SYNCHRONIZATION RACE CONDITIONS AND SYNCHRONIZATION Lecture 21 CS2110 Fall 2010 Reminder 2 A race condition arises if two threads try and share some data One updates it and the other reads it, or both update the data

More information

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing Final Exam General Information The final exam will be held Monday, Dec 21st, 2009, 11:30am-2:30pm, DCC 308. A makeup

More information

Concurrent Component Patterns, Models of Computation, and Types

Concurrent Component Patterns, Models of Computation, and Types Concurrent Component Patterns, Models of Computation, and Types Edward A. Lee Yuhong Xiong Department of Electrical Engineering and Computer Sciences University of California at Berkeley Presented at Fourth

More information

Models of concurrency & synchronization algorithms

Models of concurrency & synchronization algorithms Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu

More information

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing

More information

Threads Synchronization

Threads Synchronization Synchronization Threads Synchronization Threads share memory so communication can be based on shared references. This is a very effective way to communicate but is prone to two types of errors: Interference

More information

Synchronization Lecture 24 Fall 2018

Synchronization Lecture 24 Fall 2018 Synchronization Lecture 24 Fall 2018 Prelim 2 tonight! The room assignments are on the course website, page Exams. Check it carefully! Come on time! Bring you Cornell id card! No lunch with gries this

More information

Concurrent Programming

Concurrent Programming Concurrency Concurrent Programming A sequential program has a single thread of control. Its execution is called a process. A concurrent program has multiple threads of control. They may be executed as

More information

Concurrency & Parallelism. Threads, Concurrency, and Parallelism. Multicore Processors 11/7/17

Concurrency & Parallelism. Threads, Concurrency, and Parallelism. Multicore Processors 11/7/17 Concurrency & Parallelism So far, our programs have been sequential: they do one thing after another, one thing at a. Let s start writing programs that do more than one thing at at a. Threads, Concurrency,

More information

Models of computation

Models of computation 12 Models of computation Peter Marwedel TU Dortmund Informatik 12 Springer, 2010 2012 年 10 月 23 日 These slides use Microsoft clip arts. Microsoft copyright restrictions apply. Models of computation What

More information

Synchronization. Announcements. Concurrent Programs. Race Conditions. Race Conditions 11/9/17. Purpose of this lecture. A8 released today, Due: 11/21

Synchronization. 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 information

Producing 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 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 information

C++ Memory Model. Don t believe everything you read (from shared memory)

C++ Memory Model. Don t believe everything you read (from shared memory) C++ Memory Model Don t believe everything you read (from shared memory) The Plan Why multithreading is hard Warm-up example Sequential Consistency Races and fences The happens-before relation The DRF guarantee

More information

Warm-up question (CS 261 review) What is the primary difference between processes and threads from a developer s perspective?

Warm-up question (CS 261 review) What is the primary difference between processes and threads from a developer s perspective? Warm-up question (CS 261 review) What is the primary difference between processes and threads from a developer s perspective? CS 470 Spring 2018 POSIX Mike Lam, Professor Multithreading & Pthreads MIMD

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

Threads, Concurrency, and Parallelism

Threads, Concurrency, and Parallelism Threads, Concurrency, and Parallelism Lecture 24 CS2110 Spring 2017 Concurrency & Parallelism So far, our programs have been sequential: they do one thing after another, one thing at a time. Let s start

More information

740: Computer Architecture Memory Consistency. Prof. Onur Mutlu Carnegie Mellon University

740: Computer Architecture Memory Consistency. Prof. Onur Mutlu Carnegie Mellon University 740: Computer Architecture Memory Consistency Prof. Onur Mutlu Carnegie Mellon University Readings: Memory Consistency Required Lamport, How to Make a Multiprocessor Computer That Correctly Executes Multiprocess

More information

Internet and Intranet Protocols and Applications

Internet and Intranet Protocols and Applications Internet and Intranet Protocols and Applications Writing Good Multi-Threaded Java Programs April, 2004 Prof. Arthur Goldberg Computer Science Department New York University 1 Why write concurrent programs?

More information

Threads and Locks. CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015

Threads and Locks. CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015 Threads and Locks CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015 1 Goals Cover the material presented in Chapter 2, Day 1 of our concurrency textbook Creating threads Locks Memory

More information

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Nicolas Bettenburg 1 Universitaet des Saarlandes, D-66041 Saarbruecken, nicbet@studcs.uni-sb.de Abstract. As traditional

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Introduction to Embedded Systems Edward A. Lee & Sanjit Seshia UC Berkeley EECS Spring 008 Copyright 008, Edward A. Lee & Sanjit Seshia, All rights reserved Lecture 0: Scheduling Anomalies Source This

More information

CS370 Operating Systems Midterm Review

CS370 Operating Systems Midterm Review CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Spring 2018 Lecture 15: Multicore Geoffrey M. Voelker Multicore Operating Systems We have generally discussed operating systems concepts independent of the number

More information

CSE332: Data Abstractions Lecture 19: Mutual Exclusion and Locking

CSE332: Data Abstractions Lecture 19: Mutual Exclusion and Locking CSE332: Data Abstractions Lecture 19: Mutual Exclusion and Locking James Fogarty Winter 2012 Including slides developed in part by Ruth Anderson, James Fogarty, Dan Grossman Banking Example This code is

More information

Problems with Concurrency. February 19, 2014

Problems 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 information

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ! Last Class: CPU Scheduling! Scheduling Algorithms: FCFS Round Robin SJF Multilevel Feedback Queues Lottery Scheduling Review questions: How does each work? Advantages? Disadvantages? Lecture 7, page 1

More information

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Computation 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 information

Concurrent Programming Method for Embedded Systems

Concurrent Programming Method for Embedded Systems Concurrent Programming Method for Embedded Systems Norbert Schramm UVA, 24000 Subotica, Serbia norbert.schramm@gmail.com Anita Sabo Polytechnical Engineering College Subotica M. Oreškovića 16, 24000 Subotica,

More information

Overview. Background: Efforts Prior to EduPar 11. EduPar 11 Outcome (I): Required Core Modules. EduPar 11 Outcome (II): Advanced/Elective Modules

Overview. Background: Efforts Prior to EduPar 11. EduPar 11 Outcome (I): Required Core Modules. EduPar 11 Outcome (II): Advanced/Elective Modules PDC Modules for Every Level: A Comprehensive Model for Incorporating PDC Topics into the Existing Undergraduate Curriculum EduPar 11 Early Adoption Report, 2013 Update, 15 February 2013 1 Joseph P. Kaylor,

More information

Grand Central Dispatch

Grand Central Dispatch A better way to do multicore. (GCD) is a revolutionary approach to multicore computing. Woven throughout the fabric of Mac OS X version 10.6 Snow Leopard, GCD combines an easy-to-use programming model

More information

3/7/18. Secure Coding. CYSE 411/AIT681 Secure Software Engineering. Race Conditions. Concurrency

3/7/18. Secure Coding. CYSE 411/AIT681 Secure Software Engineering. Race Conditions. Concurrency Secure Coding CYSE 411/AIT681 Secure Software Engineering Topic #13. Secure Coding: Race Conditions Instructor: Dr. Kun Sun String management Pointer Subterfuge Dynamic memory management Integer security

More information

Multi-core Architectures. Dr. Yingwu Zhu

Multi-core Architectures. Dr. Yingwu Zhu Multi-core Architectures Dr. Yingwu Zhu What is parallel computing? Using multiple processors in parallel to solve problems more quickly than with a single processor Examples of parallel computing A cluster

More information