MULTITASKING AND SCHEDULING EEN 417 Fall 2013. Layers of Abstraction for Concurrency in Programs.
Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.
-
Upload
calvin-french -
Category
Documents
-
view
219 -
download
3
Transcript of Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.
![Page 1: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/1.jpg)
Hybrid SystemsConcurrent Models of Computation
EEN 417Fall 2013
![Page 2: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/2.jpg)
HYBRID SYSTEMS
![Page 3: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/3.jpg)
Discrete System (FSM)
Continuous System
Hybrid System jump
flow
![Page 4: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/4.jpg)
Topics in Today’s Lecture Examples of Hybrid Systems
The Hybrid Automaton Model – properties of this kind of model
![Page 5: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/5.jpg)
A Thermostat
(happen instantaneously)
![Page 6: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/6.jpg)
Dynamics of Thermostat
t
x82
80
70
68
on
off
![Page 7: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/7.jpg)
Hybrid Automaton for Thermostat
Is this automaton deterministic?
![Page 8: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/8.jpg)
Formal Representation of Hybrid Automaton
![Page 9: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/9.jpg)
Where do Hybrid Systems arise?
Digital controller of physical “plant” – thermostat – controller for power plant– intelligent cruise control in cars – aircraft auto pilot
Phased operation of natural phenomena– bouncing ball– biological cell growth
Multi-agent systems– ground and air transportation systems– interacting robots (e.g., RoboSoccer)
![Page 10: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/10.jpg)
Another example
Example due to George Pappas, UPenn
Change in Temperature
510 550
+1 +5
-5 -1
-9 -5
![Page 11: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/11.jpg)
Nuclear reactor example (contd.)
Example due to George Pappas, UPenn
Each time step, T, y1, and y2 change.
![Page 12: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/12.jpg)
Hybrid Automaton for Bouncing Ball
x – vertical distance from ground (position)v – velocity c – coefficient of restitution, 0 · c · 1
![Page 13: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/13.jpg)
Behavior of Bouncing Ball Automaton: Plot position x as a function of time t ,
where x starts at height xmax
What kind of plot would you expect?
![Page 14: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/14.jpg)
Simulation of Bouncing Ball Automaton in Ptolemy II / HyVisual
![Page 15: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/15.jpg)
Zeno Behavior
What is a Zeno machine?
![Page 16: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/16.jpg)
Zeno Behavior
•Informally:• The system makes an infinite number of jumps• in finite time
![Page 17: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/17.jpg)
A Run/Execution of a Hybrid Automatontim
e
![Page 18: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/18.jpg)
Zeno Behavior: Formal Definitiontim
e
![Page 19: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/19.jpg)
Analysis of Zeno Behavior of Bouncing Ball
![Page 20: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/20.jpg)
Why does Zeno Behavior Arise?
![Page 21: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/21.jpg)
Why does Zeno Behavior Arise?•Our model is a mathematical artifact
![Page 22: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/22.jpg)
Why does Zeno Behavior Arise?•Our model is a mathematical artifact
•Zeno behavior is mathematically possible, but it is infeasible in the real, physical world
•Points to some unrealistic assumption in the model
![Page 23: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/23.jpg)
CONCURRENT MODELS OF COMPUTATION
![Page 24: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/24.jpg)
Recall: Actor Model for State Machines
•Expose inputs and outputs, enabling composition:
![Page 25: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/25.jpg)
Recall: Actor Model of Continuous-Time Systems
•A system is a function that accepts an input signal and yields an output signal.
•The domain and range of the system function are sets of signals, which themselves are functions.
•Parameters may affect the definition of the function S.
![Page 26: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/26.jpg)
Example: Actor model of the helicopter
•Input is the net torque of the tail rotor and the top rotor. Output is the angular velocity around the y axis.
Parameters of the model are shown in the box. The input and output relation is given by the equation to the right.
![Page 27: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/27.jpg)
Recall: Composition of actor models
![Page 28: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/28.jpg)
Recall: Feedback Composition
Angular velocity appears on both
sides. The semantics (meaning) of
the model is the solution to this
equation.
![Page 29: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/29.jpg)
Models of Computation (MoC)•A model of computation assigns semantics (meaning) to the syntax defined in the actor model.
•The MoC gives operational rules for executing a model. These rules determine when actors perform internal computation, update their internal state, and perform external communication.
•An MoC also defines the nature of communication between components (e.g., buffered I/O).
![Page 30: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/30.jpg)
Model of Computation (MoC):Continuous Time (CT)
![Page 31: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/31.jpg)
Discrete-Time (DT) Actor Models
•Discrete-time helicopter model looks the same:
![Page 32: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/32.jpg)
Time-Triggered Reactions of FSMs use a Discrete-Time MoC
sigG
sigY
sigR
sigR
pedR
pedG
![Page 33: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/33.jpg)
Mixed Signal Models•A more reasonable model of a discrete helicopter controller would be a mixed-signal model:
•Here, the signals inside the blue area are continuous-time signals, and the ones outside are discrete-time signals.
![Page 34: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/34.jpg)
To jointly model discrete and continuous-time signals in the same MoC, use the notion of “absent” values
Event-triggered composition of state machines uses a discrete-event MoC.
![Page 35: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/35.jpg)
Actors are not the only way to do things
•Imperative, Threads, Declarative physical models, Constraints, …
Modelica
model of an
industrial robot.
Modelica uses
Spice-like
models where
components
have no inputs
or outputs.
![Page 36: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/36.jpg)
Uniformly Timed Schedule
•A preferable schedule would space invocations of A and B uniformly in time, as in:
…
minimum latency
![Page 37: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/37.jpg)
Non-Concurrent Uniformly Timed Schedule
•Notice that in this schedule, the rate at which A and B can be invoked is limited by the execution time of C.
…
No jitter, but utilization is poor.
![Page 38: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/38.jpg)
Concurrent Uniformly Timed Schedule:Preemptive schedule
•With preemption, the rate at which A and B can be invoked is limited only by total computation:
…
…preemptions
thread 1:
thread 2:
high priority
low priority
![Page 39: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/39.jpg)
Ignoring Initial Transients,Abstract to Periodic Tasks
•In steady-state, the execution follows a simple periodic pattern:
…
…
thread 1:
thread 2:
sampleTime = 1 sampleTime = 1
sampleTime = 8
This follows the principles of rate-monotonic scheduling (RMS).
![Page 40: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/40.jpg)
Requirement 1 for Determinacy: Periodicity
•If the execution of C runs longer than expected, data determinacy requires that thread 1 be delayed accordingly. This can be accomplished with semaphore synchronization. But there are alternatives: Throw an exception to indicate timing failure. “Anytime” computation: use incomplete results of C
…
…
thread 1:
thread 2:sampleTime: 1 sampleTime: 1
sampleTime: 8
interlock
![Page 41: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/41.jpg)
Requirement 1 for Determinacy: Periodicity
•If the execution of C runs shorter than expected, data determinacy requires that thread 2 be delayed accordingly. That is, it must not start the next execution of C before the data is available.
…
…
thread 1:
thread 2:sampleTime: 1 sampleTime: 1
sampleTime: 8
interlock
![Page 42: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/42.jpg)
Semaphore Synchronization Required Exactly Twice Per Major Period
•Note that semaphore synchronization is not required if actor B runs long because its thread has higher priority. Everything else is automatically delayed.
…
…
thread 1:
thread 2:sampleTime: 1 sampleTime: 1
sampleTime: 8
![Page 43: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/43.jpg)
Discussion Questions What about more complicated rate conversions (e.g. a task with sampleTime 2 feeding one with sampleTime 3)? How can these ideas be extended to non-periodic execution?
![Page 44: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/44.jpg)
Abstracted Version of the Spectrum Example
•Suppose that C requires 8 data values from A to execute. Suppose further that C takes much longer to execute than A or B. Then a schedule might look like this:
…
1 1
8
![Page 45: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/45.jpg)
WRAP UP
![Page 46: Hybrid Systems Concurrent Models of Computation EEN 417 Fall 2013.](https://reader036.fdocuments.in/reader036/viewer/2022062408/56649eb25503460f94bb8f60/html5/thumbnails/46.jpg)
For next time
Read Chapters 10, 11