introduction to worst-case execution-time analysis
TRANSCRIPT
Introduction to Worst-Case Execution-Time AnalysisPeter Puschner
slides: P. Puschner, R. Kirner, B. HuberVU 2.0 182.101 SS 2016
How do we know the timing is right?
2
RTCS
Environment ?
response time
Time in RTS Construction
3
DesignArchitecture, resource planning, schedules
Timing AnalysisSchedulability analysis, WCET analysis
Implementation
From Design to Implementation
4
T1
T4
T2 T3
t
Task set with precedenceconstraints and deadline
T1 T2 T3 T4t
Task sequence:execution times,response time
Can we guarantee that: response time < deadline?
Timing-Analysis Abstraction
5
T1 T2 T3 T4
T1 T2 T3 T4t
In general it is infeasible to model all possible executionscenarios and combinations of task execution times
T1 T2 T3 T4T1 T2T3 T4
Timing analysis abstracts the different execution times of eachtask to one single value ð WCET
TiTi
xt < WCET
xt = WCET
Schedulability and WCET Analysis
Schedulability objects• Units of execution (simple tasks) with WCET• Precedence relations• Synchronization, communication, mutual exclusion• Priorities
WCET-analysis objects• Simple tasks
Interference ... (nasty and therefore widely neglected)• “external” changes of task state that influence exec. time
6
• Inputs available at start• Outputs ready at the end• No blocking inside• No synchronization or
communication inside• Execution time variations only
due to differences in• inputs• task state at start time(no external disturbances)
7
Task
Input
Output
State
State
Simple Task
Why not just Measure WCET?
8
Stop Timing Measurement
Execute Task on Target HW
Start Timing Measurement
WCET estimate ?
Timer,Logic Analyzer,
etc.
Why not just Measure WCET? (2)
• Measuring all different execution traces of a real-size program is intractable in practice.(e.g., mid-size task: 1040 different paths)
• Selected test data for measurement may fail to trigger the longest execution trace.
Rare execution scenarios may be missed (e.g., exception handling, …).
9
Static WCET Analysis
Static WCET Analysis: computes upper bounds for the execution time of pieces of code
10
Execution time: time it takes to execute• a given piece of code (without disturbance)• in a given application context (inputs, state)• on a given machine
cave: execution time is not response time
Goals for WCET Analysis
WCET analysis = modelingComplexity necessitates modeling tradeoffs
11
➭ WCET bounds must be safe➭ WCET bounds should be tight➭ WCET analysis cost should be reasonable
WCET Analysis – Quality
12
BCET WCETt
freq
uenc
y
WCET Bound
WCET Determinants
• Possible sequences of actions of the code (= execution paths) in given application[→ code, context]
• The duration of each occurrence of an action on each possible path[→ hardware, state]
13
t1
t2t3 t4
t5 t6t7
t8
t8
Task
Exec. Time: Simple vs. Complex Arch.Simple Architecture Model
Duration of each action ai is constant:
xt(pk ) = Σ nk,i t(ai )pk … path k xt(pk ) … WCET of pk
t(ai) … WCET of action ai nk,i … number of times action ai is executed on path pk
Complex Architecture ModelDurations of actions ai vary depending on history:
xt(pk ) = Σ t(ai,j(k) )t(ai,j(k)) … WCET of the jth action ai executed on path k
Reasons: pipelining, caches, parallelism, … 14
WCET Analysis Problems
Path analysis: identifying (in)feasible paths to obtainflow facts• Syntactic restrictions – code• Semantic restrictions – code• Input-data space – application• Automatic analysis vs. user annotations
Modelling of hardware timing• CPU architecture• Implementation of instructions• Resource limitations and state dependencies
15
Representation Levels
16
Extraction/annotation of possibleexecution paths – flow facts
Execution-time analysis,computation of WCET bound
Translation of flow facts
Source-CodeRepresentation
Machine-LanguageRepresentation
Representation LevelsFlow-fact mapping between representation levels has
to be formally correctà support by the code transformer
otherwise mapping may be ambiguous.
Possible support by code transformer:• emit execution history
(flow facts update by an external tool)
• perform flow facts transformation in parallel to code transformation.
17
Generic WCET Analysis Framework
18
sourcecode
objectcode
Compilation Transformation ofFlow Facts
Extraction ofFlow Facts
Exec-TimeModeling
WCET
Calculation ofExecutionScenarios
Representation Level
19
WCET analysis of Matlab/Simulink models:
Summary
WCET definition• Code; context (application, situation); machine
WCET versus WCET modelling
Problems of the analysis• Flow fact analysis and annotation
• Hardware modeling
• Bridging the representation levels
20