Top Banner
NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures Supporting Interface-Based Design Presented by Edward A. Lee Chess, UC Berkeley
32

NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

NSF

Foundations of Hybrid and Embedded Software Systems

UC Berkeley: ChessVanderbilt University: ISISUniversity of Memphis: MSI

Advanced Tool Architectures Supporting Interface-Based Design

Presented byEdward A. LeeChess, UC Berkeley

Page 2: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 2

NSF ITR Deliverables

A set of reusable, inter-operating software modules, freely distributed as open-source software. These modules will be toolkits and frameworks that support the design of embedded systems, provide infrastructure for domain-specific tools, and provide model-based code generators.

The starting point is a family of actor-oriented modeling tools and associated meta modeling tools.

Page 3: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 3

Tool Architectures

• Objective is to unify:– modeling– specification– design– programming

• Define modeling & design “languages” with:– syntaxes that aid understanding– composable abstractions– understandable concurrency and time– predictable behavior– robust behavior

All of these tasks are accomplished by the system designers.

Page 4: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 4

Actor-Oriented Design

• Object orientation:

class name

data

methods

call return

What flows through an object is

sequential control

• Actor orientation:actor name

data (state)

portsInput data

parameters

Output data

What flows through an object is data

streams

Page 5: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 5

Examples of Actor-OrientedComponent Frameworks

• Simulink (The MathWorks)• Labview (National Instruments)• Modelica (Linkoping)• OCP, open control platform (Boeing)• GME, actor-oriented meta-modeling (Vanderbilt)• SPW, signal processing worksystem (Cadence)• System studio (Synopsys)• ROOM, real-time object-oriented modeling (Rational)• Port-based objects (U of Maryland)• I/O automata (MIT)• VHDL, Verilog, SystemC (Various)• Polis & Metropolis (UC Berkeley)• Ptolemy & Ptolemy II (UC Berkeley)• …

Page 6: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 6

Actor View of Producer/Consumer Components

Models of Computation:

• continuous-time• dataflow• rendezvous• discrete events• synchronous• time-driven• publish/subscribe•…

Actor

IOPort

IORelation

P2P1

E1

E2

send(0,t) receiver.put(t) get(0)

token tR 1

Basic Transport:

Receiver(inside port)

Key idea: The model of computation defines the component interaction patterns and is part of the framework, not part of the components themselves.

Page 7: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 7

Object-Oriented and Actor-Oriented Design

• Object orientation:– strong typing– inheritance– procedural interfaces

• Actor orientation– concurrency– communication– real time

• These are complementary

ComponentEntityCompositeEntity

AtomicActor

CompositeActor

0..10..n

«In te rface»Actor

+getD irec tor() : D irec to r+getE xecutiveD irec tor() : D irec to r+getM anager() : M anager+ inputP ortL is t() : L is t+new R eceiver() : R ece iver+outpu tP ortL is t() : L is t

«In terface»Executable

+fire ()+ in itia lize()+pos tfire () : boo lean+prefire () : boo lean+pre in itia lize()+s topF ire ()+ term ina te()+w rapup()

Director

Actor orientation offers:• modeling the continuous environment (and hybrid systems)• understandable concurrency (vs. RPC, semaphores, and mutexes)• specifications of temporal behavior (vs. “prioritize and pray”)

UML object model emphasizes static structure.

Page 8: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 8

Two of Our Tool Starting Points

• GME: Generic Modeling Environment– Vanderbilt ISIS– Meta modeling of actor-oriented modeling– Proven for representing “abstract syntax”

(called by some “static semantics”)

• Ptolemy II– UC Berkeley Chess– Framework for exploring actor-oriented

semantics– Beginnings of meta modeling of actor-

oriented “abstract semantics”

Page 9: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 9

Actor-Oriented Modeling in GME

Domain-specific actor-oriented modeling environments are created from meta models, and a sophisticated, domain-specific UI is generated from those models.

Page 10: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 10

Meta Modeling in GME

Meta models consist of UML object models enriched by OCL constraints which capture structural properties shared by a family of models.

Page 11: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 11

Ptolemy II

A laboratory supporting experimentation with actor-oriented design, concurrent semantics, and visual syntaxes.

http://ptolemy.eecs.berkeley.edu

continuous environment

modal model

discrete controller

example Ptolemy model: hybrid control system

Page 12: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 12

Software Practice

• Ptolemy II and GME are widely recognized to be unusually high quality software from a research group.

• Software practice in the Ptolemy Project:– Object models in UML– Design patterns– Layered software architecture– Design and code reviews– Design document– Nightly build– Regression tests– Sandbox experimentation– Code rating

Page 13: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 13

Software is written to be read!

Code rating

• A simple framework for– quality improvement by peer review– change control by improved visibility– encouraging innovation

• Four confidence levels– Red. No confidence at all.– Yellow. Passed design review.

Soundness of the APIs.– Green. Passed code review.

Quality of implementation.– Blue. Passed final review.

Backwards-compatibility assurance.

Page 14: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 14

ComponentEntityCompositeEntity

AtomicActor

CompositeActor

0..10 ..n

« In te rface»Actor

+getD irec tor() : D irec to r+getE xecutiveD irec tor() : D irec to r+getM anager() : M anager+ inputP ortL is t() : L is t+new R ece iver() : R ece iver+outpu tP ortL is t() : L is t

«In te rface»Executable

+fire ()+ in itia lize ()+pos tfire () : boo lean+pre fire () : boo lean+pre in itia lize ()+s topF ire ()+ term ina te()+w rapup()

Director

Modeling Semantics in Ptolemy II –Object Model for Executable Components

Page 15: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 15

IOPort

FIFOQueue

1..1

1..1

«Interface»Receiver

+get() : Token+getContainer() : IOPort+hasRoom() : boolean+hasToken() : boolean+put(t : Token)+setContainer(port : IOPort)

0..1 0..n

QueueReceiver

NoRoomException

throws

NoTokenExceptionthrows

PNReceiver

«Interface»ProcessReceiver

CSPReceiver

SDFReceiver

ArrayFIFOQueue

1..11..1

DEReceiverMailbox

CTReceiver

Communication Protocols –Object Model for Messaging Framework

Page 16: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 16

Structuring This Space withInterface Theories

• Concept of Interface Theories is due to Tom Henzinger and his colleagues.

• We are using this concept to figure out what the Ptolemy Group has done with its software prototypes.

Page 17: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 17

Receiver Interface –Software Architecture Perspective

«Interface»Receiver

+get() : Token+getContainer() : IOPort+hasRoom() : boolean+hasToken() : boolean+put(t : Token)+setContainer(port : IOPort)

These polymorphic methods implement the communication semantics of a domain in Ptolemy II. The receiver instance used in communication is supplied by the director, not by the component.

produceractor

consumeractor

IOPort

Receiver

Director

Page 18: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 18

Behavioral Types –Interface Theory Perspective

• Capture the dynamic interaction of components in types

• Obtain benefits analogous to data typing.• Call the result behavioral types.

produceractor

consumeractor

IOPort

Receiver

Director

• Communication has– data types– behavioral types

• Components have– data type signatures– behavioral type signatures

• Components are– data polymorphic– domain polymorphic

Page 19: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 19

A Preliminary Behavioral Type System

• Based on interface automata– Proposed by de Alfaro and Henzinger– Concise composition (vs. standard automata)– Alternating simulation provides contravariant inputs/outputs

• Compatibility checking– Done by automata composition– Captures the notion “components can work together”

• Alternating simulation (from Q to P)– All input steps of P can be simulated by Q, and– All output steps of Q can be simulated by P.– Provides the ordering we need for subtyping & polymorphism

Page 20: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 20

Simple Example: One Place BufferShowing Consumer Interface Only

g get

hT hasToken

t Token

hTT Return True from hasToken

hTF Return False from hasToken

Outputs:Inputs:

Model of the interaction of a one-place buffer, showing the interface to a consumer actor.

consumerinterfaceBuffer:

Page 21: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 21

Two Candidate Consumer Actors

Consumer with check:Consumer without check:

bufferinterface

g get

hT hasToken

t Token

hTT Return True from hasToken

hTF Return False from hasToken

Inputs: Outputs:

Page 22: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 22

Composition: Behavioral Type Check

Consumer with check: Buffer:

Illegal states are pruned out of the composition. A composite state is illegal if an output produced by one has no corresponding input in the other.

Page 23: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 23

Composition: Behavioral Type Check

Buffer:

Consumer without check:

An empty composition means that all composite states are illegal. E.g., here, 0_0 is illegal, which results in pruning all states.

Page 24: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 24

Subclassing and Polymorphism

Buffer:

Buffer with Default:

Alternating simulation relation

We can construct a type lattice by defining a partial order based on alternating simulation. It properly reflects the desire for contravariant inputs and outputs.

Page 25: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 25

Contravariance of Inputs and Outputsin a Classical Type System

public Complex foo(Double arg)

BaseClass

public Double foo(Complex arg)

DerivedClass

Can accept more general inputs

… and deliver more specific outputs

DerivedClass remains a valid drop-

in substitution for BaseClass.

Page 26: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 26

Representing Models of Computation Synchronous Dataflow (SDF) Domain

produceractor

consumeractor

IOPort

Receiver

Director

receiverinterface

directorinterface

This can be composed with

models of actors to determine

compatibility.

Page 27: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 27

Subtyping Relation Between Models of Computation: SDF DE

SDF Domain

DE Domain

This enables the design of components that can operate

within multiple models of computation (“domain

polymorphic components”)

Page 28: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 28

Summary of Behavioral Types –Preliminary Results

• We capture patterns of component interaction in a type system framework: behavioral types

• We describe interaction types and component behavior using interface automata.

• We do type checking through automata composition (detect component incompatibilities)

• Subtyping order is given by the alternating simulation relation, supporting polymorphism.

• A behavioral type system is a set of automata that form a lattice under alternating simulation.

Page 29: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 29

Scalability

• Automata represent behavioral types– Not arbitrary program behavior– Descriptions are small– Compositions are small– Scalability is probably not an issue

• Type system design becomes an issue– What to express and what to not express– Restraint!

• Will lead to efficient type check and type inference algorithms

Page 30: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 30

Issues and Ideas

• Composition by name-matching– awkward, limiting.– use ports in hierarchical models?

• Rich subtyping:– extra ports interfere with alternating simulation.– projection automata?– use ports in hierarchical models?

• Synchronous composition:– composed automata react synchronously.– modeling mutual exclusion is awkward– use transient states?– hierarchy with transition refinements?

Page 31: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 31

More Speculative

• We can reflect component dynamics in a run-time environment, providing behavioral reflection.– admission control– run-time type checking– fault detection, isolation, and recovery (FDIR)

• Timed interface automata may be able to model real-time requirements and constraints.– checking consistency becomes a type check– generalized schedulability analysis

• Need a language with a behavioral type system– Visual syntax given here is meta modeling– Use this to build domain-specific languages

Page 32: NSF Foundations of Hybrid and Embedded Software Systems UC Berkeley: Chess Vanderbilt University: ISIS University of Memphis: MSI Advanced Tool Architectures.

Chess/ISIS/MSI 32

Conclusions

• You can expect from this team:– Sophisticated software– High quality, open-source software– Domain-specific modules– Generators for domain-specific modules

• Emphasis on:– Meta modeling of abstract syntax– Meta modeling of semantics– Actor-oriented design methods– Interface definitions– Composable models