roger johansson embedded real time systems - an introduction 1 embedded real time systems – an...
TRANSCRIPT
![Page 1: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/1.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 1
Embedded Real time systems – an Introduction
What’s a ”Real time system”? The concept of control. Embedded real time control – some examples Some terminology ”Scheduling” – determination of actions ”Execution time analysis” – a prerequisite for scheduling
![Page 2: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/2.jpg)
Roger Johansson
Embedded systems
Embedded Real time systems - an Introduction 2
Wikipedia...
” An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, often with real-time computing constraints.
It is usually embedded as part of a complete device including hardware and mechanical parts.”
More distinct...
” An embedded system is a special-purpose digital system designed to perform dedicated functions with real-time computing constraints.
The digital system hardware is embedded as part of a complete device which might include other hardware such as mechanical, pneumatic or hydraulical parts.”
![Page 3: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/3.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 3
Digital systems
Server applications
Personal computing
Embedded systems
Real-Time Control systems
Safety-critical R-T control
Secure/RobustR-T control
![Page 4: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/4.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 4
In Control ? Swedish fighter JAS 39 GRIPEN
![Page 5: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/5.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 5
In Control ? but there is control ...
![Page 6: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/6.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 6
In Control ?
A control system is a feedback system
Time properties (temporal aspects) is fundamental for a well designed control system.
A computer designed for control has to handle REAL-TIME as desired by the controlled object.
Control requires feedback
![Page 7: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/7.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 7
traffic control
local control
train (consist) control
((( )))
((( )))
wayside control
traffic control
local control
train (consist) control
((( )))
((( )))
wayside control
Real time control applications
![Page 8: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/8.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 8
The “F-8 Digital Fly-By-Wire (DFBW)” validated fundamental concepts still used today. The first “by-wire” flight was in the 25’th of May in 1972. The project lasted for 13 years.
hydraulic information
carrier
electronic information
carrier
steer ”by-wire”
![Page 9: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/9.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 9
Computers in space…
![Page 10: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/10.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 10
..and within marine applications.
![Page 11: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/11.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 11
..development of Automotive electronics
![Page 12: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/12.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 12
control characteristics in a car
simple reactive (ON/OFF) …climate, windows …
reactive, autonomous …engine- and gear- control,
anti-brake-lock, anti-spin, etc.
safety criticalairbag ...
others..navigation, audio-video ...
![Page 13: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/13.jpg)
Roger Johansson
correct time
computer time
”computer clock”
”perfect clock”
”Correct time” is an convention
A real time clock, basic terminology
13Embedded Real time systems - an Introduction
![Page 14: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/14.jpg)
Roger Johansson
Cs(t)
t
Ideal : C(t)=t
Cs(t)>t
Cs(t)<t
computer time
correct time
A real time clock, basic terminology
14Embedded Real time systems - an Introduction
![Page 15: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/15.jpg)
Roger Johansson
)()( tCtCs
1
)(1
)()(
0
lim
dt
tCd
t
tCttC
t
DefinitionsCorrectness
Deviation
)()( 1212 tCtCtt Monotoni
15Embedded Real time systems - an Introduction
![Page 16: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/16.jpg)
Roger Johansson
rt0 rt1
rt
ct
Δt
Clock adjustment
16Embedded Real time systems - an Introduction
![Page 17: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/17.jpg)
Roger Johansson
1 21
2
oscillator
timer
Mechanisms
17Embedded Real time systems - an Introduction
)Hz(p
1)s(p
![Page 18: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/18.jpg)
Roger Johansson
Timer interrupt
interval
0 IRQ IRQ IRQ t
Y = X / interval
18Embedded Real time systems - an Introduction
![Page 19: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/19.jpg)
Roger Johansson
timer interrupt ”TICK”
”TIMESLICE” ”TIMESLICE”
”Timer interrupt routine” – invoked approx each ms, requires low overhead
”TIMESLICE” – systemcheck, task switch, more overhead
100 000 ”TIMESLICE” – clock adjustment
Real time clock
19Embedded Real time systems - an Introduction
![Page 20: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/20.jpg)
Roger Johansson
SetTimeGetTimeSetTimeoutSetPeriod......
SetRealTime
GetRealTime
init_timerstart_timerstop_timertimer_interrupt
”software” clock
hardware clock
Application task
Clock services
20Embedded Real time systems - an Introduction
![Page 21: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/21.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 21
A control system
A/D
A/D
Computationscontrol laws
D/A
actuatorsensor object
r(t)
y(t) u(t)
yk
rk
uk
![Page 22: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/22.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 22
Time triggered implementations
object
initiate
input
calculate
output
Pros
Easy to understand, easy to implement.
Cons
Time synchronization is tied to underlying hardware.
Difficult to anticipate and handle unordered events.
Software complexity depends on object .
![Page 23: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/23.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 23
activity..
initiate
object
wait...
Event triggered implementations
Pros
Easy to understand.
Short response times (good feedback performance)
Cons
Exteremely complex software when object becomes complex.
![Page 24: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/24.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 24
A software task
actuator
actuator
sensor
micro computer
sample input from
sensor
update actuators
compute new values
(control laws)
t
task 1 task 2 task 3
![Page 25: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/25.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 25
Scheduling strategies
task 1 task 2 task 3
task switch
t
Non-preemptive
(serial)
task 1
task 2
task 3
task switch
t
Preemptive
(parallel)
![Page 26: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/26.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 26
Measurements, program under test is executed a number of times. A Worst Case Execution Time is estimated.
Code analysis, determine the most time consuming path through the program and determine execution time for this path.
Task Execution time analysis
![Page 27: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/27.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 27
// Example
t_start = C(t);P();t_finish = C(t);
t_exec = t_finish – t_start;
Execution time measure
![Page 28: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/28.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 28
BB 1BB2
BB3
start
stop
label:..instr 1..instr 2..instr 3
...
..instr n
bra ...
label:..instr 1..instr 2..instr 3
...
..instr n
bra ...
Execution time analysis, basic blocks
![Page 29: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/29.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 29
BB 1
BB 2
BB 3
start
stop
A Control Flow Graph represents all possible execution paths in a program. Contributions from all basic blocks are summed.
A Control Flow Graph represents all possible execution paths in a program. Contributions from all basic blocks are summed.
Σ BB
start
stop
Execution time analysis, Control Flow Graphs
![Page 30: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/30.jpg)
Roger Johansson
* MC68HCS12BB:movw _b,_amovw _lb,_la
movw 2+_lb,2+_la
int a,b;long int la,lb;a = b;la = lb;
Each instruction takes 6 processor cycles (from Datasheet).
So, for the block:6+6+6=18 cycles
Execution time:18 * 1/fClock
Basic blocks, assignments
30Embedded Real time systems - an Introduction
![Page 31: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/31.jpg)
Roger Johansson
At the end of the block the ackumulator D should hold 1 (if the expression is true) and 0 otherwise. (Compiler convention)
At the end of the block the ackumulator D should hold 1 (if the expression is true) and 0 otherwise. (Compiler convention)
* MC68HCS12* a == b *BB:
ldd _a cpd _b bne _1 ldd #1 bra _2_1: ldd #0_2:
BB= [min,max]
Basic blocks, test evaluation
31Embedded Real time systems - an Introduction
![Page 32: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/32.jpg)
Roger Johansson
A program flow graph for:if( c == a )
b = 1;else
b = d+e+f+g;
A program flow graph for:if( c == a )
b = 1;else
b = d+e+f+g;
test
S1 S2
Code for ’test’ is always executed.Exactly one of statements ’S1’ or ’S2’ is always executed.
Combining basic blocks, if/else
32Embedded Real time systems - an Introduction
![Page 33: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/33.jpg)
Roger Johansson
Inspect the code, identify and annotate the basic blocks: BB0: if( c == a )BB1: b = 1;
elseBB2: b = d+e+f+g;
From the program flow graph we conclude that:BB(min) = BB0(min) + min ( BB1(min) , BB2(min) ) andBB(max) = BB0(max) + max ( BB1(max) , BB2(max) )
Combining basic blocks, if/else
33Embedded Real time systems - an Introduction
![Page 34: Roger Johansson Embedded Real time systems - an Introduction 1 Embedded Real time systems – an Introduction n What’s a ”Real time system”? The concept](https://reader036.vdocuments.us/reader036/viewer/2022081512/56649d205503460f949f52e5/html5/thumbnails/34.jpg)
Roger Johansson
Embedded Real time systems - an Introduction 34
Summary
we have got a brief introduction towe have got a brief introduction to
The concept of control. Embedded real time control Real Time Systems terminology Task Scheduling Execution time analysis