Distributed, Time-Safe TDL Execution— Concepts, Tools and...

46
Distributed, Time-Safe TDL Execution— Concepts, Tools and Run-time Infrastructure Emilia Farcas Prof. Dr. Wolfgang Pree Dr. (ETH) Josef Templ Department of Computer Science Universität Salzburg cs.uni-salzburg.at MoDECS.cc PREEtec.com

Transcript of Distributed, Time-Safe TDL Execution— Concepts, Tools and...

Page 1: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

Distributed, Time-Safe TDL Execution—Concepts, Tools and

Run-time Infrastructure

Emilia FarcasProf. Dr. Wolfgang PreeDr. (ETH) Josef Templ

Department of Computer ScienceUniversität Salzburg

cs.uni-salzburg.atMoDECS.cc

PREEtec.com

Page 2: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL2 LASER 2005

Overview

Motivation Transparent Distribution Bus Schedule Generation Tool TDL Run-time Environment Tool Chain Development Process and Module Distribution

Page 3: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL3 LASER 2005

Motivation

MOST-Bus

CAN-Bus

Some benefits of distribution: Fault tolerance Scalability Less wiring

Page 4: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL4 LASER 2005

Introduction to Distributed TDL

Unit of distribution: TDL moduleBehavior: as if executed locallyCommunication: via broadcast (bus)Medium access control: TDMA (time-slotting)Cooperation model: Producer-Consumer (Push)

bus

M2

M3

M1

M4

node 1

node 2 node 3

Page 5: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL5 LASER 2005

The advantages oftransparent distribution

the functional and temporal behavior of asystem is the same no matter where acomponent is executed

developer’s perspective:NO difference between local and distributedexecution of components

OEM-supplier perspective:the components can be developedindependently

Page 6: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL6 LASER 2005

transparent distribution in a nutshell

computing platform, for example, MPC555+OSEK

software component(hard real-time control system)

plantA S

Page 7: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL7 LASER 2005

transparent distribution in a nutshell

M1

Page 8: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL8 LASER 2005

transparent distribution in a nutshell

M1

Page 9: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL9 LASER 2005

transparent distribution in a nutshell

M1M2

component M2 added later,if required even at run-time

exactly defined communication semantics(TDL programming model)

Page 10: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL10 LASER 2005

transparent distribution in a nutshell

deterministic timing and communication behavior independent of the computing and communication

platform=> portability through automatic code generation

and run-time environment

M1 M2

FlexRayTTCAN, EtherCAT, etc.

Page 11: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL11 LASER 2005

Example of Distributed TDL

bus

M2

M3

M1

M4

node 1

node 2 node 3

task1

M1 M2

task2

Page 12: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL12 LASER 2005

Transparent Distribution

M1

comm1

comm2

timeLET1

bus

LET2

node1

node2M2

message sent according to bus schedule (TDMA)

Page 13: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL13 LASER 2005

Optimization I

if the consumer runs slower e.g. by a factor of 2 redundant message are avoided saves bandwidth

M1

comm1

comm2

timeLET1

bus

LET2

node1

node2M2

Page 14: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL14 LASER 2005

Optimization II

if the consumer needs a variable later than the producer’s FLET

M1

comm1

timeLET1

bus

LET2

node1

node2M2

comm2

Page 15: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL15 LASER 2005

Optimization III

the release of the consumer can be delayed until the message withthe input variable is received

M1

M2

comm1

comm2

timeLET1

bus

LET2

node1

node2

Page 16: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL16 LASER 2005

Bus ScheduleGeneration Tool

Page 17: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL17 LASER 2005

What Does the Tool Do?

It generates a global bus schedule file, which contains thefollowing 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 correspondingdatagram, which has one or more items).

Page 18: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL18 LASER 2005

What Does the Tool Need as Input?

TDL modules Platform description file

module to node assignment physical bus properties (e.g., bus frequency,

protocol overhead, inter frame gaps, min/maxpayload)

The tool automatically detects: Who has to communicate with whom. Which messages are needed in a communication cycle

(bus period).

Page 19: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL19 LASER 2005

Who Has to Communicate with Whom

Result: a set of messages.

A message has: a Producer one or more Consumers size.

Producers: sensors, task output ports.

Consumers: actuators, task input ports, guardarguments.

Page 20: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL20 LASER 2005

Messages Needed in a Bus Period

Result: a set of message instances, with individual timing constraints: Release Offset Deadline

Basic Producer-Consumer: Send messages with the frequency of the Producer. Message deadline = Producer LET. BusPeriod = LCM(Producer.period)

Optimized Producer-Consumer: Send messages only when they are needed by the Consumers. Message deadline depends on the optimization (e.g.,=

consumer LET). BusPeriod = LCM(Producer.period, Consumer.period)

Page 21: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL21 LASER 2005

Message Deadline in Optimization II

M1

M2

comm1

comm2

timeLET1

bus

LET2

node1

node2

ProducerDeadline

MessageDeadline

Page 22: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL22 LASER 2005

Message Scheduling

Current approach: Scheduling in 2 steps:

Schedule first the messages. Schedule then the tasks with deadlines constraints from

messages.

Optimizations: Build bus schedulers which allow more flexibility for the task

scheduler. Try several bus schedulers and get feedback from the Time-

Safety-Check (TSC) for tasks. Schedule individual messages or merge messages sent from

the same node.

Page 23: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL23 LASER 2005

Scheduling Algorithms

Heuristic algorithm - “Latest Deadline Last” - LDL Adapted from Reversed EDF (Latest Release Time - LRT) -

treats deadlines as release times and vice versa Schedule messages as late as possible

Optimal algorithm Branch and bound search Exponential complexity in the worst case

Heuristic Algorithm

Schedule

Success Failure

Not enough SW/HW performance

There is a schedule but the algorithm fails to find it.

Page 24: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL24 LASER 2005

Latest Deadline Last - Example

m3

m1

m2

Released messages {m1, m2, m3}

time m3

m1

m2

LDL scheduling {m2, m1, m3}

time

Page 25: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL25 LASER 2005

Latest Deadline Last

Sorts the list of messages by: Key1 = message deadline Key2 = message release time Key3 = producer deadline.

Bus Scheduler is non-preemptive and just schedules themessages in the resulted order. Starts from the end of the Bus Period and goes

backwards. Merges messages if they have to be sent by the

same node, and are adjacent.

Page 26: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL26 LASER 2005

Search Scheduler - Example

m1

m2

LDL scheduling failure {m2, m1}

time m1

m2

Search scheduler {m1, m2}

time

Page 27: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL27 LASER 2005

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 28: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL28 LASER 2005

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 29: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL29 LASER 2005

We do Various Measurements as Basisfor Optimizations

Metrics relevant for efficient bus utilization: Throughput Bus utilization Average data efficiency Maximum and average sending rates Maximum and average receiving rates

Metrics relevant for flexibility in task scheduling: Minimum and average release-send intervals Minimum and average relative release-send intervals

Page 30: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL30 LASER 2005

TDL Run-time Environment

Page 31: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL31 LASER 2005

TDL Run-time Environment

E-machineTDL Scheduler

(S-machine)TDL Comm

Tasksreleases

dispatches

Ports

Drivers

calls

Environment

Platform

r/w r/w

MessageBuffers

r/w

r/w

calls

Sensors/Actuators

Page 32: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL32 LASER 2005

E-Machine Operation

Executes E-code instructions at logical time instances Implementation is platform dependent (OSEK, InTime,

RTLinux, Java) It is fast and lightweight (e.g. 8KB for OSEK E-machine).

Supports three kinds of module execution: local, push,and stub.

Page 33: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL33 LASER 2005

E-Machine

bus

M2

M3

M1

M4

node 1

node 2 node 3

M2 imports M1

M4 imports M1, M3

Page 34: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL34 LASER 2005

E-Machine

bus

M2

M3

M1 stub

M1 node 1

node 2 node 3

M2 imports M1

M4 imports M1, M3

M4

M1 stubM3 stub

push

pushlocal local

Page 35: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL35 LASER 2005

LOCAL

release driver - copies input arguments terminate driver - copies output arguments start driver - calls task impl. function stop driver - noop

E-machine timerelease driver

terminate driver

start driver

stop driver

S-machine

LET

Page 36: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL36 LASER 2005

PUSH

release driver - same as LOCAL terminate driver - same as LOCAL start driver - same as LOCAL stop driver - copy results to TDLcomm

E-machine timerelease driver

terminate driver

start driver

stop driver

S-machine

LET

Page 37: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL37 LASER 2005

STUB

terminate driver - copies from TDLcomm to output uses special E-code that contains only terminate driver

calls at appropriate time instances => stub mode

E-machine timeterminate driver

LET

Page 38: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL38 LASER 2005

Transparent Distribution

M1

comm1

comm2

timeLET1

bus

LET2

node1

node2

M2

stop driver

release driver

M1 stub

terminate driver

Page 39: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL39 LASER 2005

Tool Chain

.tdl Compiler E-machine

AST

.ecode

functionalitycode

Platformplugin

platformspecific

platformspecific

Page 40: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL40 LASER 2005

Tool Chain

.tdl Compiler E-machine

Bus Schedulerplugin

AST

.ecode

functionalitycode

Platformplugin

platformspecific

AST

platformspecific

platform busch

Page 41: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL41 LASER 2005

Development process andTDL module distribution

Page 42: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL42 LASER 2005

modeling the timing + functionality of amodule

a

Task1Impl

Task2Impl

. . .

eg,Simulink-Editor TDL-Editor

functionalitymodel, i.e.,control laws

timingmodel (TDL)

eg, SimulinkSimulation

Environment

M1

Page 43: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL43 LASER 2005

fully automated generation ofexecutable(s)

a

Task1Impl

Task2Impl

. . .

eg,Simulink-Editor TDL-Editor

functionalitymodel, i.e.,control laws

timingmodel (TDL)

C-CodeGenerator

C Compiler

TDLCompiler

Linker

M1

M1

Page 44: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL44 LASER 2005

independently developed TDLmodules

aa

requirements

functionalmodel

applicationcode

test

verification

validation

eg, TDL+Simulink

generated

requirements

functionalmodel

applicationcode

test

verification

validation

eg, TDL+Simulink

generated

requirements

functionalmodel

applicationcode

test

verification

validation

eg, TDL+Simulink

generated

M1

M2

M3

generated

generated

generated

Page 45: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL45 LASER 2005

The modules can be assigned to anyECU as long as the time-safety propertyis not violated

ECU1M3ECU2M2ECU1M1

@module

ECU1M3ECU1M2ECU1M1

@module

Page 46: Distributed, Time-Safe TDL Execution— Concepts, Tools and ...laser.inf.ethz.ch/2005/slides/pree/03a_DistributedTDL.pdf · Distributed, Time-Safe TDL Execution— Concepts, Tools

© E. Coste, W. Pree, J. Templ: Distributed TDL46 LASER 2005

Thank you for your attention!