Real-Time Systems
Introduction
03/08/10 1
Text Book
• R. Mall, Real-Time
Systems, Pearson,
2008.
• To be supplemented
with handouts
03/08/10 2
Technology Advancements
Decade Technology
’60s Mainframes
’70s Mini Computers
’80s Personal Computers
’90s Internet and mobile phones
’00s Internet-enabled
Source: IDC Embedded appliances
• Embedded devices are now vastly
outnumbering the traditional computers.
These are a type of real-time systems.
03/08/10 3
Introduction
• Embedded systems:
Increasingly being used in newer
applications.
Usually, real-time in nature.
• According to a recent estimate:
The number of processors deployed in
real-time applications vastly
outnumber the total processors
manufactured world-wide.
03/08/10 4
Why Surge in Embedded
Applications?
• Trend of reducing cost of computers:
Processors
Memory
• Flexibility due to Internet
• Reducing power consumption
• Reducing size
• Increased:
Processing power
Hardware and software reliability
03/08/10 5
Examples
• Set-top boxes,
mobile phones,
iPods, PDAs...
• Modern cars: Up to
~100 processors:
Complex software
Engine & emissions
control,
Stability & traction
control,
Diagnostics,
Automatic
03/08/10 6
transmission
Where Are the Embedded
Systems?
03/08/10 7
What is Real-Time?
• Real-time is a quantitative notion of
time measured using a physical clock.
Example: After a certain event occurs
(temperature exceeds 500 degrees) the
corresponding action (coolant shower)
must complete within 100mSec.
• This is in contrast to the qualitative
notion of time:
Expressed using notions such as before,
03/08/10
after, sometime, eventually, etc. 8
Embedded System Applications
Industrial
• Chemical Plant Control
• Automated Car Assembly Plant
• Supervisory Control And Data Acquisition(SCADA)
Medical
• Robot Used in recovery of Displaced
Radioactive Material, Medical equipments
Peripheral Equipments
• Laser Printer, digital cameras and
camcorders, sensors
Transportation
• Multi-Point Fuel Injection (MPFI) System
• Automated car
03/08/10 9
Embedded System
Applications cont…
– Telecommunication Applications
• Cellular System
– Aerospace
• Computer On-board an Aircraft
– Internet
– Multimedia Applications
• Video Conferencing
– Consumer Electronics
• Cell Phones, digital cameras and camcorders
– Defence Applications
• Missile Guidance System
03/08/10 10
Example: Automotive Applications
• In 2005, 30-90 processors
per car
Engine control, Break
system, Airbag deployment
system
Windshield wiper, door locks,
entertainment systems
• Example: BMW 745i
2,000,000 LOC
Window CE OS
Over 60 microprocessors
53 8-bit, 11 32-bit, 7 16-bit
Multiple networks
03/08/10 11
Source: Insup Lee, UPenn
MPFI: Multi-Point Fuel
Injection
• ECU (Engine
Control Unit)
controls the timing
and amount of fuel
injected. :
Receive signal from
various sensors,
Process the signals
Send control
signals to the
actuators.
03/08/10 12
Laser Printer
• Raster line.
A horizontal strip of
dots across a page.
Created by a raster
image processor
laser beam neutralizes
the charge on the black
parts of the image
• leaving a static electric
negative image on the
photoreceptor surface
03/08/10 13
Mobile Phone
• Tasks for the processor:
Convert input voice to digital
using DSP techniques
Convert digital voice to CDMA
signals
Convert incoming CDMA signals
to microphone signals
Handle signals on the control
channel
Handle user invoked functions
03/08/10 14
SCADA
• Supervisory Control and Data
Acquisition
A computer system monitoring and
controlling a process
• Sensors store process data in a
Distributed real-time database.
• Supervisory system issues control
signal
• Example: Energy Management System
03/08/10 15
Computer On-board an
Aircraft
• Periodically sample:
Velocity, acceleration, altitude
• Compute current position (X,Y,Z
position)
• Compute deviation from the trajectory
• Drive actuators to take corrective
actions.
• Task deadlines in few micro to
milliseconds.
03/08/10 16
Anti-Missile System
• Sense target and home onto it:
Based on some thermal or
electrical characteristics.
Carry out track corrections
based on target trajectory.
• Sampling and processing
activities:
Typically need to be completed
in a few micro or milliseconds.
03/08/10 17
Key Recent Trends
• Increasing computation demands
e.g. video conferencing, MobileTV.
• Increasingly networked
Remotely monitor/debug
Embedded web browser
• e.g. Mercedes car with web browser
Cameras, disks etc. that sit directly on
networks
• Increasing need for reducing time-to-
market under ever changing standards!
• 03/08/10
Need careful co-design of h/w & s/w! 18
Basic Model of an
Embedded System
03/08/10 19
Sensors
• A sensor converts some physical
characteristic of its environment:
– Into electrical signals.
• Example sensors:
– A photo-voltaic cell converts light energy
into electrical energy.
– A temperature sensor typically operates
based on the principle of a thermocouple.
– A pressure sensor typically operates based
on the piezoelectricity principle.
03/08/10 20
Low Cost Sensors
From left to right: IR proximity, shaft encoder,
GPS, Sonar, IR distance, Electronic Compass,
CMOS Camera
03/08/10 21
Actuators
• An actuator converts electrical signals
from a computer:
– Into some physical actions.
• The physical actions may be:
– Motion, change of thermal, electrical,
pneumatic, or physical characteristics of
some objects.
• Example actuators:
– Motors
– Heaters Stepper Motor
– Hydraulic and pneumatic actuators
03/08/10 22
Low Cost Servos
•A Servo is a small wireless device that has a shaft.
•The shaft can be positioned at specific angular
positions:
•By
03/08/10
sending a coded signal. 23
Servo
• As long as a coded signal exists on the
input line,
The servo will maintain the angular
position of the shaft.
• As the coded signal changes,
The angular position of the shaft
changes.
• Servos are used predominantly in
robots:
Also used in radio controlled cars, and
puppets.
03/08/10 24
Signal Conditioning
• Analog signals are generated by a sensor:
A photo-voltaic cell normally generates signals
in the millivolts range.
Need to be conditioned before they can be
processed by a computer.
• Important types of conditioning:
Voltage Amplification
Voltage Level Shifting
Frequency Range Shifting and Filtering
Signal Mode Conversion
03/08/10 25
ADC and DAC
• Analog-to-digital converter (ADC):
Converts continuous signals to
discrete digital numbers.
• The reverse operation:
Performed by a digital-to-analog
converter (DAC).
03/08/10 26
Characteristics of
Real-Time Systems
03/08/10 27
What is a Real-Time
System?
• A system is called real-time:
Whenever we need to quantitatively
express time to describe its
behaviour.
• Recall how to describe the
behaviour of a system?
List inputs to the system and the
corresponding system response.
03/08/10 28
Important Characteristics
• An embedded system responds to
events.
External Process External
Input Event New Data Output Event
Example: An Automobile airbag system.
When the airbag’s motion sensors detect a
collision, the system needs to respond by
deploying the airbag within 10ms or less.
– or the system fails!
03/08/10 29
Embedded Systems = Hardware +
RTOS +Application Program
ELECTROMECHANICAL SOFTWARE
BACKUP & SAFETY
MEMORY
SENSORS
A/D
CONVERSION CPU D/A
CONVERSION
ACTUATORS
AUXILLARY
HUMAN DIAGNOSTIC SYSTEMS
INTERFACE PORT (POWER,
COOLING)
External
Environment
03/08/10 30
What is a Real-Time OS?
• An embedded system responds to
external inputs:
If response time to an event is too
long, the system fails.
• General purpose Operating
Systems:
Not designed for real-time use
• Real-time Operating Systems:
Help
03/08/10
tasks meet their deadline. 31
Characteristics of An
Embedded System
•Real-time:
• Every real-time task is associated
with some time constraints, e.g. a
Deadline.
•Correctness Criterion:
• Results should be logically
correct,
• And within the stipulated time.
03/08/10 32
Characteristics of an
Embedded System cont…
• Safety and Task Criticality:
A critical task is one whose failure
causes system failure (example:
obstacle avoidance).
A safe system does not cause damage.
A safety-critical real-time system is
one where any failure causes severe
damage.
03/08/10 33
Characteristics of an
Embedded System cont…
• Concurrency:
A RT system needs to respond to
several independent events.
Typically separate tasks process
each independent event.
For the same inputs, the result can
be different (Non-determinism).
03/08/10 34
Characteristics of
Embedded Systems cont…
• Distributed and Feedback
Structure
• Custom Hardware:
An embedded system is often
implemented on custom H/W that
is specially designed and developed
for the purpose.
03/08/10 35
Characteristics of
Embedded Systems
Feedback structure of real-time systems
03/08/10 36
Characteristics of Embedded
Systems cont…
• Reactive:
On-going interaction between
computer and environment.
• Stability:
Under overload conditions, work
acceptably for at least important
tasks.
• Exception Handling:
03/08/10 37
Safety and Reliability
•Independent concepts in
traditional systems.
• A safe system does not cause
damage even when it fails.
• A reliable system operates for
long time without any failure.
03/08/10 38
Safety and Reliability
• In traditional systems, safety and
reliability are independent
concerns:
A system can be safe and unreliable
and vice versa.
Give examples of:
• A safe and unreliable system
• A reliable and unsafe system
03/08/10 39
Safety and Reliability
cont…
• Interrelated in safety-critical
system.
A safety critical system is one
for which any failure of the
system would result in severe
damage.
• Safety can be ensured only
through increased reliability.
03/08/10 40
Safety and Reliability
• An unreliable system can be made
safe upon a failure:
By reverting to a fail-safe state.
• A fail-safe state:
No damage can result if a system
fails in this state.
Example: For a traffic light, all
lights orange and blinking.
03/08/10 41
Fail-Safe State
• The fail-safe state of a word
processing program:
The document being processed has
been saved onto the disk.
• Fail-safe states help separate the
issues of safety and reliability.
Even if a system is unreliable, it can
always be made to fail in a fail-safe
03/08/10state. 42
Safety and Reliability
• For a safety-critical system
No fail-safe state exists.
• Consider the navigation system on an
aircraft:
• When the navigation system fails:
• Shutting down the engine can be of
little help!
As a result, for a safety-critical
system:
• The only way to achieve safety is by
making it reliable.
03/08/10 43
Safety-Critical
Systems
• A safety-critical system is
one for which a failure can
cause severe damages.
• A safety-critical system does
not have any fail-safe states:
Safety can only be ensured
through increased reliability.
03/08/10 44
How to Design a Highly
Reliable System?
–Error Avoidance
–Error Detection and
Removing
–Fault Tolerance
03/08/10 45
Fault Tolerance in RT
System
• The essential idea:
Provide redundancy
• Hardware Fault-Tolerance:
Masks the effects of a hardware
fault.
• Software Fault-Tolerance:
Masks the effects of a program
03/08/10
fault. 46
Fault Tolerance in RT
System
–Hardware FT:
•Built in self test (BIST)
•Triple modular redundancy
–Software FT:
•N-Version programming
•Recovery Blocks
03/08/10 47
Triple Modular Redundancy
C1, C2 and C3 are redundant copies of same component
03/08/10 48
N-version Programming
• Software fault tolerance technique
inspired by TMR of hardware:
Different teams are employed to
develop the same software.
Unsatisfactory performance in
practice.
Reason: Faults are correlated in the
different versions.
All
03/08/10
versions fail for similar reasons. 49
Recovery Blocks
Software Fault Tolerance using recovery blocks
03/08/10 50
Modern Embedded Systems
Application
Analog
Specific HW
I/O
Processor
Cores Memory
• Embedded systems incorporate:
Application-specific hardware (ASICs, FPGAs
etc.)
• performance, low power
Programmable processors: DSPs, controllers etc.
Mechanical transducers and actuators
03/08/10 51
Block Diagram of An
Embedded System
controller
control panel processes
Real-time
ASIC UI
Processor OS
processes
DSP Programmable DSP
Programmable
Assembly DSP Assembly
DSP
Code Code
Dual-ported
CODEC
RAM
03/08/10 52