Docsity

Timing Analysis for Embedded Systems: WCET, CAN Bus, and Holistic Scheduling, Study notes of Computer Science

Partial preview of the text

Download Timing Analysis for Embedded Systems: WCET, CAN Bus, and Holistic Scheduling and more Study notes Computer Science in PDF only on Docsity!

Last Time

^ Response time analysis ^ Blocking terms ^ Priority inversion^ ^

And solutions

^ Release jitter ^ Release jitter ^ Other extensions

Today

^ Timing analysis^ ^

Answers a question we commonly ask:^ •^ At most long can this code take to run?

^ Response time over CAN^ ^

Worst-case message times Holistic scheduling  Holistic scheduling

Timing Analysis by Testing  WCET is often estimated by looking for themaximum execution time over many executions^ ^ This is easy^ ^ However, it does not solve the problem!

True

Number of executions

WCETestimate True WCET LongestobservedET #

Execution time Number of executions

LongestobservedET #

Timing Analysis by Testing  Always true:^ ^ Longest observed ET

≤^ true WCET

≤^ WCET estimate

^ Question: What is the requirement for correctlyestimating WCET using testing?

Static Timing Analysis

int foo1 (int a, int b){ int c = b + 31a;int e = 120 - c - a;return e;}*^ link

a6,# link^

a6,# move.l

8(a6),d moveq

#-32,d muls.l

d1,d sub.l

12(a6),d addi.l

#120,d unlk^

a rts  What does it take to estimate WCET of this code?

Analyzing Branches

void^ foo

(int^

a)^ { if^ (a)

{ x += 3a; }*^ else

{ y -= x-a; }} link^

a6,# move.l

8(a6),d tst.l^

d tst.l^

d beq.s^

*+ moveq^

#3,d muls.l

d0,d add.l^

d2,_x bra.s^

*+ move.l

_x,d sub.l^

d2,d move.l

_y,d sub.l^

d1,d move.l

d0,_y unlk^

a rts

Loop Analysis Strategies

1.^ Programmer annotates loops with bounds^ ^

Not very fun  Doesn’t work well for library code  However, could argue that in critical software programmershould always know the loop bounds

2.^ Analyzer tries to figure out loop bounds2.^ Analyzer tries to figure out loop bounds^ ^

Doesn’t always work  Derived bound might be too high

^ Reasonable answer: Analyzer figures out simpleloops, programmer annotates difficult ones

Bottom-Up WCET Analysis void foo4 (void){ if (y==0) {if (x>5) {^ x++;

foo4 if y == 0

max(7,13) + 2 = 15 15+3 = 18

*x++; } else {x = 1;} } else {x = 3;} }

if x> x++^

x = 1

x=

Return Return

Return

3

3

3

3+2 = 5

3+1 = 4

3+10 = 13

max(5,4) + 2 = 7

Hardware Horror Story

^ Start with some simple code: ^ Measure time per loop iteration for k = 1..

Result on NEC V850E

Result on Athlon

Commercial Timing Analysis ^ aiT from Absint^ ^ Supports ARM7TDMI, ColdFire 5307, PowerPC 755,MPC5xx ^ Analysis steps:^ ^ Reconstruct control flow from object code^ ^ Value analysis: Computation of address ranges for ^ Value analysis: Computation of address ranges for^ instructions accessing memory^ ^ Cache analysis: Classification of memory references ascache misses or hits^ ^ Pipeline analysis: Predicting the behavior of the programon the processor pipeline^ ^ Path analysis: Determination of the worst-case executionpath of the program^ ^ Analysis of loops and recursive procedures

Timing Analysis Summary  WCET estimation for simple hardware + simplesoftware ^ Largely a solved problem ^ Technology far less mature than e.g. compiler technology  WCET estimation for complex hardware + complex softwaresoftware ^ Open problem ^ May not be possible ^ May not even be a good idea^ •^ I.e. nobody cares about WCET of spell check in MS Word  Products exist  What kind of chip should one use for a high-performance, time-critical embedded system?

Time Guarantees over CAN  Basic idea:^ ^ Processors scheduled using priorities^ ^ We know WCET of tasks^ ^ CAN scheduled using priorities^ ^ We know WCTT of messages^ ^ Can put it all together using “holistic scheduling” ^ Can put it all together using “holistic scheduling”  Why do we care?^ ^ Accelerometer on your pickup is on CAN bus^ ^ Airbags are also on CAN bus^ ^ Want to guarantee airbag deployment within 150 ms of whenyou start to roll the truck^ •^

Even if lots of other stuff is going over the bus