Multicore for safety-critical embedded systems: challenges and - - PowerPoint PPT Presentation

multicore for safety critical embedded systems challenges
SMART_READER_LITE
LIVE PREVIEW

Multicore for safety-critical embedded systems: challenges and - - PowerPoint PPT Presentation

Multicore for safety-critical embedded systems: challenges and opportunities Giuseppe Lipari CRIStAL Universit de Lille Centre de Recherche en Informatique, Signal et Automatique de Lille June 23, 2016 Giuseppe Lipari (CRIStAL)


slide-1
SLIDE 1

Multicore for safety-critical embedded systems: challenges and opportunities

Giuseppe Lipari

CRIStAL – Université de Lille

Centre de Recherche en Informatique, Signal et Automatique de Lille

June 23, 2016

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 1 / 46

slide-2
SLIDE 2

Outline

1

Introduction to RT Systemes

2

Resource Reservations

3

Hierarchical scheduling

4

Multiprocessor sharing of resources

5

Conclusions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 2 / 46

slide-3
SLIDE 3

Outline

1

Introduction to RT Systemes

2

Resource Reservations

3

Hierarchical scheduling

4

Multiprocessor sharing of resources

5

Conclusions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 3 / 46

slide-4
SLIDE 4

Real-Time Systems

Most real-time systems are concurrent

need to handle many events with different temporal characteristics

Periodic events

In control systems, periodic sampling, computation of the control algorithm, actuation Different events may have different periods

Aperiodic events

May be triggered by the external environment Examples: a sensor triggers an interrupt, a packet arrives from the network

Different events are handled by different tasks that run concurrently Constraints: each task instance must complete before a certain instant (deadline) Scheduling problem: how to interleave tasks executions so that each task instance meets its deadline

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 4 / 46

slide-5
SLIDE 5

Task model

A periodic task τi = (Ci, Di, Ti) consists of a (infinite) sequence of jobs Ji,k = {ai,k, ci,k, di,k} k = 0, 1, 2, . . ., with: ai,0 = 0 ∀k > 0 ai,k = ai,k−1 + Ti ∀k ≥ 0 di,k = ai,k + Di Ci = max{k ≥ 0|ci,k} Pseudo-code for a periodic task:

void * PeriodicTask(void *arg) { <initialization>; <start periodic timer, period = T>; while (cond) { <read sensors>; <update outputs>; <update state variables>; <wait next activation>; } }

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 5 / 46

slide-6
SLIDE 6

Example of schedule

Every task τi is assigned a fixed priority pi; the active task with the highest priority is executed on the processor

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 6 / 46

slide-7
SLIDE 7

Scheduling analysis

Theorem (Liu and Layland, 1973)

Consider n periodic (or sporadic) tasks with relative deadline equal to periods, whose priorities are assigned in Rate Monotonic order. Then, U =

N

  • i=1

Ci Ti ≤ Ulub = n(21/n − 1) Ulub is a decreasing function of n; For large n: Ulub → 0.69

n Ulub n Ulub 2 0.828 7 0.728 3 0.779 8 0.724 4 0.756 9 0.720 5 0.743 10 0.717 6 0.734 11 . . .

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 7 / 46

slide-8
SLIDE 8

Dynamic priority

The most important (and analysed) dynamic priority algorithm is Earliest Deadline First (EDF)

The priority of a job (instance) is inversely proportional to its absolute deadline;

Example with U = 23

24

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 8 / 46

slide-9
SLIDE 9

Scheduling analysis

Theorem (Optimality, Dertouzos ’73)

If a set of jobs J is schedulable by an algorithm A, then it is schedulable by EDF.

Theorem (Liu & Layland ’71)

Given a task set of periodic or sporadic tasks, with relative deadlines equal to periods, the task set is schedulable by EDF if and only if U =

N

  • i=1

Ci Ti ≤ 1

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 9 / 46

slide-10
SLIDE 10

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-11
SLIDE 11

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-12
SLIDE 12

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-13
SLIDE 13

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-14
SLIDE 14

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-15
SLIDE 15

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-16
SLIDE 16

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-17
SLIDE 17

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-18
SLIDE 18

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-19
SLIDE 19

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-20
SLIDE 20

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-21
SLIDE 21

Domino effect

In case of overhead (U > 1), in EDF we have the domino effect: it means that all tasks miss their deadlines. An example of domino effect is the following:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 10 / 46

slide-22
SLIDE 22

Domino effect and fixed priority

FP is more predictable: only lower priority tasks miss their deadlines! In the previous example, if we use FP:

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3 τ4

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 11 / 46

slide-23
SLIDE 23

Execution time and schedulability

The analysis depends on the worst-case execution time Ci of each task As we have seen in the previous slides, a wrong estimate may lead to a deadline miss How to compute the WCET of tasks ?

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 12 / 46

slide-24
SLIDE 24

WCET estimation

Execution time of a task varies with

The input The state of the system The processor architecture Interference from other threads

How to compute

By timing analysis (by using appropriate tools) we can obtain a (safe) upper bound, but sometimes too pessimistic By testing we can only obtain an unsafe lower bound

Problem

A wrong estimate may lead to a wrong analysis

Courtesy of Peter Puschner Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 13 / 46

slide-25
SLIDE 25

Execution time variability: example

Tasks can have variable execution times between different jobs

while (cond) { if (a > 10) { // long computation } else { // short computation } a = getInput(); }

We have two sources of variability:

the value of variable a influences which computation is performed (long

  • r short);

the value of cond influences the number of times the loop body is executed.

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 14 / 46

slide-26
SLIDE 26

Impact of processor architecture

With recent processor architectures, the difference between BCET and WCET became larger and larger

Figure : Courtesy of AbsInt

Impact of cache and shared resources Situation even worse on multi-core systems

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 15 / 46

slide-27
SLIDE 27

Impact of interference

WCET Analysis

it is difficult to estimate a tight upper bound of WCET when the task executes in isolation

Preemption:

preempting tasks could evict cache lines next time the task executes the data is not in the cache anymore

while (i < 10) { data = getInput(); // ... // possible preemption function(data); // is data in cache ? }

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 16 / 46

slide-28
SLIDE 28

Impact of interference

WCET Analysis

it is difficult to estimate a tight upper bound of WCET when the task executes in isolation

Preemption:

preempting tasks could evict cache lines next time the task executes the data is not in the cache anymore

while (i < 10) { data = getInput(); // ... // possible preemption function(data); // is data in cache ? }

Some (partial) solution is available

avoid (or limit) preemption → additional blocking time for higher priority tasks lock cache to some task try to minimise cache conflicts by properly placing tasks in memory

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 16 / 46

slide-29
SLIDE 29

Outline

1

Introduction to RT Systemes

2

Resource Reservations

3

Hierarchical scheduling

4

Multiprocessor sharing of resources

5

Conclusions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 17 / 46

slide-30
SLIDE 30

Resource Reservation

Assign each task to a server

a watchdog that monitors execution and enforces an execution budget

A server S = (Q, P)

Q: maximum execution budget P: minimim serving period U = Q/P: reserved bandwidth

Different algorithms in the literature

FP: Polling Server, Deferrable Server, Sporadic Server EDF: Dynamic Sporadic Server, Constant Bandwidth Server

Implementations

Sporadic Server is a POSIX standard (optional) CBS implemented in Linux (since 3.14), (available as SCHED_DEADLINE)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 18 / 46

slide-31
SLIDE 31

Example

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) U = 0, 983 < 1 ⇒ schedulable

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 19 / 46

slide-32
SLIDE 32

Misbehaving task

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) What happens if τ1 executes for 2 for the first 3 instances ?

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 miss their deadlines They could be critical tasks, we need to protect them

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 20 / 46

slide-33
SLIDE 33

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-34
SLIDE 34

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-35
SLIDE 35

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-36
SLIDE 36

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-37
SLIDE 37

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-38
SLIDE 38

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-39
SLIDE 39

Example with CBS

Consider τ1 = (1, 4), τ2 = (2, 5), τ3 = (2, 6) Assign τ1 a server S1 = (1, 4)

2 4 6 8 10 12 14 16 18 20

τ1 τ2 τ3 τ2 and τ3 are not influenced

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 21 / 46

slide-40
SLIDE 40

CBS algorithm properties

CBS takes care of other possible cases

jobs arriving earlier (or later) than expected jobs executing more or less than expected server period can be different from task period

Properties:

Temporal isolation: no server misses its "scheduling deadlines"

all server jobs execute the maximum budget before their scheduling deadlines

Hard Schedulablity: if a task is assigned Qi ≥ Ci and Pi ≤ Ti, then it will never miss its deadlines

Thanks to this properties we can easily mix hard and soft real-time tasks simply by assigning the correct parameters (budget/periods)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 22 / 46

slide-41
SLIDE 41

CBS algorithm

Two dynamic variables

q: remaining budget (init to Q, decreases while executing) d: scheduling deadline

Idle Idle Active Ahead

q = Q , d = t + P if q < (d − t)Q/P i f q ≥ ( d − t ) Q / P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 23 / 46

slide-42
SLIDE 42

CBS algorithm

Two dynamic variables

q: remaining budget (init to Q, decreases while executing) d: scheduling deadline

Idle Active Active Ahead

q = Q , d = t + P q = Q , d = t + P if q < (d − t)Q/P if q ≥ (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 23 / 46

slide-43
SLIDE 43

CBS algorithm

Two dynamic variables

q: remaining budget (init to Q, decreases while executing) d: scheduling deadline

Idle Active Active Ahead

q = Q , d = t + P if q < (d − t)Q/P if q ≥ (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 4: q ← 2

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 23 / 46

slide-44
SLIDE 44

CBS algorithm

Two dynamic variables

q: remaining budget (init to Q, decreases while executing) d: scheduling deadline

Idle Active Ahead Ahead

q = Q, d = t + P if q < (d − t)Q/P if q < (d − t)Q/P i f q ≥ ( d − t ) Q / P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 4: q ← 2 t = 7: q ← 1

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 23 / 46

slide-45
SLIDE 45

CBS algorithm

Two dynamic variables

q: remaining budget (init to Q, decreases while executing) d: scheduling deadline

Idle Idle Active Ahead

q = Q , d = t + P if q < (d − t)Q/P i f q ≥ ( d − t ) Q / P when q = (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 4: q ← 2 t = 7: q ← 1 t = 9: zero lag time

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 23 / 46

slide-46
SLIDE 46

CBS algorithm: early arrival

Idle Idle Active Ahead

q = Q , d = t + P if q < (d − t)Q/P i f q ≥ ( d − t ) Q / P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 24 / 46

slide-47
SLIDE 47

CBS algorithm: early arrival

Idle Active Active Ahead

q = Q , d = t + P q = Q , d = t + P if q < (d − t)Q/P if q ≥ (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 24 / 46

slide-48
SLIDE 48

CBS algorithm: early arrival

Idle Active Active Ahead

q = Q , d = t + P if q < (d − t)Q/P if q ≥ (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 2: q ← 2

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 24 / 46

slide-49
SLIDE 49

CBS algorithm: early arrival

Idle Active Ahead Ahead

q = Q, d = t + P if q < (d − t)Q/P if q < (d − t)Q/P i f q ≥ ( d − t ) Q / P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 2: q ← 2 t = 5: q ← 1

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 24 / 46

slide-50
SLIDE 50

CBS algorithm: early arrival

Idle Active Active Ahead

q = Q , d = t + P if q < (d − t)Q/P if q ≥ (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 2: q ← 2 t = 5: q ← 1 t = 8 < 9: reuse the same q = 1 and d = 12

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 24 / 46

slide-51
SLIDE 51

CBS algorithm: early arrival

Idle Active Active Ahead

q = Q , d = t + P if q < (d − t)Q/P if q ≥ (d − t)Q/P when q = (d − t)Q/P

Q = 4, P = 12

2 4 6 8 10 12 14 16

τ1 t = 0: q ← 4, d ← 12 t = 2: q ← 2 t = 5: q ← 1 t = 8 < 9: reuse the same q = 1 and d = 12 t = 9: q = 0, so q ← 4 and d ← 24

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 24 / 46

slide-52
SLIDE 52

Analysis

Setting the budget

the Hard Schedulability Property tells us that, to meet all deadlines, Qi ≥ Ci and Pi ≤ Ti If we allow some deadline to be missed, we can set the budget between the average value and the worst case value of the execution time We need some sort of probabilistic characterization of the execution time

Probability of deadline miss

For a periodic task, given the stochastic process of the execution time, the probability of missing a deadline can be computed under different conditions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 25 / 46

slide-53
SLIDE 53

Probability of finishing time

When the budget is exhausted, the CBS will postpone the deadline by Pi

If the exceeding job is allowed to continue its execution, it will consume budget of future instances Future instance may also miss their deadlines

Markov chain model [Abeni and Buttazzo, 1999]

if the execution time is a IID stochastic variable, we can build a Markov Chain to compute the probability of finishing within Pi, 2Pi, . . . , kPi, . . .

Refinement [Palopoli, Fontanelli, Abeni, Villalba Frias, 2015]

Efficient numerical methods Closed form solution

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 26 / 46

slide-54
SLIDE 54

Stopping and skipping

If the budget is exhausted we can

1

Continue executing all jobs

2

Kill the executing job

3

Skip the next job

Solution 2. is more difficult to implement

must leave data structures in a consistent state must unlock semaphores before exiting may need to roll-back some operation (time consuming)

Solution 3. is not always desirable

the data is produced late and may not be useful

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 27 / 46

slide-55
SLIDE 55

Skipping next job

Here is a periodic POSIX thread in Linux, implementing solution 3.

void *thread_code(void *arg) { struct per_data *ps = (struct per_data *) arg; struct timespec next, now; clock_gettime(CLOCK_REALTIME, &next); while (1) { // Wait until next period timespec_add_us(&next, ps->period_us); clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &next, NULL); // Job execution // Check deadline miss clock_gettime(CLOCK_REALTIME, &now); while (timespec_cmp(&now, &next) > 0) { // Skip jobs timespec_add_us(&next, ps->dline_us); } } return NULL; }

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 28 / 46

slide-56
SLIDE 56

Outline

1

Introduction to RT Systemes

2

Resource Reservations

3

Hierarchical scheduling

4

Multiprocessor sharing of resources

5

Conclusions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 29 / 46

slide-57
SLIDE 57

Hierarchical systems

Similar techniques are used for timing partition of applications (group

  • f tasks)

T3 T4 T5 T7 T6 Global Scheduler Server S1 Server S2 Server S3 Local Scheduler

RM

Local Scheduler

POSIX

T2 T1 Local Scheduler

EDF

Application A2 Application A3 Application A1

Used mainly in IMA (Integrated Modular Avionics – ARINC 653)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 30 / 46

slide-58
SLIDE 58

Hierarchical scheduling

Two levels of scheduling

A global scheduler selects the components to execute, regardless of their internal structure When a component is selected by the global scheduler, a local scheduler decides which of the tasks is executing

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 31 / 46

slide-59
SLIDE 59

Hierarchical scheduling

Two levels of scheduling

A global scheduler selects the components to execute, regardless of their internal structure When a component is selected by the global scheduler, a local scheduler decides which of the tasks is executing

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 31 / 46

slide-60
SLIDE 60

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-61
SLIDE 61

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-62
SLIDE 62

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-63
SLIDE 63

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-64
SLIDE 64

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-65
SLIDE 65

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-66
SLIDE 66

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-67
SLIDE 67

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-68
SLIDE 68

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-69
SLIDE 69

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-70
SLIDE 70

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-71
SLIDE 71

Hierarchical scheduling - example

2 4 6 8 10 12 14 16 18 20 22 24 26

A(2,4) B(3,6) τ A

1 (2, 8)

τ A

2 (2, 12)

τ B

1 (2, 9)

τ B

2 (3, 16) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 32 / 46

slide-72
SLIDE 72

Outline

1

Introduction to RT Systemes

2

Resource Reservations

3

Hierarchical scheduling

4

Multiprocessor sharing of resources

5

Conclusions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 33 / 46

slide-73
SLIDE 73

Shared data

Until now, we have considered only independent tasks

a task never blocks or suspends it can only be suspended when it finishes its istance (job)

However, in reality, many tasks exchange data through shared memory

Example

Consider as an example three periodic tasks that exchange data Conflicts on concurrent access could make the data structures inconsistent.

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 34 / 46

slide-74
SLIDE 74

Shared resources and critical sections

The shared data structure is called resource; A piece of code accessing the data structure is called critical section; Two or more critical sections on the same resource must be executed in mutual exclusion Therefore, each data structure should be protected by a mutual exclusion mechanism; here we will study what happens when resources are protected by mutual exclusion semaphores.

The resource and the corresponding mutex semaphore will be denoted by symbol Sj

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 35 / 46

slide-75
SLIDE 75

Priority inversion

A blocking condition happens when a high priority tasks wants to access a resource that is held by a lower priority task. Consider the following example, where p1 > p2.

2 4 6 8 10 12 14 16 18 20 22 24 τ1 τ2 L(S) S L(S) S U(S) S U(S)

From time 4 to 7, task τ1 is blocked by a lower priority task τ2; this is a priority inversion. Priority inversion is not avoidable; in fact, τ1 must wait for τ2 to leave the critical section. However, in some cases, the priority inversion could be too large.

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 36 / 46

slide-76
SLIDE 76

The middle priority task

Consider the following example, with p1 > p2 > p3

2 4 6 8 10 12 14 16 18 20 22 24

τ1 τ2 τ3

L(S) S L(S) S S U(S) S U(S)

The middle priority task delays the high priority task too much! Well-known problem since the ’90s (Mars Pathfinder problem)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 37 / 46

slide-77
SLIDE 77

Priority Inheritance Protocol

First solution:

While the low priority task blocks an higher priority task, it inherits the priority of the higher priority task;

2 4 6 8 10 12 14 16 18 20 22 24 τ1 τ2 τ3 L(S) S L(S) S S U(S) S U(S) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 38 / 46

slide-78
SLIDE 78

Resource reservation and semaphores

Two problems arise when using CBS with priority inheritance

What to do if the budget is exhausted within a critical section? What happens to the budget of a blocked task?

Blocking inside a critical section

2 4 6 8 10 12 14 16 18 20

τ1 τ2

L(S)

S

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 39 / 46

slide-79
SLIDE 79

Resource reservation and semaphores

Two problems arise when using CBS with priority inheritance

What to do if the budget is exhausted within a critical section? What happens to the budget of a blocked task?

Blocking inside a critical section

2 4 6 8 10 12 14 16 18 20

τ1 τ2

L(S)

S

q = 0 Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 39 / 46

slide-80
SLIDE 80

Resource reservation and semaphores

Two problems arise when using CBS with priority inheritance

What to do if the budget is exhausted within a critical section? What happens to the budget of a blocked task?

Blocking inside a critical section

2 4 6 8 10 12 14 16 18 20

τ1 τ2

L(S)

S

L(S) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 39 / 46

slide-81
SLIDE 81

Resource reservation and semaphores

Two problems arise when using CBS with priority inheritance

What to do if the budget is exhausted within a critical section? What happens to the budget of a blocked task?

Blocking inside a critical section

2 4 6 8 10 12 14 16 18 20

τ1 τ2

L(S)

S

L(S) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 39 / 46

slide-82
SLIDE 82

Resource reservation and semaphores

Two problems arise when using CBS with priority inheritance

What to do if the budget is exhausted within a critical section? What happens to the budget of a blocked task?

Blocking inside a critical section

2 4 6 8 10 12 14 16 18 20

τ1 τ2

L(S)

S

L(S)

S

U(S)

S

U(S) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 39 / 46

slide-83
SLIDE 83

Solutions

1 Check budget

before entering the critical section, check if there is enough budget to complete Needs to know the length of the critical sections to work Used by Algorithm BROE [Bertogna et Baruah]

2 Overrun budget

if the budget is exhausted while in a critical section, the job is allowed to continue need to know the length of the critical sections for the analysis and admission control Used by Algorithm SIRAP [Benham et al.]

3 Inherit budget/deadline

When a task blocks another task, it inherits its budget/deadline pair needs to know the length of the critical sections for the analysis (but not for admission control) Used by Algorithm BWI [Lipari et al.]

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 40 / 46

slide-84
SLIDE 84

Bandwidth Inheritance

In the previous case:

2 4 6 8 10 12 14 16 τ1 τ2 L(S) S

Task τ2 inherits the deadline and the budget (so the server) of task τ1 Therefore, it consumes the budget of the other server (rather than its

  • wn)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 41 / 46

slide-85
SLIDE 85

Bandwidth Inheritance

In the previous case:

2 4 6 8 10 12 14 16 τ1 τ2 L(S) S q = 0

Task τ2 inherits the deadline and the budget (so the server) of task τ1 Therefore, it consumes the budget of the other server (rather than its

  • wn)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 41 / 46

slide-86
SLIDE 86

Bandwidth Inheritance

In the previous case:

2 4 6 8 10 12 14 16 τ1 τ2 L(S) S L(S)

Task τ2 inherits the deadline and the budget (so the server) of task τ1 Therefore, it consumes the budget of the other server (rather than its

  • wn)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 41 / 46

slide-87
SLIDE 87

Bandwidth Inheritance

In the previous case:

2 4 6 8 10 12 14 16 τ1 τ2 L(S) S L(S) inheritance

Task τ2 inherits the deadline and the budget (so the server) of task τ1 Therefore, it consumes the budget of the other server (rather than its

  • wn)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 41 / 46

slide-88
SLIDE 88

Bandwidth Inheritance

In the previous case:

2 4 6 8 10 12 14 16 τ1 τ2 L(S) S L(S) inheritance S U(S)

Task τ2 inherits the deadline and the budget (so the server) of task τ1 Therefore, it consumes the budget of the other server (rather than its

  • wn)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 41 / 46

slide-89
SLIDE 89

Bandwidth Inheritance

In the previous case:

2 4 6 8 10 12 14 16 τ1 τ2 L(S) S L(S) S U(S) S U(S)

Task τ2 inherits the deadline and the budget (so the server) of task τ1 Therefore, it consumes the budget of the other server (rather than its

  • wn)

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 41 / 46

slide-90
SLIDE 90

Multiprocessor extension

On single-processors, when a task blocks, the lock-owner is not running On multi-processors, when a task blocks

the lock-owner may be running on another core. In this case, the blocking task starts to spin, i.e. it actively waits for the lock-owner to release the resource the lock-owner may be suspended on a different core. In this case, a migration occurs, and the lock owner executes in the server (and hence in the core) of the blocked task

We only consider FIFO blocking queues

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 42 / 46

slide-91
SLIDE 91

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC C Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-92
SLIDE 92

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC B C C Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-93
SLIDE 93

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC BB C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-94
SLIDE 94

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A BBB C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-95
SLIDE 95

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A BBB L(R1) C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-96
SLIDE 96

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A A BBB L(R1) C1 C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-97
SLIDE 97

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A A L(R1) BBB L(R1) C1 C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-98
SLIDE 98

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A A L(R1) BBB L(R1) C1 C1 U(R1) C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-99
SLIDE 99

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A A L(R1) BBB L(R1) C1 C1 U(R1) B1 U(R1) C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-100
SLIDE 100

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A A L(R1) A1 U(R1) BBB L(R1) C1 C1 U(R1) B1 U(R1) B C C C1 L(R1) Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-101
SLIDE 101

Example

3 tasks, τA, τB, τC, executed on 2 processors, that access only Semaphore R1.

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 SA SB SC A A L(R1) A1 U(R1) A BBB L(R1) C1 C1 U(R1) B1 U(R1) B C C C1 L(R1) C Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 43 / 46

slide-102
SLIDE 102

Computing interference

Theorem (Hard schedulability)

Consider a set of reservations schedulable on a system when access to semaphores is not considered. When M-BWI is used as a resource access protocol, hard real-time task τi, with WCET Ci and minimum inter-arrival time Ti, attached to a server Si = (Qi ≥ Ci + Ii, Pi ≤ Ti), never misses its deadline. The interference Ii can be computed with a complex algorithm

a generalization of the Priority Inheritance analysis The complexity is exponential in the number of tasks and length of blocking chains

BWI does not prevent deadlocks!

but can identify them at run time

Currently under implementation in Linux

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 44 / 46

slide-103
SLIDE 103

Outline

1

Introduction to RT Systemes

2

Resource Reservations

3

Hierarchical scheduling

4

Multiprocessor sharing of resources

5

Conclusions

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 45 / 46

slide-104
SLIDE 104

Resource reservations

Resource reservations are an effective technique for mixing hard and soft real-time tasks Other extensions

resource reclaiming power-aware scheduling adaptive reservations

It has been applied to bus scheduling

MemGuard [Pellizzoni et al.]

Currently available in Linux

companies are already experimenting with it give it a try!

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 46 / 46

slide-105
SLIDE 105

Resource reservations

Resource reservations are an effective technique for mixing hard and soft real-time tasks Other extensions

resource reclaiming power-aware scheduling adaptive reservations

It has been applied to bus scheduling

MemGuard [Pellizzoni et al.]

Currently available in Linux

companies are already experimenting with it give it a try!

Open challenges:

combine memory/cache reservation techniques with CPU reservations to improve multicore performance

Giuseppe Lipari (CRIStAL) Multicore for safety-critical embedded systems: challenges and opportunities June 23, 2016 46 / 46