osek-like kernel support for engine control applications under edf...

44
1 OSEK - Like Kernel Support for Engine Control Applications Under EDF Scheduling Vincenzo Apuzzo, Alessandro Biondi and Giorgio Buttazzo ReTiS Laboratory Scuola Superiore Sant’Anna, Pisa, Italy

Upload: others

Post on 22-Apr-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

1

OSEK-Like Kernel Support

for Engine Control

Applications Under EDF

Scheduling

Vincenzo Apuzzo, Alessandro Biondi and Giorgio Buttazzo

ReTiS Laboratory

Scuola Superiore Sant’Anna, Pisa, Italy

Page 2: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

2

Towards the use of EDF in real-world engine control applications

Not only periodic tasks!

Engine control applications also include adaptive variable-rate tasks

• OSEK-like RTOS support for EDF scheduling of engine control applications

• Simulation Framework

ThisWork

Benefits in terms of schedulability have been observed (in theory) under EDF scheduling

Page 3: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

3

A LOOK INTO

ENGINE CONTROL

APPLICATIONS

Page 4: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

4

Introduction

(t)

t

t

/2

3/2

2

Task activations

Engine control applications include

Periodic tasks with fixed periods: 1 - 500 ms

Angular tasks, linked to the rotation of the

crankshaft

activate task

Page 5: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

5

Introduction

Page 6: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

6

Engine-triggered Tasks

Engine-triggered tasks – single activation per revolution

𝑇 =2𝜋

𝜔

Inter-arrival time

given a fixed

speed 𝝎TDC

𝝎

𝑇

𝜔

𝜔𝑚𝑖𝑛 = 500 rpm 𝑇𝑚𝑎𝑥= 120 ms

𝜔𝑚𝑎𝑥 = 6500 rpm 𝑇𝑚𝑖𝑛 ≅ 10 ms

Page 7: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

7

Engine-triggered Tasks

Engine-triggered tasks – single activation per revolution

𝑇 =2𝜋

𝜔

Inter-arrival time

given a fixed

speed 𝝎TDC

𝝎

𝑇

𝜔

𝜔𝑚𝑖𝑛 = 500 rpm 𝑇𝑚𝑎𝑥= 120 ms

𝜔𝑚𝑎𝑥 = 6500 rpm 𝑇𝑚𝑖𝑛 ≅ 10 ms

Page 8: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

8

Engine-triggered Tasks

engine speed

100%

Suppose a fixed WCET for the task

CPU

load

Overload

TASK

worst-case execution time (WCET)

time

Page 9: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

9

Engine-triggered Tasks

engine speed

100%

Suppose a fixed WCET for the task

CPU

load

Overload

worst-case execution time (WCET)

TASK

time

Page 10: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

10

Engine-triggered Tasks

1 2

C(1)

C(2)

C(3)

1

2

3

To prevent overload at high rates, different control implementations are used

speedtime

time

Page 11: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

11

Engine-triggered Tasks

1 2

C(1)

C(2)

C(3)

1

2

3

To prevent overload at high rates, different control implementations are used

speedtime

time

Page 12: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

12

Adaptive Variable-Rate Tasks

The AVR task implements a number of execution

modes

Page 13: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

13

Scheduling Infrastructure

OSEK/AUTOSARRTOS

CPU

Set ofengine-triggered

tasks

i* (Ci(), Ti(), Di())

Fixed-Priority

Scheduling

ECU

Page 14: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

14

IS FIXED-PRIORITY

SCHEDULING THE BEST

CHOICE FOR ENGINE

CONTROL APPLICATIONS?

Page 15: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

15

FP Scheduling of AVR Tasks

50 100 1500

20 40 60 80 100 120 140 160

T [~10, 120] ms

= 6500 = 500

AVR

20ms

50ms

Since the inter-arrival time vary a lot with , any fixed priority

assignment may not be optimal for some speed!

Page 16: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

16

EDF Scheduling of AVR Tasks

Job priorities are adapted at run time as a function of the engine speed at their release time

Variable relative deadline for each job

This is still EDF! (job-level fixed-priority)

Deadline

Assignment Law

EDF

SchedulerDeadline

Assignment Law

Page 17: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

17

Deadline Assignment

Engine-triggered tasks – Dynamic condition

𝑡𝑪(𝝎)

TDC

𝝎

𝜶𝜶 < 0

2𝜋

0𝑡

𝜃(𝑡)

𝑇 =2𝜋

𝜔

𝜶 ≥ 0

Page 18: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

18

Deadline Assignment

𝑡𝑪(𝝎)

TDC

𝝎

𝜶𝜶 < 0

2𝜋

0𝑡

𝜃(𝑡)

𝜔2 + 2𝜋𝛼+ − 𝜔

𝛼+

𝜶 ≥ 0

Engine-triggered tasks – Dynamic condition

The deadline is assigned

considering the earliest possible

next activation given by the

maximum acceleration

Page 19: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

19

Benefits of EDF

[1] A. Biondi, G. Buttazzo, S. Simoncelli, “Feasbility Analysis of Engine Control Tasks under EDF Scheduling”, ECRTS ‘15

Experimentalresults from [1]

[2] Z. Guo, S. Baruah, “Uniprocessor EDF Scheduling of AVR task systems”, ICCPS ‘15

Speed-up factor analysisGuo and Baruah [2]

~1.1

Depends on engine speed and maximum acceleration

EDF is “practically” optimal

Page 20: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

20

LET’S TRY TO USE EDF

FOR REAL-WORLD

ENGINE CONTROL

APPLICATIONS…

Page 21: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

21

Our Goal

Motivated by the benefits of EDF observed in theory

Design and implementation of a RTOS support for

engine control applications under EDF

scheduling

Being OSEK/AUTOSAR the de-facto standard in the automotive industry

Minimal changes to the standard

OSEK API

Integration with the OSEK standard configuration language (OIL)

Page 22: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

22

Our Goal

Existing

engine-control

application

OSEK RTOS

Page 23: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

23

Our Goal

Existing

engine-control

application

OSEK RTOSThis Work

less

changes as possible

Page 24: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

24

Erika Enterprise

ERIKA Enterprise is an OSEK/VDX certified RTOS

Offers a suitable open-source license allowing the

static linking of closed source code

Typical footprint around 2-4KB Flash

Used by several automotive and white goods

companies

Page 25: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

25

EDF

EDF

scheduling

+

(M)SRP

Erika Enterprise

OSEKcertified

FP HR FRSH

• BCC1

• BCC2

• ECC1• ECC2

minimal

impl. of

fixed-priority

scheduling

EDF

EDF

scheduling

+

(M)SRP

two-level

hierarchical

scheduling

(M)BROE

EDF-based

per-task

resource

reservation

OSEK-like API

Page 26: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

26

Impact

RTOS should be aware of the parameters of AVR

tasks and the engine

Needed support for variable relative-deadline as

a function of the engine speed

Needed extensions at the OSEK Configuration

Language (OIL)

Needed new support for deadline buffering to

manage overloads

Different requirements for stack sharing

Page 27: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

27

Activation of an AVR task

Interrupt:CrankshaftAngle_Zero

TDC

ISR(CrankshaftAngle_Zero) {

ActivateTask(AVRtask);}

ISR(CrankshaftAngle_Zero) {

= read_rotation_speed();

ActivateTask(AVRtask, );}

Not part of the OSEK standard API

Page 28: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

28

Deadline Computation

The deadline of each job depends on the engine speed 𝜔 (at the job release time)

engine speed 𝝎

𝐷(𝜔)

Must be computed every

time a job of an AVR task is

activated

Page 29: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

29

Deadline Computation

run-time overhead

errorfootprint

Page 30: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

30

Deadline Computation

run-time overhead

errorfootprint

~450 cycles

5.4 𝝁s on SMT32F4

@ 168Mhz

Relying on

standard C libmath

Page 31: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

31

Deadline Computation

run-time overhead

errorfootprint

~188 cycles

2.2 𝝁s on SMT32F4

@ 168Mhz

error < 0.04%

fastSQRTalgorithm

Page 32: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

32

Deadline Computation

run-time overhead

errorfootprint

~25 cycles

0.3 𝝁s on SMT32F4

@ 168Mhz

error 0.2/0.05%

look-up

table

64/128

entries@ 32 bit

Page 33: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

33

Experimental ResultsRun-time overhead for the ActivateTaskcontext switch + deadline computation + ready queue

management + …

Fixed-priority

420 cycles2.2 𝜇𝑠

STM32F4 @ 168Mhz – GNU ARM Compiler

Page 34: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

34

Experimental ResultsFootprint – 2 periodic tasks + #n AVR tasks

STM32F4 – GNU ARM Compiler with -Os

Page 35: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

35

A SIMULATION

FRAMEWORK

Page 36: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

36

Simulation Framework

Lauterbach is the world’s larger producer of hardware assisted debug tools for microprocessors

TRACE32® PowerView IDE

Lauterbach makes available a version of their IDE

based on an instruction-set simulator trace & debug without any hardware!

Page 37: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

37

Simulation Framework

Lauterbach

TRACE32

PSMcustom simulated peripheral device

The TRACE32 simulator offers a standard interface

named Peripheral Simulation Model (PSM)

The PSM allows developing custom simulated

peripheral devices

react to events (e.g., memory read);

access to the simulated CPU registers;

Page 38: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

38

Simulation Framework

Lauterbach TRACE32

SimulatedCPU

TRACE32 PowerViewIDE

..

.

..

.

SimulatedMemory

void myMemoryReadHandler(){

<…>PSM_TRACE_WRITE_MEM(…);<…>PSM_TRACE_WRITE_REG(…);<…>

}

on write

void mySimulatedInterrupt() {

<…>PSM_TRACE32_RISE_INT(3);<…>

}

rise interrupt #3

DLL

DLL

Page 39: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

39

Simulation Framework

SimulatedSTM32F4

Free Running Timer

Simulator

Crankshaft Simulator

Random Speed

Pattern

File

Lauterbach TRACE32

TRACE32IDE

ERIKAApplication

Binary

𝑤(𝑡)

𝑡

𝜔, 𝛼

Page 40: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

40

DEMO

Page 41: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

41

Conclusions

We presented a new RTOS support for EDFscheduling of engine control applications

The implementation has been conceived to

require minimal changes to existing applications

(OSEK-like API, integration with OIL)

Run-time overhead and footprint are not

problems (+1.5 𝝁𝒔 and +500 bytes over an

implementation of fixed-priority scheduling)

We also present a powerful simulation framework

for studying the execution of real code under (but not only limited to) the proposed RTOS

Page 42: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

42

Future Work

We are going to test this implementation with a

real engine control application controlling a real engine

Integration of the TRACE32 simulator with MATLAB Simulink and/or other physical simulation tools

http://erika.tuxfamily.org/

soon available as open-source

http://erika.tuxfamily.org/

Page 43: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

43

Acknowledgements

Thanks to Paolo Gai from Evidence S.R.L. and

Maurizio Menegotto from Lauterbach Italia for their support which helped to improve this work.

Page 44: OSEK-Like Kernel Support for Engine Control Applications Under EDF Schedulingretis.sssup.it/~a.biondi/slides/RTAS16_slides.pdf · 2016-05-06 · 2 Towards the use of EDF in real-world

44

Thank you!Alessandro Biondi

[email protected]