You are on page 1of 24

Real-Time and Embedded

Systems

Nam Ho
Dr. Anh-Vu Dinh-Duc
Module Outline

 Introduction to Real-Time Systems


 Real-Time Task Scheduling
 Real-Time Operating Systems (RTOS)
 Measuring Execution Time and
Real-Time Performance
 Development of Embedded Systems
 Our Research Results in Embedded
Systems
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 2
Measuring Execution Time
and Real-Time Performance

 Why do we perform this work ?


 Many embedded systems require hard or
soft real-time execution. To ensure the
requirements are met, it is necessary to
measure the execution time of individual
tasks, as well as establish the overall
real-time performance of the system
 What exactly is being measured ?
 How is it being measured ?
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 3
What exactly is being
measured ?
 Real-Time Scheduling Analysis
 Task Execution Time
 Periodic Time of Task
 The effect of RTOS Overhead
 Context Switch
 Interrupt Processing
 The effect of RTOS Services
 Message Passing
 Semaphore Processing
 Memory Allocation/Deallocation

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 4
Measurement Methods
 Stop-watch
 Program starts, state the watch. Program ends,
stop the watch and read the time
 Too low in accuracy for real-time code
 Ignore this manual method
 Software Analyzer
 WindView, Tornado Environment (VxWorks)
 ARM RealView Profiler
 Real-Time Trace, Keil ARM Development Tools
 …
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 5
Measurement Methods –
WindView

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 6
Measurement Methods –
Using Timer Services

start = OSTimerGet();
do stuff; Measurement
finish = OSTimerGet();
total = (finish – start)/CLOCK_TICKS;

Accuracy depends on the tick resolution

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 7
Code Execution Time
Estimation

T = Ic * CPI / f
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 8
Measurement Methods –
Hardware Tools

 The best tools for accurately


measuring execution time
 Hook up the probes to the CPU pins
 The embedded application is designed
with at least one such port dedicated
to testing and debugging
 The software must send the signals to
these dedicated port pins
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 9
Measurement Methods –
Hardware Tools
Using LPC2294’s GPIO port
pins to measure the
execution time

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 10
Measurement Methods –
Logic Analyzer

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 11
Measurement Methods –
Oscilloscope

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 12
Measurement Methods

 Must setup macros for writing the


output port
#define MEZ_START(id)
output(dioport,0x50|id&0xF)
#define MEZ_STOP(id)
output(dioport,0x60|id&0xF)

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 13
Measuring Task Execution

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 14
Measuring Task Execution

etask c = (55.081 – 28.677) – (3.0669 +


5.0944 + 3.3741 + 3.0464) = 11.8222
msec
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 15
Measuring Task Execution – Effect
of Context Switch Overhead

e1,1 = tg; e2,1 = tc; e3,1 = ta


e2,2 = tf+th+2Δthr; e3,2 = tb+td+2Δthr
eidle = ty+tz+4Δthr; e3,3 = te+ti+tk+4Δthr
Whenever a high priority task preempts a low-priority task, the preemption
overhead (Δthr) is added to the execution time of the lower priority task
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 16
Measuring Task Execution – Effect
of Context Switch Overhead

 Need this overhead for each task is constant


 Supposing the start task event was logged
before the overhead, and the end task event
was logged after the overhead
e1,1 = tg + 2Δthr; e2,1 = tc + 2Δthr; e3,1 = ta + 2Δthr
e2,2 = tf+th+2Δthr; e3,2 = tb+td+2Δthr
eidle = ty+tz; e3,3 = te+ti+tk+2Δthr

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 17
Measuring Task Execution – Effect
of Context Switch Overhead

The entire task set is feasible by RMS if and only if


( e j 2. )
L max{1 i n} min{t S } ij 1 . t / pj 1,
i t
where Si {k . p j | j 1, ..., i; k 1, ..., p / p }
i j

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 18
Measuring Time of Task
Context Switch
 Using two periodic tasks each at a different priority
 The slowest task toggles bit on a GPIO pin connecting to channel 1
 The other toggles bit on another GPIO pin connecting to channel 2

2Δthr = t1 – t2 – t3
8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 19
Measuring Time of Interrupt
Latency
Force a software interrupt
Toggle a GPIO pin

Toggle a GPIO pin

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 20
Measuring Time of Interrupt
Latency

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 21
Measuring Time of Interrupt
Latency

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 22
Measuring Time of RTOS’s
Services

 Message Passing
 Semaphore Processing
 Memory Allocation/Deallocation

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 23
Reference
 David B. Stewart, Measuring Execution Time and
Real-Time Performance, Embedded Systems
Conference, Boston, September 2006
 William Lamie and John Carbone, Measure your
RTOS’s Real-Time Performance,
http://www.eetimes.com/design/automotive-
design/4007081/Measure-your-RTOS-s-real-time-
performance, 2007
 Phillip A. Laplante, Real-Time System Design and
Analysis An Engineers Handbook, John Wiley &
Sons, Inc., Third Edition, 2004

8/20/2010 Embedded Systems Course: Measuring Execution Time and Real-Time Performance - 2010 24

You might also like