Technische universität dortmund fakultät für informatik informatik 12 Models of computation Peter Marwedel TU Dortmund Informatik 12 Graphics: © Alexandra.

Slides:



Advertisements
Similar presentations
Peter Marwedel TU Dortmund, Informatik 12
Advertisements

Fakultät für informatik informatik 12 technische universität dortmund VHDL-based synthesis in XST Peter Marwedel Informatik XII, U. Dortmund.
Fakultät für informatik informatik 12 technische universität dortmund Resource Access Protocols Peter Marwedel Informatik 12 TU Dortmund Germany 2008/12/06.
Fakultät für informatik informatik 12 technische universität dortmund Optimizations - Compilation for Embedded Processors - Peter Marwedel TU Dortmund.
FSMs & message passing: SDL
Fakultät für informatik informatik 12 technische universität dortmund Imperative model of computation Peter Marwedel TU Dortmund, Informatik 12 Graphics:
Technische universität dortmund fakultät für informatik informatik 12 Specifications and Modeling Peter Marwedel TU Dortmund, Informatik 12 Graphics: ©
fakultät für informatik informatik 12 technische universität dortmund Additional compiler optimizations Peter Marwedel TU Dortmund Informatik 12 Germany.
Fakultät für informatik informatik 12 technische universität dortmund Petri Nets Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra Nolte,
Fakultät für informatik informatik 12 technische universität dortmund Petri Nets Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra Nolte,
Evaluation and Validation
Fakult ä t f ü r informatik informatik 12 technische universit ä t dortmund Data flow models Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra.
Fakultät für informatik informatik 12 technische universität dortmund Specifications and Modeling Peter Marwedel TU Dortmund, Informatik 12 Graphics: ©
Fakultät für informatik informatik 12 technische universität dortmund Standard Optimization Techniques Peter Marwedel Informatik 12 TU Dortmund Germany.
Fakultät für informatik informatik 12 technische universität dortmund SDL Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra Nolte, Gesine.
Technische universität dortmund fakultät für informatik informatik 12 Discrete Event Models Peter Marwedel TU Dortmund, Informatik 12 Germany
Communicating finite state machines
Technische universität dortmund fakultät für informatik informatik 12 Specifications and Modeling Peter Marwedel TU Dortmund, Informatik
Technische Universität München Fakultät für Informatik Scientific Computing in Computer Science Practical Course CFD - Free Boundary Value Problems Tobias.
Embedded Systems & Parallel Programming P. Marwedel, Univ. Dortmund/Informatik 12 + ICD/ES, 2007 Universität Dortmund A view on embedded systems.
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
fakultät für informatik informatik 12 technische universität dortmund Optimizations - Compilation for Embedded Processors - Peter Marwedel TU Dortmund.
Technische universität dortmund fakultät für informatik informatik 12 Embedded System Design: Embedded Systems Foundations of Cyber-Physical Systems Peter.
Peter Marwedel TU Dortmund, Informatik 12
Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,
Fakultät für informatik informatik 12 technische universität dortmund Finite state machines + message passing: SDL Peter Marwedel TU Dortmund, Informatik.
Technische universität dortmund fakultät für informatik informatik 12 Embedded System Design: Embedded Systems Foundations of Cyber-Physical Systems Jian-Jia.
Technische universität dortmund fakultät für informatik informatik 12 Embedded Systems Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund,
Petri Nets Jian-Jia Chen (slides are based on Peter Marwedel)
Technische universität dortmund fakultät für informatik informatik 12 Specifications, Modeling, and Model of Computation Jian-Jia Chen (slides are based.
(slides are based on Peter Marwedel)
technische universität dortmund fakultät für informatik informatik 12 Early design phases Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund,
Technische universität dortmund fakultät für informatik informatik 12 Discrete Event Models Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund,
Technische universität dortmund fakultät für informatik informatik 12 Limits of von-Neumann (thread-based) computing Jian-Jia Chen (Slides are based on.
Hardware/ Software Partitioning 2011 年 12 月 09 日 Peter Marwedel TU Dortmund, Informatik 12 Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003 These.
Synchronization and Deadlocks
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
fakultät für informatik informatik 12 technische universität dortmund Test Peter Marwedel TU Dortmund Informatik 12 Germany Graphics: © Alexandra Nolte,
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Lecture 5 Concurrency and Process/Thread Synchronization     Mutual Exclusion         Dekker's Algorithm         Lamport's Bakery Algorithm.
Fakultät für informatik informatik 12 technische universität dortmund Lab 4: Exploiting the memory hierarchy - Session 14 - Peter Marwedel Heiko Falk TU.
Fakultät für informatik informatik 12 technische universität dortmund Specifications - Session 5 - Peter Marwedel TU Dortmund Informatik 12 Germany Slides.
fakultät für informatik informatik 12 technische universität dortmund Early design phases Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
System Software (2) Peter Marwedel TU Dortmund, Informatik 12 Germany 2013 年 11 月 26 日 These slides use Microsoft clip arts. Microsoft copyright restrictions.
Fakultät für informatik informatik 12 technische universität dortmund Imperative languages Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Fakultät für informatik informatik 12 technische universität dortmund Universität Dortmund Middleware Peter Marwedel TU Dortmund, Informatik 12 Germany.
Understandable Concurrency Edward A. Lee Professor, Chair of EE, and Associate Chair of EECS Director, CHESS: Center for Hybrid and Embedded Software Systems.
Concurrency and Software Transactional Memories Satnam Singh, Microsoft Faculty Summit 2005.
Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,
fakultät für informatik informatik 12 technische universität dortmund Specifications - sessions Peter Marwedel TU Dortmund Informatik 12 Germany.
Fakultät für informatik informatik 12 technische universität dortmund Modeling levels Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra Nolte,
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 2003 Universität Dortmund Actual design flows and tools.
Course Outline DayContents Day 1 Introduction Motivation, definitions, properties of embedded systems, outline of the current course How to specify embedded.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 2005/6 Universität Dortmund Specifications.
12/1/98 COP 4020 Programming Languages Parallel Programming in Ada and Java Gregory A. Riccardi Department of Computer Science Florida State University.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Concurrent Programming. Concurrency  Concurrency means for a program to have multiple paths of execution running at (almost) the same time. Examples:
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Universität Dortmund System Software (2) Peter Marwedel TU Dortmund, Informatik 12 Germany 2012 年 11 月 28 日 These slides use Microsoft clip arts. Microsoft.
technische universität dortmund fakultät für informatik informatik 12 Early design phases Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund,
Technische universität dortmund fakultät für informatik informatik 12 Imperative model of computation Peter Marwedel Informatik 12 TU Dortmund Germany.
Technische universität dortmund fakultät für informatik informatik 12 Finite state machines & message passing: SDL Peter Marwedel TU Dortmund, Informatik.
2. Specification and Modeling
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Embedded System Design Specifications and Modeling
Standard Optimization Techniques
Specifications and Modeling
Presentation transcript:

technische universität dortmund fakultät für informatik informatik 12 Models of computation Peter Marwedel TU Dortmund Informatik 12 Graphics: © Alexandra Nolte, Gesine Marwedel, /10/21 These slides use Microsoft clip arts. Microsoft copyright restrictions apply.

- 2 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Models of computation What does it mean, to compute? Models of computation define: Components and an execution model for computations for each component Communication model for exchange of information between components. C-1 C-2

- 3 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Models of computation considered in this course Communication/ local computations Shared memory Message passing Synchronous | Asynchronous Undefined components Plain text, use cases | (Message) sequence charts Communicating finite state machines StateChartsSDL Data flow(Not useful)Kahn networks, SDF Petri nets C/E nets, P/T nets, … Discrete event (DE) model VHDL, Verilog, SystemC, … Only experimental systems, e.g. distributed DE in Ptolemy Von Neumann modelC, C++, JavaC, C++, Java with libraries CSP, ADA |

- 4 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Why not just use von-Neumann computing (C, Java, …) ? Potential race conditions ( inconsistent results possible) Critical sections = sections at which exclusive access to resource r (e.g. shared memory) must be guaranteed. process a {.. P(S) //obtain lock.. // critical section V(S) //release lock } process b {.. P(S) //obtain lock.. // critical section V(S) //release lock } Race-free access to shared memory protected by S possible This model may be supported by: mutual exclusion for critical sections cache coherency protocols

- 5 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Why not just use von-Neumann computing (C, Java, …) (2)? Problems with von-Neumann Computing Thread-based multiprocessing may access global variables We know from the theory of operating systems that access to global variables might lead to race conditions, to avoid these, we need to use mutual exclusion, mutual exclusion may lead to deadlocks, avoiding deadlocks is possible only if we accept performance penalties.

- 6 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Consider a Simple Example The Observer pattern defines a one-to-many dependency between a subject object and any number of observer objects so that when the subject object changes state, all its observer objects are notified and updated automatically. Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides: Design Patterns, Addision- Wesley, 1995 © Edward Lee, Berkeley, Artemis Conference, Graz, 2007

- 7 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Example: Observer Pattern in Java public void addListener(listener) {…} public void setValue(newvalue) { myvalue=newvalue; for (int i=0; i<mylisteners.length; i++) { myListeners[i].valueChanged(newvalue) } Thanks to Mark S. Miller for the details of this example. Will this work in a multithreaded context? © Edward Lee, Berkeley, Artemis Conference, Graz, 2007

- 8 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Example: Observer Pattern with Mutual Exclusion (mutexes) public synchronized void addListener(listener) {…} public synchronized void setValue(newvalue) { myvalue=newvalue; for (int i=0; i<mylisteners.length; i++) { myListeners[i].valueChanged(newvalue) } Javasoft recommends against this. Whats wrong with it? © Edward Lee, Berkeley, Artemis Conference, Graz, 2007

- 9 - technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Mutexes using monitors are minefields public synchronized void addListener(listener) {…} public synchronized void setValue(newvalue) { myvalue=newvalue; for (int i=0; i<mylisteners.length; i++) { myListeners[i].valueChanged(newvalue) } valueChanged() may attempt to acquire a lock on some other object and stall. If the holder of that lock calls addListener(): deadlock! © Edward Lee, Berkeley, Artemis Conference, Graz, 2007 x calls addListener valueChanged requests lock held by x mutex

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Simple Observer Pattern Becomes not so simple public synchronized void addListener(listener) {…} public void setValue(newValue) { synchronized (this) { myValue=newValue; listeners=myListeners.clone(); } for (int i=0; i<listeners.length; i++) { listeners[i].valueChanged(newValue) } while holding lock, make a copy of listeners to avoid race conditions notify each listener outside of the synchronized block to avoid deadlock This still isnt right. Whats wrong with it? © Edward Lee, Berkeley, Artemis Conference, Graz, 2007

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Simple Observer Pattern: How to Make it Right? public synchronized void addListener(listener) {…} public void setValue(newValue) { synchronized (this) { myValue=newValue; listeners=myListeners.clone(); } for (int i=0; i<listeners.length; i++) { listeners[i].valueChanged(newValue) } Suppose two threads call setValue(). One of them will set the value last, leaving that value in the object, but listeners may be notified in the opposite order. The listeners may be alerted to the value-changes in the wrong order! © Edward Lee, Berkeley, Artemis Conference, Graz, 2007

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 A stake in the ground … Nontrivial software written with threads, semaphores, and mutexes is incomprehensible to humans. © Edward Lee, Berkeley, Artemis Conference, Graz, 2007

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Problems with thread-based concurrency … threads as a concurrency model are a poor match for embedded systems. … they work well only … where best-effort scheduling policies are sufficient. Edward Lee: Absolutely Positively on Time, IEEE Computer, July, 2005 Even the core … notion of computable is at odds with the requirements of embedded software. In this notion, useful computation terminates, but termination is undecidable. In embedded software, termination is failure, and yet to get predictable timing, subcomputations must decidably terminate. What is needed is nearly a reinvention of computer science.

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Models of computation considered in this course Communication/ local computations Shared memory Message passing Synchronous | Asynchronous Undefined components Plain text, use cases | (Message) sequence charts Communicating finite state machines StateChartsSDL Data flow(Not useful)Kahn networks, SDF Petri nets C/E nets, P/T nets, … Discrete event (DE) model VHDL, Verilog, SystemC, … Only experimental systems, e.g. distributed DE in Ptolemy Von Neumann modelC, C++, JavaC, C++, Java with libraries CSP, ADA | No language that meets all language requirements using compromises

technische universität dortmund fakultät für informatik informatik 12 Early design phases Peter Marwedel TU Dortmund, Informatik 12 Graphics: © Alexandra Nolte, Gesine Marwedel, /05/08

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Capturing the requirements as text In the very early phases of some design project, only descriptions of the system under design (SUD) in a natural language such as English or Japanese exist. Expectations for tools: Machine-readable Version management Dependency analysis Example: DOORS® [Telelogic/IBM]

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Use cases Use cases describe possible applications of the SUD Included in UML (Unified Modeling Language) Example: Answering machine Neither a precisely specified model of the computations nor a precisely specified model of the communication

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 (Message) Sequence charts Explicitly indicate exchange of information One dimension (usually vertical dimension) reflects time The other reflects distribution in space Example: Included in UML Earlier called Message Sequence Charts, now mostly called Sequence Charts

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Example (2) deliverable 2.1

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Application: In-Car Navigation System Car radio with navigation system User interface needs to be responsive Traffic messages (TMC) must be processed in a timely way Several applications may execute concurrently © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 System Overview NAVRAD MMI DB Communication © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 NAVRAD MMI DB Communication Use case 1: Change Audio Volume < 200 ms < 50 ms © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Use case 1: Change Audio Volume © Thiele, ETHZ Communication Resource Demand

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 NAVRAD MMI DB Communication < 200 ms Use case 2: Lookup Destination Address © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Use case 2: Lookup Destination Address © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 NAVRAD MMI DB Communication Use case 3: Receive TMC Messages < 1000 ms © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Use case 3: Receive TMC Messages © Thiele, ETHZ

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 (Message) Sequence Charts (MSC) No distinction between accidental overlap and synchronization

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Time/distance diagrams as a special case © Levi-TDD

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 UML: Timing diagrams Can be used to show the change of the state of an object over time. © Scott Ambler, Agile Modeling, // ing.com, 2003

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Life Sequence Charts * (LSCs) * W. Damm, D. Harel: LSCs: Breathing Life into Message Sequence Charts, Formal Methods in System Design, 19, 45–80, 2001 Key problems observed with standard MSCs: During the design process, MSC are initially interpreted as what could happen (existential interpretation, still allowing other behaviors). Later, they are frequently assumed to describe what must happen (referring to what happens in the implementation).

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Extensions for LSCs (1) Extension 1: Introduction of pre- charts: Pre-charts describe conditions that must hold for the main chart to apply. Extension 1: Introduction of pre- charts: Pre-charts describe conditions that must hold for the main chart to apply. Pre-chart Example:

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Extensions (2) Extension 2: Mandatory vs. provisional behavior LevelMandatory (solid lines)Provisional (dashed lines) Chart All runs of the system satisfy the chart At least one run of the system satisfies the chart LocationInstance must move beyond location/time Instance run need not move beyond loc/time MessageIf message is sent, it will be received Receipt of message is not guaranteed ConditionCondition must be met; otherwise abort If condition is not met, exit subchart

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 PROs: Appropriate for visualizing schedules, Proven method for representing schedules in transportation. Standard defined: ITU-TS Recommendation Z.120: Message Sequence Chart (MSC), ITU-TS, Geneva, Semantics also defined: ITU-TS Recommendation Z.120: Message Sequence Chart (MSC)Annex B: Algebraic Semantics of Message Sequence Charts, ITU-TS, Geneva. CONS: describes just one case, no timing tolerances: "What does an MSC specification mean: does it describe all behaviors of a system, or does it describe a set of sample behaviors of a system? * * H. Ben-Abdallah and S. Leue, Timing constraints in message sequence chart specifications, in Proc. 10th International Conference on Formal Description Techniques FORTE/PSTV97, Chapman and Hall, (Message) Sequence Charts

technische universität dortmund fakultät für informatik informatik 12 Communicating finite state machines Peter Marwedel TU Dortmund Informatik 12 Graphics: © Alexandra Nolte, Gesine Marwedel, /05/08

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Models of computation considered in this course Communication/ local computations Shared memory Message passing Synchronous | Asynchronous Undefined components Plain text, use cases | (Message) sequence charts Communicating finite state machines StateChartsSDL Data flow(Not useful)Kahn networks, SDF Petri nets C/E nets, P/T nets, … Discrete event (DE) model VHDL, Verilog, SystemC, … Only experimental systems, e.g. distributed DE in Ptolemy Von Neumann modelC, C++, JavaC, C++, Java with libraries CSP, ADA |

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 StateCharts: recap of classical automata Classical automata: Moore-automata: Y = ( Z ); Z + = ( X, Z ) Mealy-automata Y = ( X, Z ); Z + = ( X, Z ) Moore-automata: Y = ( Z ); Z + = ( X, Z ) Mealy-automata Y = ( X, Z ); Z + = ( X, Z ) Internal state Z input X output Y Next state Z + computed by function Output computed by function Z0Z1 Z2Z3 e = clock Moore- + Mealy automata=finite state machines (FSMs)

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Timed automata Timed automata = automata + models of time The variables model the logical clocks in the system, that are initialized with zero when the system is started, and then increase synchronously with the same rate. Clock constraints i.e. guards on edges are used to restrict the behavior of the automaton. A transition represented by an edge can be taken when the clocks values satisfy the guard labeled on the edge. Additional invariants make sure, the transition is taken. Clocks may be reset to zero when a transition is taken [Bengtsson and Yi, 2004].

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Example: Answering machine May take place, but does not have to Ensures that transition takes place

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Definitions Let C : real-valued variables C representing clocks. Let : finite alphabet of possible inputs. Definition: A clock constraint is a conjunctive formula of atomic constraints of the form x n or xy n for x, y C, {,,} and n N Let B ( C ) be the set of clock constraints. Definition: A timed automaton A is a tuple ( S, s 0,E, I ) where S is a finite set of states, s 0 is the initial state, E S × B ( C )× ×2 C × S is the set of edges, B ( C ): conjunctive condition, 2 C : variables to be reset I : S B ( C ) is the set of invariants for each of the states B ( C ): invariant that must hold for state S

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Definitions (2) Let C : real-valued variables C representing clocks. Let : finite alphabet of possible inputs. Definition: A clock constraint is a conjunctive formula of atomic constraints of the form x n or xy n for x, y C, {,,} and n N Let B ( C ) be the set of clock constraints. Definition: A timed automaton A is a tuple ( S, s 0,E, I ) where S is a finite set of states, s 0 is the initial state, E S × B ( C )× ×2 C × S is the set of edges, B ( C ): conjunctive condition, 2 C : variables to be reset I : S B ( C ) is the set of invariants for each of the states, B ( C ): invariant that must hold for state S

technische universität dortmund fakultät für informatik P.Marwedel, Informatik 12, 2011 Summary Motivation for non-von Neumann models Support for early design phases Text Use cases (Message) sequence charts Automata models Timed automata