ICS 2408 Advanced
Topics in Information
Technology
Chapter 6 Real Time
Systems
A System
Consistsof a set of components that
collaborate to achieve a common purpose.
A system comprises of hardware and
software components which are put
together through a well-defined interface.
Components include:
Hardware: sensors, keypads, display, communication
chips
Software: concurrent processes,Real
objects and etc.
Time 1
System
Describing RTS
A system can be define as a collection of
components that respond to inputs from
the user or the environment or from
itself.
Typically,
there is an amount of time
spent between receiving the input and
responding to the input.
In any system it is quite natural to expect
a response within a specific time interval.
Real
Time 1
System
Overall Structure of RT Systems
Hardware (CPU, I/O device etc)
a clock!
A real time OS (function as standard
OS, with predictable behavior and
well-defined functionality)
A collection of RT tasks/processes
(share resources,
communicate/synchronize with each
other and the environment)
Real
Time 1
System
Types of RTS
Hard RTS:
A system where, a missing deadline could
cause lost of life/ massive property
destruction.
eg: Aircrafts, biomedical inst, nuclear reactor
Soft RTS:
A system where a few missed deadlines may
not cause any significant inconvenience to
the user.
eg: Internet streaming ( lost of some packets can
be afforded) Real
Time 1
System
What’s up with Fast & Slow
RTS
Typically, any system that operates within
sub-second response time can be
classified as fast.
While systems that can take a second or
more to respond is classified slow.
Note: soft real time system can be “fast”.
ie: a few packets can be lost across a
high-speed router that works with
nanosecond deadlines.
Similarly hard real time system can be
“slow”. i.e: the cadmium rods inside a
nuclear reactor need not be pulled out at a
Real
Time 1
lighting speed. System
Determinism in RTS
The concept of determinism differentiates real
time programming from normal application
programming.
The time interval between input occurrence
and output occurrence must be
“deterministic” or predictable. ie: the system
always respond within a specified (known)
period of time.
Real
Time 1
System
Which is RTS
Mobile phones
Cars, Trains, Aircrafts
Washing machines
Games
...
All
computers that do not look like a
computer
Consumming 99% of processors produced in
the world!
Real
Time 1
System
Digital control
Real
Time 1
System
Components of RTS
Real
Time 1
System
Characteristics of a RTS
Large and complex
vary from a few hundred lines of assembler
or C to 20 million lines of Ada estimated for
the Space Station Freedom
Concurrent
control of separate system
components
devices operate in parallel in the real-
world; better to model this parallelism by
concurrent entities in the program
Facilities
to interact with special
purpose hardware
need to be able to program devices in a
reliable and abstract way Real
Time 1
System
../ Charac of RTS
Extreme reliability and safety
Embedded systems typically control the
environment in which they operate; failure
to control can result in loss of life, damage
to environment or economic loss
Guaranteed response times
we need to be able to predict with
confidence the worst case response times
for systems; efficiency is important but
predictability is essential Real
Time 1
System
Remember
In
RT systems, the correctness of
computation depends not only on the
results but also on the time when
outputs are produced.
Real Time =/= Fast
Real Time =/= Time Sharing
Real Time = just in Time
(predictable)
Real
Time 1
System
Main desirable properties of RT Systems(1)
Timeliness: not only outputs but also times they
are produced
Robustness: must not collapse when subject to
peak load, exception, manage all possible
scenarios
Fault tolerance: hardware and software failures
should not cause the system to crash
Predictability: able to predict the future
consequences
( in relation to time) of current actions
Maintainability: modular structure to ease system
modification
Testability: easy to test if the system can meet all
the deadlines Real
Time 1
System
How to achieve RTS ( the time factor)
How can u guarantee that your system fulfill the
timing requirement?
A lot of things need to be considered, but here
some of the most useful terms related to the
answer
Scheduling
Concurrency
Synchronization
Re-entrant code
Real
Time 1
System
What makes an OS an RTOS?
A RTOS (Real-Time Operating System) has to be
multi-tasking and pre-emptable.
The notion of process/thread priority has to exist.
The OS has to support predictable process
synchronization mechanisms
A system of priority inheritance has to exist
OS behaviour should be known
Real
Time 1
System
The interrupt latency (i.e. time from interrupt to
task run) : this has to be compatible with
application requirements and has to be
predictable. This value depends on the number of
simultaneous pending interrupts.
For every system call, the maximum time it takes.
It should be predictable and independent from
the number of objects in the system;
The maximum time the OS and drivers mask the
interrupts.
The following points should also be known by the
developer:
System Interrupt Levels.
Device driver IRQ Levels, maximum time they
take, etc. Real
Time 1
System
Embedded Systems
In the day-to-day life we come across a wide variety
of consumer electronic products. We are habituated
to use them easily and flawlessly to our advantage.
Common examples are TV Remote Controllers,
Mobile Phones, FAX machines, Xerox machines etc.
However, we seldom ponder over the technology
behind each of them. Each of these devices does
have one or more programmable devices waiting to
interact with the environment as effectively as
possible.
These are a class of “embedded systems” and they
provide service in real time. i.e. we need not have
to wait too long for the action.
Real
Time 1
System
Network Types
Global System for Mobile Communications, one of
the leading digital cellular systems. GSM uses
narrowband Time Division Multiple Access (TDMA),
which allows eight simultaneous calls on the same
radio frequency. GSM was first introduced in 1991. As
of the end of 1997, GSM service was available in
more than 100 countries and has become the de
facto standard in Europe and Asia.
1
NT
Code-Division Multiple Access, a digital cellular
technology that uses spread-spectrum techniques.
Unlike competing systems, such as GSM, that use
TDMA, CDMA does not assign a specific frequency
to each user. Instead, every channel uses the full
available spectrum. Individual conversations are
encoded with a pseudo-random digital sequence.
CDMA is a military technology first used during
World War II by the English allies to foil German
attempts at jamming transmissions. The allies
decided to transmit over several frequencies,
instead of one, making it difficult for the Germans
to pick up the complete signal.
Real
Time 1
System
From the above specifications it is clear that a mobile phone
is a very complex device which houses a number of
miniature gadgets functioning coherently on a single device.
Moreover each of these embedded gadgets such as digital
camera or an FM radio along with the telephone has a
number of operating modes such as:
• you may like to adjust the zoom of the digital camera,
• you may like to reduce the screen brightness,
• you may like to change the ring tone,
• you may like to relay a specific song from your favorite FM
station to your friend using your mobile
• You may like to use it as a calculator, address book, emailing
device etc.
These variations in the functionality can only be achieved by
a very flexible device.
Real
Time 1
System
This flexible device sitting at the heart of the
circuits is none other than a Customized
Microprocessor better known as an Embedded
Processor and the mobile phone housing a
number of functionalities is known as an
Embedded System.
Since it satisfies the requirement of a number of
users at the same time (you and your friend, you
and the radio station, you and the telephone
network etc) it is working within a time-constraint,
i.e. it has to satisfy everyone with the minimum
acceptable delay. We call this as to work in “Real
Time”. This is unlike your holidaying attitude
when you take the clock on your stride.
Thus we can name the mobile telephone as a
“Real Time Embedded System” Real (RTES)
Time 1
System
A Desktop Computer will have more
open standards than an Embedded
System. This is because of the level of
integration in the later. Many of the
components of the embedded systems are
integrated on to a single chip.
This concept is known as System on
Chip (SOC) design. Thus there are only
few subsystems left to be connected.
Analyzing the assembling process of a
Desktop let us comparatively assess the
possible subsystems of the typical RTES.
Real
Time 1
System
Real
Time 1
System
Parts
The explanation of various parts as follows:
User Interface: for interacting with users. May
consists of keyboard, touch pad etc
ASIC: Application Specific Integrated Circuit:
for specific functions like motor control, data
modulation etc.
Microcontroller(μC): A family of
microprocessors
Real Time Operating System (RTOS): contains
all the software for the system control and
user interface
Controller Process: The overall control
algorithm for the external process. It also
1
provides timing and control for the various
Parts
Digital Signal Processor (DSP) a typical family
of microprocessors
DSP assembly code: code for DSP stored in
program memory
Dual Ported Memory: Data Memory accessible
by two processors at the same time
CODEC: Compressor/Decompressor of the
data
User Interface Process: The part of the RTOS
that runs the software for User Interface
activities
Real
Time 1
System
Example: A car controler
Activities of a car control system. Let
1. C = worst case execution time
2. T = (sampling) period
3. D = deadline
Speed measurement: C=4ms, T=20ms, D=5ms
ABS control: C=10ms,T=40ms, D=40ms
Fuel injection: C=40ms, T=80ms,D=80ms
Other software with soft deadlines e.g audio, air
condition etc
Construct a controller meeting all the
deadlines!
Real
Time 1
System
Programming the car
controller (1)
Process Speed: Process ABS:
Loop Loop
read read
sensor,compute,display.. sensor,compute,display..
. .
sleep (0.02) /*period*/ sleep (0.04) /*period*/
End loop End loop
Process Fuel Soft RT Processes
Loop Loop
read data, compute, read temperature
inject ... el hiss, stereo
sleep(0.08) ....
End loop End loop
Real
Time 1
System
Any problem?
We forgot the execution times !
e.g. Process speed:
20ms = execution time +
sleep(X)
Real
Time 1
System
Programming the car controller (2)
Process Speed: Process ABS
Loop Loop
next := get-time + 0.02 next:=get-time + 0.04
read Read sensor, compute, react
sensor,compute,display... sleep until next
sleep until next End loop
End loop
Process Fuel Soft RT Processes
Loop Loop
next:=get-time + 0.08 read temperature,el hiss,
read data, compute, stereo
inject ... ....
sleep until next End loop
End loop
Real
Time 1
System
Programming the car controller (3)
Real
Time 1
System
What is the problem now?
We don’t know if the deadlines are met!
We need to know the execution times
We need to do schedulability analysis
We need to construct a schedule
We need to implement/buy an RT
operating system
Run-time system (in programming
language design)
Real
Time 1
System