Concurrent Models of Computation

Similar documents
Introduction to Embedded Systems

Modal Models in Ptolemy

Composition of State Machines

Hierarchical FSMs with Multiple CMs

Executing SyncCharts with Ptolemy

Concurrent Models of Computation

Finite State Machines and Modal Models in Ptolemy II

Multimodeling: A Preliminary Case Study

Synchronous Statecharts. Christian Motika

Interactive Esterel to SyncCharts Transformation. Christian Motika

Concurrent Models of Computation

Hybrid System Modeling: Operational Semantics Issues

Model Engineering using Multimodeling

Model Engineering using Multimodeling

Component-Based Design of Embedded Control Systems

The Ptolemy II Framework for Visual Languages

Specifications Part 1

Synchronous Dataflow Processong

Building Unreliable Systems out of Reliable Components: The Real Time Story

Fusing Dataflow with Finite State Machines

Understandable Concurrency

SCCharts. Sequentially Constructive Charts

The Future of the Ptolemy Project

Early design phases. Peter Marwedel TU Dortmund, Informatik /10/11. technische universität dortmund. fakultät für informatik informatik 12

FROM SYNCHRONOUS SPECIFICATIONS TO ASYNCHRONOUS DISTRIBUTED IMPLEMENTATIONS Technische Universitiit Miinchen Peter Scholz

Embedded Real-Time Systems

System Design, Modeling, and Simulation using Ptolemy II

Design of Embedded Systems: Formal Models, Validation, and Synthesis

The Problem with Treads

Model checking pushdown systems

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

PTIDES: A Discrete-Event-Based Programming Model for Distributed Embedded Systems

Sequential Constructiveness, SCL and SCCharts

World Wide Web Server.

The Esterel language

Overview of the Ptolemy Project

Handout 9: Imperative Programs and State

The Event-B Modelling Notation

Introduction 2 The first synchronous language (early 80 s) Gérard Berry and his team (École des Mines de Paris / INRIA Sophia-Antipolis) Imperative, s

Prof. Dr. Reinhard von Hanxleden. Christian-Albrechts Universität Kiel Department of Computer Science Real-Time Systems and Embedded Systems Group

Imperative model of computation

Compiling SCCharts A Case-Study on Interactive Model-Based Compilation

Section 8. The Basic Step Algorithm

Concurrent Component Patterns, Models of Computation, and Types

DESIGN AND SIMULATION OF HETEROGENEOUS CONTROL SYSTEMS USING PTOLEMY II

Activity Nets: A UML profile for modeling workflow and business processes

EE382N.23: Embedded System Design and Modeling

Introduction to Embedded Systems

ECL: A SPECIFICATION ENVIRONMENT FOR SYSTEM-LEVEL DESIGN

State Machine Diagrams

Dynamic Logic David Harel, The Weizmann Institute Dexter Kozen, Cornell University Jerzy Tiuryn, University of Warsaw The MIT Press, Cambridge, Massac

State-Based Testing Part B Error Identification. Generating test cases for complex behaviour

Classes and Inheritance in Actor- Oriented Models

SDL. Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund, Informatik 年 10 月 18 日. technische universität dortmund

Reinhard v. Hanxleden 1, Michael Mendler 2, J. Aguado 2, Björn Duderstadt 1, Insa Fuhrmann 1, Christian Motika 1, Stephen Mercer 3 and Owen Brian 3

Concurrent Models of Computation for Embedded Software

Disciplined Concurrent Models of Computation for Parallel Software

Updates on SCCharts Christian Motika Steven Smyth

Specifications and Modeling

Ptolemy II The automotive challenge problems version 4.1

Compositionality in Synchronous Data Flow: Modular Code Generation from Hierarchical SDF Graphs

Synchronous Languages Lecture 07

CA314 Object Oriented Analysis & Design - 7. File name: CA314_Section_07_Ver01 Author: L Tuohey No. of pages: 16

By: Chaitanya Settaluri Devendra Kalia

Q Body of techniques supported by. R precise mathematics. R powerful analysis tools. Q Rigorous, effective mechanisms for system.

EE249 Lab September 30 h, 2008 Hugo A. Andrade

Modeling Statecharts and Activitycharts as Signal Equations

A PRIMITIVE EXECUTION MODEL FOR HETEROGENEOUS MODELING

Overview. Synchronous Languages Lecture 12. Code Generation for Sequential Constructiveness. Compilation Overview. The 5-Minute Review Session

Towards Formalizing Domain-specific Modeling Languages. Kai Chen Janos Sztipanovits Sandeep Neema

Quick Introduction to SystemVerilog: Sequental Logic

Advanced Tool Architectures. Edited and Presented by Edward A. Lee, Co-PI UC Berkeley. Tool Projects. Chess Review May 10, 2004 Berkeley, CA

Petri Nets ee249 Fall 2000

Discrete-Event Modeling and Design of Embedded Software

Automatic Code Generation from Stateflow Models

Compositionality in system design: interfaces everywhere! UC Berkeley

Lecture 2. The SCADE Language Data Flow Kernel. Daniel Kästner AbsInt GmbH 2012

SCXML State Chart XML

Using and Compiling Esterel

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

Design and Specification of Embedded Systems in Java Using Successive, Formal Refinement

Introduction to Formal Methods

A Simple Example. The Synchronous Language Esterel. A First Try: An FSM. The Esterel Version. The Esterel Version. The Esterel Version

States Transitions Connectors Esterel Studio

Removing Cycles in Esterel Programs

Object Oriented Modeling

The Ptolemy Project. Modeling and Design of Reactive Systems. Presenter: Praveen Murthy, PhD Postdoc and Presenter

SCADE S E M I N A R I N S O F T W A R E E N G I N E E R I N G P R E S E N T E R A V N E R B A R R

visualstate Reference Guide

Embedded Software Engineering

Functional Languages. Hwansoo Han

LabVIEW Based Embedded Design [First Report]

Modeling Hybrid Systems with Petri Nets

Heterogeneous Simulation Mixing Discrete-Event Models with Dataflow

Concurrency Demands New Foundations for Computing

EL6483: Basic Concepts of Embedded System ModelingSpring and Hardware-In-The-Loo

Interface Automata and Actif Actors

Last Time. Introduction to Design Languages. Syntax, Semantics, and Model. This Time. Syntax. Computational Model. Introduction to the class

SOFTWARE MODELING AND DESIGN. UML, Use Cases, Patterns, and. Software Architectures. Ki Cambridge UNIVERSITY PRESS. Hassan Gomaa

EE382V: Embedded System Design and Modeling

Transcription:

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 reserved Week 7: Concurrent State Machines A collection of states: Lee 07: 2 l 1

An initial state: Lee 07: 3 A collection of transitions: Lee 07: 4 l 2

Transitions have labels: There are many variants of state machines, each giving different labels and semantics associated with those labels. Since we are interested in concurrent composition of state machines, we will give our state machines explicit inputs and outputs, and the labels will refer to these (reading and writing them). Lee 07: 5 Guards: Predicates on transitions This state machine is nondeterminate because there are two simultaneously enabled transitions leaving state B. Ptolemy II by default rejects such state machines. Lee 07: 6 l 3

Nondeterministic State Machines Transitions can be marked nondeterministic and the model executes. This state machine will remain in state B for a random number of ticks then go to C and stay there. Lee 07: 7 Final states: This model stops executing when it reaches state C. Lee 07: 8 l 4

Extended State Machines can operate on variables: If the variables include unbounded datatypes (integers, arrays), then the model become Turing complete. This model produces a random number and then stops. The set actions perform the operations on the local variable count. If the selection among transitions has fixed probability, then the random number generated will have a geometric distribution. Lee 07: 9 I/O Automata This model has an input port named input and an output port named output. Given an input with any (non-absent) value, it starts counting. It counts a random number of ticks according to a geometric distribution, and then produces an output. Lee 07: 10 l 5

Using this in an SR model This model produces one value after a random amount of time (according to a geometric distribution), and then none after that. Lee 07: 11 Hierarchical State Machines & Preemption Here, the count can be preempted by a reset signal. Here, the self transition is a reset transition, which means that when entering the destination state, it gets reset to its initial state. Lee 07: 12 l 6

Discussion Hierarchy is only syntactic sugar. How much syntax does it affect? Lee 07: 13 Modal Models Whereas Statecharts lumps together the state machine semantics and the concurrency model, Ptolemy II separates these. A state may refine to another state machine or to a concurrent model. Lee 07: 14 l 7

Concurrent State Machines in Ptolemy II The hierarchy can be further extended, where the concurrent model can include components that refine to state machines or other concurrent models. Instance This gives us concurrent state machines. Class definition Lee 07: 15 Background on Concurrent State Machines Statecharts [Harel 87] I/O Automata [Lynch 87] Esterel [Berry 92] SyncCharts [André 96] *Charts [Girault, Lee, Lee 99] Safe State Machine (SSM) [André 03] SCADE [Berry 03] Lee 07: 16 l 8

Simple Traffic Light Example in Statecharts Case study Pred: pedestrian red signal Pgrn(0): turn pedestrian green off Cgrn: car green Sec: one second time 2 Sec: two seconds time Pgo/Pstop: pedestrian go/stop Lee 07: 17 Traffic Light Example in Ptolemy II Whereas Statecharts lumps together the state machine semantics and the concurrency model, Ptolemy II separates these. Here we have chosen the SR Director, which realizes a true synchronous fixed point semantics. Lee 07: 18 l 9

Concurrent State Machines in Ptolemy II In Ptolemy II, we have implemented an SR Director (for synchronous concurrent models) and an FSM Director (for sequential decision logic). Rather than combining them into one language (like Statecharts), Ptolemy II supports hierarchical combinations of MoCs. Instance Class definition Lee 07: 19 Syntax Comparisons between Statecharts and Ptolemy II The Ptolemy II model and the Statecharts model differ in syntax. Some issues to consider when evaluating a syntax: l Rendering on a page l Showing dependencies in concurrent models l Scalability to complex models l Reusability (e.g. with other concurrency models) l Special notations (e.g. 3 Sec ). Lee 07: 20 l 10

Simple Traffic Light Example in Statecharts, from Reinhard von Hanxleden, Kiel University Case study for Ptolemy II Design In StateCharts, the communication between concurrent components is not represented graphically, but is rather represented by name matching. Can you tell whether there is feedback? Lee 07: 21 Syntax comparisons Now can you tell whether there is feedback? Lee 07: 22 l 11

Semantics Comparisons The Ptolemy II model and the Statecharts model have similar semantics, but combined in different ways. Some issues to consider: l Separation of concurrency from state machines l Nesting of distinct models of computation l Expanding beyond synchronous + FSM to model the (stochastic) environment and deployment to hardware. l Styles of synchronous semantics (Ptolemy II realizes a true fixed-point constructive semantics). Lee 07: 23 Constructive Semantics (Part 1) When using state machines with SR providing the concurrency model, then semantics is given by the least fixed point, obtained constructively via the Kleene fixedpoint theorem. Lee 07: 24 l 12

Side-by-Side Composition Synchronous composition: the machines react simultaneously and instantaneously. Lee 07: 25 Cascade Composition Synchronous composition: the machines react simultaneously and instantaneously, despite the apparent causal relationship! Lee 07: 26 l 13

Synchronous Composition: Reactions are Simultaneous and Instantaneous Consider a cascade composition as follows: Lee 07: 27 Synchronous Composition: Reactions are Simultaneous and Instantaneous In this model, you must not think of machine A as reacting before machine B. If it did, the unreachable states would not be unreachable. S C = S A S B unreachable Lee 07: 28 l 14

Feedback Composition Recall that everything can be viewed as feedback composition. Lee 07: 29 Well-Formed Feedback At the n-th reaction, we seek s(n) V y {absent} such that s(n)=(f (n))(s(n)) There are two potential problems: s 1. It does not exist. 2. It is not unique. x y In either case, we call the system ill formed. Otherwise, it is well formed. Note that if a state is not reachable, then it is irrelevant to determining whether the machine is well formed. Lee 07: 30 l 15

Well-Formed Example In state s1, we get the unique s(n)=absent. In state s2, we get the unique s(n)=present. Therefore, s alternates between absent and present. Lee 07: 31 Composite Machine Lee 07: 32 l 16

Ill-Formed Example 1 (Existence) In state s1, we get the unique s(n)=absent. In state s2, there is no fixed point. Since state s2 is reachable, this composition is ill formed. Lee 07: 33 Ill-Formed Example 2 (Uniqueness) In s1, both s(n)=absent and s(n)=present are fixed points. In state s2, we get the unique s(n)=present. Since state s1 is reachable, this composition is ill formed. Lee 07: 34 l 17

Constructive Semantics: Single Signal 1. Start with s(n) unknown. 2. Determine as much as you can about ( f (n))(s(n)). 3. If s(n) becomes known (whether it is present, and if it is not pure, what its value is), then we have a unique fixed point. A state machine for which this procedure works is said to be constructive. Lee 07: 35 Non-Constructive Well-Formed State Machine In state s1, if the input is unknown, we cannot immediately tell what the output will be. We have to try all the possible values for the input to determine that in fact s(n)=absent for all n. For non-constructive machines, we are forced to do exhaustive search. This is only possible if the data types are finite, and is only practical if the data types are small. Lee 07: 36 l 18

Must / May Analysis For the above constructive machine, in state s1, we can immediately determine that the machine may not produce an output. Therefore, we can immediately conclude that the output is absent, even though the input is unknown. In state s2, we can immediately determine that the machine must produce an output, so we can immediately conclude that the output is present. Lee 07: 37 Subtlety: Constructive Semantics (Part 2) The constructive semantics is based on two things: Iteration to a least fixed point. Construction of the functions f (n) from an FSM The second of these is subtle. Implicit default transition does not produce an output. Hence, to know that the output is present, must analyze guards to know that at least one of them is true! In general, this analysis is undecidable. In practice, it is far from trivial. Lee 07: 38 l 19

Constructive Semantics, Esterel Style (Berry, 2003) Iteration to a least fixed point. Construction of the functions f (n) from an FSM Where the latter asserts: An output is absent if no transition that might become enabled asserts it is present. An output is present if there exists a transition that is enabled and asserts the output. (Notice the asymmetry). Lee 07: 39 Constructive Semantics, Esterel Style (Berry, 2003) Rejects this model: because when the input is unknown, there is no single transition enabled that asserts the transition. Lee 07: 40 l 20

Ptolemy II Implements the Esterel-Style Constructive Semantics Lee 07: 41 Constructive Semantics: Multiple Signals 1. Start with s 1 (n),,s N (n) unknown. 2. Determine as much as you can about ( f (n))(s 1 (n),,s N (n)). 3. Using new information about s 1 (n),,s N (n), repeat step (2) until no information is obtained. 4. If s 1 (n),,s N (n) all become known, then we have a unique fixed point and a constructive machine. A state machine for which this procedure works is said to be constructive. Lee 07: 42 l 21

Constructive Semantics: Multiple Actors Procedure is the same. Lee 07: 43 Constructive Semantics: Arbitrary Structure Procedure is the same. A state machine language with constructive semantics will reject all compositions that in any iteration fail to make all signals known. Such a language rejects some well-formed compositions. Lee 07: 44 l 22

Conclusions State machines, extended state machines, and I/O automata provide expressive sequential decision logic. Variants support hierarchy (in different ways), nondeterminism, etc. Statecharts is a composition of a single-clock synchronousreactive concurrent MoC with finite state machines. Ptolemy II separates these two semantic models using the idea of modal models. Lee 07: 45 l 23