Undoing the Task: Moving Timing Analysis back to Functional Models

12
Undoing the Task: Moving Timing Analysis back to Functional Models Marco Di Natale, Haibo Zeng Scuola Superiore S. Anna – Pisa, Italy McGill University – Montreal, Canada d International Real-Time Scheduling Open Problems Semin

description

3rd International Real-Time Scheduling Open Problems Seminar. Undoing the Task: Moving Timing Analysis back to Functional Models. Marco Di Natale, Haibo Zeng Scuola Superiore S. Anna – Pisa, Italy McGill University – Montreal, Canada. Model-based Design. - PowerPoint PPT Presentation

Transcript of Undoing the Task: Moving Timing Analysis back to Functional Models

Page 1: Undoing the Task:  Moving Timing Analysis back to Functional Models

Undoing the Task: Moving Timing Analysis back to Functional Models

Marco Di Natale, Haibo ZengScuola Superiore S. Anna – Pisa, ItalyMcGill University – Montreal, Canada

3rd International Real-Time Scheduling Open Problems Seminar

Page 2: Undoing the Task:  Moving Timing Analysis back to Functional Models

Model-based Design

• Popular in many application domains of real-time systems– Automotive– Avionics

• To deal with complexity– Model everything for design (engineering)

and analysis (science)– It is necessary to select a modeling language

in the most natural and easy way

• The four tenets on the right are fundamental to model-based design

by Ali Behboodian, DSP Magazine

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

• No program by hand• Starting point is functional model• Automatic generation of

implementation is key• Synthesis of tasks, priorities,

allocation, communication mechanisms …

Page 3: Undoing the Task:  Moving Timing Analysis back to Functional Models

Undoing the Task

• Real-time research has been looking at ways to look inside the task and find smaller granularity entities and/or models for conditional execution.

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

• Examples:–Task graphs (see left)– Identify a task

segment to be managed without preemption (see [1])

– Identify a task segment to be executed at a different priority level (see [2])

–…

[1] M. Bertogna, G. Buttazzo, and G. Yao, “Improving feasibility of fixed priority tasks using non-preemptive regions”, RTSS 2011[2] R. Davis and A. Wellings, “Dual Priority Scheduling” RTSS, 1995.

Page 4: Undoing the Task:  Moving Timing Analysis back to Functional Models

Synchronous Models: Simulink/Stateflow• Synchronous FSMs are used in the most popular model-based

design tools – SCADE– Simulink/Stateflow

The system is a network of “dataflow” blocks and

Stateflow (EFSM) blocks

e1=2mse2=5ms

S1

S2

S3

e1/{action1();o1}

0.25

0.1e1/{action3();o1}

e2/{action4();o2}0.15

0.3

e2/{action2();o2}

2

1

i1

i2

in

o1

o2

om

Where are the tasks? Timing constraints?

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

Page 5: Undoing the Task:  Moving Timing Analysis back to Functional Models

Problem Statement: Input

• System is a network of blocks bj of two types – Regular (Dataflow):

• period Tj (an integer multiple of a system-wide base periodTb) • inputs ij,p. • at each kTj output and state are updated, with a WCET gj.

– State machine (Stateflow): • can have multiple activation events ej,p. • at any multiple of the event periods kTj,p, different transitions may be taken. • each update function has a WCET labeled as gj,q

• Order of execution– For two communicating blocks– If bj has a feedthrough semantics, then bi → bj – This partial order of execution of functions can be enforced by

static code scheduling inside the task or by the scheduler– This precedence constraint can be avoided by adding a delay

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

bi bj

Page 6: Undoing the Task:  Moving Timing Analysis back to Functional Models

Problem Statement: Input

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

zero logical execution time zero logical communication time

A B

4

4 2 fc(4,2)D

tv=0: A,B,D,C tv=1:A,B

C

42

A B3 1

tv=2: A,B,D

A B2 0

D

T=1

T=1 T=2

T=4B

A

C

D

3 2

1 02

C

fc(4,1)?4 1

A B4 2

tr=1

A B3 1

A B2 0

D

tr=0 tr=2C

Behavior in Implementation

Behavior in Simulation

Order in simulation: A->B->D->C

The requirement of preserving the behavior in functional model can impose additional constraints

• Either tighter deadline for block C• Or other mechanisms (but possibly

with memory overhead)

Page 7: Undoing the Task:  Moving Timing Analysis back to Functional Models

Problem Statement• Unlike traditional manual programming, in MBD

– the task (or threads) model becomes an intermediate artifact – the timing analysis becomes part of a synthesis problem (to

facilitate automatic code generation)

• Analysis problem– deadline may depends on the function-to-task mapping– additional requirements from the correct implementation of

function models• Synthesis problem:

– mapping functions into tasks– assigning the execution order of functions inside tasks, – assigning the task parameters (priority, deadline, offset) – assigning scheduling attributes to functions (including

preemptability and preemption threshold) – designing communication

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

Page 8: Undoing the Task:  Moving Timing Analysis back to Functional Models

Example Open Problem• Given

– functional model (composed of multiple communicating state machine blocks and dataflow blocks)

– a multicore platform as the implementation architecture • Find

– mapping of state machine actions and block reactions onto tasks– placement of tasks onto the cores – assignment of task activation offsets and priorities

• Such that – functional model semantics are preserved – each block finish in time for the follower blocks

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

Page 9: Undoing the Task:  Moving Timing Analysis back to Functional Models

Example Open Problem II• Given

– functional model (composed of multiple communicating state machine blocks and dataflow blocks)

– a multicore platform as the implementation architecture • Find

– mapping of state machine actions and block reactions onto tasks– placement of tasks onto the cores – assignment of task activation offsets and priorities– assignment of preemption thresholds to actions inside the tasks

• Such that – functional model semantics are preserved – each block finish in time for the follower blocks– memory usage is minimized

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

Page 10: Undoing the Task:  Moving Timing Analysis back to Functional Models

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

Thank you!Initial discussion on the example problems[3] M. Di Natale and H. Zeng, “Task implementation of synchronous finite state machines,” in Proc. the Conference on Design, Automation, and Test in Europe, 2012.[4] H. Zeng and M. Di Natale, “Schedulability Analysis of Periodic Tasks Implementing Synchronous Finite State Machines,” in Proc. 23rd Euromicro Conference on Real-Time Systems, 2012.

Page 11: Undoing the Task:  Moving Timing Analysis back to Functional Models

Baseline (Single-Task) Implementation

Undoing the Task: Moving Timing Analysis back to Functional ModelsM. Di Natale, H. Zeng

S1

S2

S3

e1/{action1();o1}0.25

0.1e1/{action3();o1}

e2/{action4();o2}0.15

0.3

e2/{action2();o2}

2

1

e1=2ms

e2=5ms

i1i2

in

o1

o2

om

The generated code runs in the context of a 1 ms task (gcd), but reactions do not occur every 1ms

A single task forces the execution of all the actions at the same priority level

Simple periodic model: Worst-case exec time of a reaction to any event – deadline at 1ms – quite pessimistic

Page 12: Undoing the Task:  Moving Timing Analysis back to Functional Models

Partitioned (Multi-task) Implementation

One task for each event rate.

• Priority of transitions is handled by task priorities

• Single reaction execution by an “inhibit signal”

• Atomicity (state consistency) by deadlines. Undoing the Task: Moving Timing Analysis back to Functional Models

M. Di Natale, H. Zeng

e1=2ms

e2=5ms

S1

S2

S3

e1/{action1();o1}0.25

0.1e1/{action3();o1}

e2/{action4();o2}0.15

0.3

e2/{action2();o2}2

1

e1=2ms

e2=5ms

i1

i2

in

o1

o2

om

Applicable if the priority of a transition is determined by the corresponding event