Upload
linore
View
52
Download
2
Embed Size (px)
DESCRIPTION
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. Embedded systems. - PowerPoint PPT Presentation
Citation preview
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
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.”
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
Roger Johansson
Embedded Real time systems - an Introduction 4
In Control ? Swedish fighter JAS 39 GRIPEN
Roger Johansson
Embedded Real time systems - an Introduction 5
In Control ? but there is control ...
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
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
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”
Roger Johansson
Embedded Real time systems - an Introduction 9
Computers in space…
Roger Johansson
Embedded Real time systems - an Introduction 10
..and within marine applications.
Roger Johansson
Embedded Real time systems - an Introduction 11
..development of Automotive electronics
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 ...
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
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
Roger Johansson
)()( tCtCs
1
)(1
)()(
0
lim
dt
tCd
t
tCttC
t
DefinitionsCorrectness
Deviation
)()( 1212 tCtCtt Monotoni
15Embedded Real time systems - an Introduction
Roger Johansson
rt0 rt1
rt
ct
Δt
Clock adjustment
16Embedded Real time systems - an Introduction
Roger Johansson
1 21
2
oscillator
timer
Mechanisms
17Embedded Real time systems - an Introduction
)Hz(p
1)s(p
Roger Johansson
Timer interrupt
interval
0 IRQ IRQ IRQ t
Y = X / interval
18Embedded Real time systems - an Introduction
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
Roger Johansson
SetTimeGetTimeSetTimeoutSetPeriod......
SetRealTime
GetRealTime
init_timerstart_timerstop_timertimer_interrupt
”software” clock
hardware clock
Application task
Clock services
20Embedded Real time systems - an Introduction
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
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 .
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.
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
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)
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
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
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
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
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
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
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
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
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