Professional Documents
Culture Documents
01 - Introduction To Real Time Systems PDF
01 - Introduction To Real Time Systems PDF
◼ Real time (RT) systems are defined informally by a set of characteristics and
properties that they exhibit, that differentiate them from other non real-
time systems such as “on-line” or “batch” systems.
◼ Such a definition is complicated by the fact that some non RT systems may
exhibit some of the same properties/characteristics of their RT cousins and
is further compounded by the fact that not all RT systems exhibit all of the
properties/characteristics listed here.
◼ If this sounds a bit vague, then remember that it is equally difficult to define
what constitutes a non real-time system.
◼ Taking all this into account, the most popular Real-time definitions, in
increasing order of importance, are listed below.
Popular Real-Time System Definitions 4
Sensor Actuator
Actuator11
Sensor11
Sensor
Sensor22 Actuator
Actuator22
Real
Real
Time
Time
Sensor
Sensor33
System
System Actuator
Actuator33
Sensor
Sensornn
Actuator
Actuatornn
5
Popular Real-Time System Definitions (cont…)
2. “ A real time system reacts, responds and alters its actions to affect
the environment in which it is placed” .
Sensor
Sensor11 Real
Real Actuator
Actuator11 ‘T’ Response Time
Time
Time
Input ‘X’ Output ‘Y’
System
System
Input ‘X’
Heater
(That is, in theory, you should always be able to take account of all sensor, software
and hardware delays, the workload of the CPU etc. and be able to calculate under all
circumstances, what the worst case response/delay to an input signal will be.)
Note: As well as a max response time, a RT system might also specify a minimum
response time meaning that the system must not respond any earlier than that time,
or it may even quote a min-max tolerance or window in which the response should
be generated. The response time can vary each time but should fall within that
window on each and every occasion.
5. “A real time system is a system where the correct answer at the wrong
time is the wrong answer”.
8
Examples of real-time systems
➢ The response time of a Soft Real Time system is thus not fixed and may
improve or degrade within acceptable limits depending upon system
loading”.
◼ Real time systems can also be classified on the basis of how they generate
their responses.
◼ An event driven system, is one in which the input sensor is responsible for
detecting that some important ‘event’ (e.g. a push button, or temperature
change etc) critical to the system’s success and operation has taken place.
◼ The occurrence of the event thus triggers a response from the system.
◼ For example an elevator is event driven, so is a burglar alarm, both are based
on digital inputs such as push buttons etc.
Detecting Events
◼ Events are usually detected in one of two ways.
Save State
Restore State
The CPU…
Interrupt
signal
Push Button
acting as
“Sensor”
◼ System level code (i.e. interrupt handlers) to deal with the interrupt and
trigger the execution of users code able to process and respond to it.
Disadvantages to Interrupt Based, Event Driven Systems (cont….)27
◼ The use of interrupts makes systems more difficult to Test and Debug
systems. This is because
no Handle
button0 event
Is button1
pressed?
Handle
button1 event
Is button2
pressed?
Handle
button2 event
…
28
29
Advantages of Polling in Event Driven Systems
◼ Adding more sensors degrades the overall system response time since it
takes longer to poll and service all the sensors as part of the main() loop.
◼ Polling consumes lots of CPU time leaving little spare for other activities.
31
Example Polled System from APSC 160
while( continueSuperLoop() == TRUE ) {
/* get current state of switches */
switch0 = digitalRead (SWITCH0);
switch1 = digitalRead (SWITCH1);
Computer usually employs a hardware timer with say 1ms interrupt precision
toINTRO
generate the timing required to trigger activities.
TO SYSTEM SOFTWARE ENGINEERING
33
Time-Driven Systems (cont…) 34
Utilisation is
Initially all 3 tasks 80.5%
eligible to run. A
with the highest
priority is run first
Idle
Idle
Actual Task
Scheduling using
RMS
Time ms
35
◼ Can we ensure we test all lines of code and all combinations of inputs.
◼ With new kinds of software e.g. AI and Machine learning, it’s almost
impossible to test a system completely or even understand why it failed.
This is because the software “learns” from its exposure to situations. Two
identical machines with identical software exposed to different “learning
experiences” may make different decisions.
37
Testing Issues for Real-Time Systems (cont…)
◼ If the system should fail, it may be difficult (impossible even?) to recreate the
exact same environment that existed just prior to the failure in order to figure
out how and why the system failed.
◼ In fact when a RT system fails there may be nothing left of it to test. This why
black boxes were installed in passenger airplanes to record all sensor data and
pilot interaction so a “post-mortem” examination of the cause of failure can
be determined.
38
Ariane 5
◼ Exploded on its maiden flight in 1996
◼ An exception occurred when a 64-bit floating point number was assigned to a
16 bit integer and it was out of range.
Therac 25 39
◼ Radiation machine used to treat cancer patients in Canada and USA
◼ Software written by someone with inadequate experience of developing real-
time, multi-threaded software and who lacked adequate testing skills.
◼ Two types of radiation(X-Rays and Electrons) could be delivered which
required different scattering hardware to be in place. Errors occurred when
the operator changed the type of radiation to be delivered but the software
did not employ software or mechanical safety interlocks to wait for correct
scattering H/W to move into place before delivering radiation. This resulted
in massive patient overdoses and even death.