Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu...
Transcript of Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu...
![Page 1: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/1.jpg)
Part 8: Transparent Distribution
Claudiu Farcas
Credits: MoDECS Project Team, GiottoDepartment of Computer Science
cs.uni-salzburg.at
Model Based Development of Embedded Control Software
![Page 2: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/2.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ2
Overview
MotivationTransparent DistributionBus Schedule Generation ToolModule stubs and TDL Run-time Environment
![Page 3: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/3.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ3
Motivation
MOST-BusMultimediasubsystems
CAN-Buspowertrain and body electronicscomfort / climatronic
Benefits from distribution:Scalability (CPU, IO)Low-cost componentsFault Tolerance
![Page 4: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/4.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ4
The advantages of transparent distribution
the functional and temporal behavior of a system is the same no matter where a component is executeddeveloper’s perspective: NO difference between local and distributed execution of componentsOEM-supplier perspective:the components can be developed independently
![Page 5: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/5.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ5
Transparent distribution in a nutshell
computing platform, for example, MPC555+OSEK
software component (hard real-time control system)
plantA S
M1
![Page 6: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/6.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ6
Transparent distribution in a nutshell
M1M2
component M2 added later,if required even at run-time
exactly defined communication semantics(TDL programming model)
![Page 7: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/7.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ7
Transparent distribution in a nutshell
deterministic timing and communication behaviorindependent of the computing and communication platform => portability through automatic code generation
and run-time environment
M1 M2
FlexRayTTCAN, EtherCAT, etc.
![Page 8: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/8.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ8
What do we need to achieve transparent distribution?
abstractions for embedded software that ignore the platform details, but capture the essence of embedded hard-real-time systems
=> Timing Definition Language (TDL)run-time environment that
efficiently executes programsis flexible enough to allow dynamic changes (adding/replacing/moving of components)
=> TDL run-time environment
![Page 9: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/9.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ9
The Giotto/TDL core abstraction: LET
LET means that the observable temporal behavior of a task is independent from its physical execution.
we gain crucial software properties: determinism, portability, composability
timetask invocation
Logical Execution Time (LET)
Logical
Physical
start stopsuspend resume
release terminate
Time for communication
![Page 10: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/10.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ10
Sample distribution of TDL componentsM1, M2, M3, M4
Unit of distribution: TDL moduleBehavior: as if executed locallyCommunication: via broadcast (bus)Medium access control: TDMA (time-slotting)Cooperation model: Producer-Consumer (Push)
bus
M2M3
M1
M4
node 1
node 2 node 3
![Page 11: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/11.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ11
Sample distribution of TDL componentsM1, M2, M3, M4
bus
M2M3
M1
M4
node 1
node 2 node 3
task1
M1 M2
task2
![Page 12: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/12.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ12
The purpose of the TDL-Comm layer
M1
comm1
comm2
timeLET1
bus
LET2
node1
node2 M2
messages are sent according to a bus schedule (TDMA)
![Page 13: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/13.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ13
Optimization I
if consumer runs slower e.g. by a factor of 2redundant message are avoidedsaves bandwidth
M1
M2
comm1
comm2
timeLET1
bus
LET2
node1
node2
![Page 14: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/14.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ14
Optimization II
if the consumer needs variable later than the producer’s LET can lead to better bus utilization
M1
M2
comm1
comm2
timeLET1
bus
LET2
node1
node2
![Page 15: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/15.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ15
Optimization III
the release of the receiver can be delayed until the message with the input variable is received
M1
M2
comm1
comm2
timeLET1
bus
LET2
node1
node2
![Page 16: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/16.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ16
Bus Schedule Generation Tool
![Page 17: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/17.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ17
Tool chain – Single Node setup
.tdl Compiler E-machine
AST
.ecode
functionality code
Platformplugin
platformspecific
platformspecific
![Page 18: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/18.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ18
Tool chain – Distributed system
.tdl Compiler E-machine
Bus Schedulerplugin
AST
.ecode
functionality code
Platformplugin
platformspecific
AST
platformspecific
platform busch
![Page 19: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/19.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ19
What Does the Tool Do?
It generates a global bus schedule file, which contains the following information:
Which node has to send a packet and when.
Which nodes have to receive a packet and when.
The content for bus packets (a corresponding datagram, which has one or more items/variables).
![Page 20: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/20.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ20
What Does the Tool Need?
TDL modulesPlatform description file
module to node assignmentphysical bus properties (e.g., bus frequency, protocol overhead, inter frame gaps, min/max payload)
The tool automatically detects:Who has to communicate with whom.Which messages are needed in a communication cycle (bus period).
![Page 21: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/21.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ21
Who has to Communicate with Whom
Results a set of messages.
A message has: a Sender port, one or more Receiver ports, size.
A Sender or Receiver port has: unique qualified identifier, period, and WCET.
Senders: sensors, task output ports.
Receivers: actuators, task input ports, guard arguments.
![Page 22: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/22.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ22
Messages Needed in a Bus Period
Results a set of message instances, with individual timing constraints:Release OffsetDeadline
Basic Producer-Consumer:Send messages with the frequency of the Sender:Message deadline = sender deadline.BusPeriod = LCM(Sender.period)
Optimized Producer-Consumer:Send messages only when they are needed by the Receivers.Message deadline depends on the optimization (e.g., = receiver release time).BusPeriod = LCM(Sender.period, Receiver.period)
![Page 23: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/23.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ23
Message Deadline in Optimization II
M1
M2
comm1
comm2
timeLET1
bus
LET2
node1
node2
Sender Deadline
Message Deadline
![Page 24: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/24.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ24
Message Scheduling
Current approach: 2 Steps scheduling:
schedule first the messages. schedule then the tasks with deadlines constraints from messages.
Optimizations:We build bus schedulers which allow more flexibility for the task scheduler.We try several bus schedulers and get feedback from the TSC for tasks.Schedule individual messages or merge messages sent from the same node
![Page 25: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/25.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ25
Scheduling Algorithms
Heuristic schedule - Latest Deadline Last (variant of Reversed EDF)
Schedule messages as late as possibleMay fail even when a schedule exists
Optimal schedule Branch and bound search Exponential complexity in the worst case.
![Page 26: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/26.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ26
Latest Deadline Last - Example
m3
m1
m2
Released messages {m1, m2, m3}
time m3
m1
m2
LDL scheduling {m2, m1, m3}
time
![Page 27: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/27.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ27
Latest Deadline Last
Sorts the list of messages by:Key1 = message deadlineKey2 = message release timeKey3 = sender deadline
Bus Scheduler is non-preemptive and just schedules the messages in the resulted order.
Starts from the end of the Bus PeriodMerges messages if they have to be sent by the same node, and are adjacent.
![Page 28: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/28.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ28
Search Scheduler - Example
m1
m2
LDL scheduling failure {m2, m1}
time m1
m2
Search scheduler {m1, m2}
time
![Page 29: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/29.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ29
Bus Properties as Constraints
Relevant for:Merging messages (min/max payload)WCCT (Bps, protocol overhead) Time alignment (inter frame gaps, clock resolution)Control packets (time synchronization)
Clock Resolution:TDL time unit is microsecond (us).Different platforms have a given clock resolution (e.g., 1ms or 100us).Bus communication is computed in microseconds or even nanoseconds.
![Page 30: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/30.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ30
Merging Messages and Clock Resolution
m1
m1
m2
m2
Scheduled m1
Scheduled m2
Aligned m1
Aligned m2
m1m2
m1m2
Merged m1+m2
Aligned m1+m2
time
![Page 31: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/31.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ31
Measurements
Metrics relevant for efficient bus utilization:Throughput Bus utilizationAverage data efficiencyMaximum and average sending ratesMaximum and average receiving rates
Metrics relevant for flexibility in task scheduling:Minimum and average release-send intervalsMinimum and average relative release-send intervals
![Page 32: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/32.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ32
Module stubs and theTDL E-Machine
![Page 33: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/33.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ33
TDL run-time system: E-Machine
runs on each computing nodeexecutes E-code instructions at logical time instancesimplementation is platform dependent (OSEK, InTime, RTLinux, Java)it is fast and lightweight (e.g. 13 KB for the OSEK E-machine).
supports three kinds of module executions: local, push, and stub.
![Page 34: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/34.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ34
Module import relationships
bus
M2M3
M1
M4node 2
node 1
node 3
M2 imports M1
M4 imports M1, M3
![Page 35: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/35.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ35
E-Machine actions
M1
comm1
comm2
timeLET1
bus
LET2
node1
node2
M2
stop driver
release driver
M1 stub
terminate driver
![Page 36: Model Based Development of Embedded Control Software · Part 8: Transparent Distribution Claudiu Farcas Credits: MoDECS Project Team, Giotto Department of Computer Science cs.uni-salzburg.at](https://reader034.fdocuments.us/reader034/viewer/2022050410/5f86df0d29c238269633fb24/html5/thumbnails/36.jpg)
© 2005 C. Farcas, E. Farcas, W. Pree and J. Templ36
Module execution attributes
bus
M2M3M1 stub
M1 node 1
node 2
M2 imports M1
M4 imports M1, M3
node 3M4
M1 stubM3 stub
push
pushlocal local