Title: Actor Oriented Programming with CAL designing embedded system components
1Actor Oriented Programming with CAL-designing
embedded system components
- Johan Eker
- Department of Automatic Control, Lund University
- Chris Chang, Jörn Janneck, Yang Zhao
- EECS, University of California at Berkeley
- LUCAS Seminar, October 22, 2002
2Multipurpose tools
- Express almost anything, guarantee
almost nothing - You only need to know one programming
language! - Easy to get started, harder to finish
- Programmerslanguage, a lifelong
marriage - Examples
- Java
- C/C with RTOS, ADA, Modula-2
- RMA EDF scheduling
3Sharpen your tools
- Use problem specific tools
- Constrain the solutions
- Combine several dedicated tools
- Dont get it right, keep it right
4Component Technologya component is a component
is a component
- Examples Java beans, VB-components, etc
- Rationale
- Encapsulation Reuse
- Successful in many areas
- Embedded components
- Problems with concurrency
- Threads do not compose well
- Difficult to encapsulate properties such as
priorities, deadlines, execution times, etc. - Static interfaces not good enough
- State-of-the art technology does not suffice
5Enter actor oriented programming
- Actors and models
- An application (or a model) is expressed as a
network of actors - Actors communicate via token passing
- When an actor is fired it consumes tokens and
produces token - The actor itself is agnostic about when and how
it is scheduled and how and with whom it is
communicating
6What's an actor
parameters
input ports
output ports
99
12
\
3
1
N
Actor
tokens
tokens
L
A
C
Data
state
Actors decouple data and control
7What's an application
B
D
A schedule Fire A Fire A Fire B Fire A Fire
C Fire D
A
C
- A Model of Computation governs the actor
interaction, i.e. - Sheduling
- Communication
8Hierarchical, heterogeneous modeling and design
in Ptolemy II
Slide courtesy of Edward Lee
9Components
- Actor Component
- A network of actors can be transformed into a
single actor
MoC
10Enter CALCal Actor Language
- A domain-specific language for writing dataflow
actors - Ports, states, parameters
- Produces consumes tokens
A
actor A() Double input Double output
mutable Integer n 0 mutable Double sum
0 action a sum / n do n n
1 sum sum a end end
11Multiple actions and tags
- An actors defines a set of input-output relation
- Port pattern example
- in11,2,3, in21 matches all
- in11, in22 matches a2 a4
- in11,2,3, in2 matches a1
12Parameters Guards
actor A(Double max) Double input Double
output mutable Integer n 0 mutable
Double sum 0 action a guard sum
max do end action a sum / n do
n n 1 sum sum a end end
13Action schedules, priorities type parameters
actor FairMergeT() T Input1, T Input2 T
Output A action a, a do end
B action , a a do end schedule (A
B) end end
- other selectors are conceivable, e.g.
- (A B) (B A)
- ( (A B) (B A) )
actor AnotherMergeT() T Input1, T Input2 T
Output A action a, a do end
B action a, b a do end priority B
A end end
14A CAL Application
15Analysis of a CAL Application
input
input
output
output
- Map the network into a petri net
- Compute firing vectors
- Find legal firing sequences
- Select a schedule
- Calculate buffer sizes
- Fold the CAL actor descriptions for A, B C
16Source level transformation
Assume we found the following schedule
- fire A, action a2
- fire B, action b1
- fire C, action c1
What are the benefits?
- Removes external buffers
- No need for a scheduler
- Source level components
- CAL provides an dynamic
- component interface
Components are refined upon composition!
17Some Cal Buzzwords
- Control flow analysis
- Token production/consumption rates
- Side effect free expressions
- Lambda and procedural closures
- First class of course
- Type parametric
- Immutable varibles as default
- No aliasing
18(No Transcript)
19Key Concept Orthogonal Concerns
20Summary
- Embedded system components
- Java code for Ptolemy II/Grafchart frameworks
- C-code
- Compiler is being developed at UCB and Thales
Research Ltd, UK. - More information
- Eker et al Taming heterogeneity-the Ptolemy
Approach, IEEE Proceedings - http//www.gigascale.org/caltrop
- http//ptolemy.eecs.berkeley.edu