You are on page 1of 34

Real-time Systems

◆ Systems controlled by
embedded software whose
behaviour is subject to timing
constraints

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 1


Objectives
◆ To discuss general principles of real-time systems
design
◆ To show how real-time systems can be modelled
using finite state machines
◆ To describe the platform support required by real-
time systems
◆ To describe a typical architecture for monitoring
and control systems

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 2


Real-time systems
◆ Systems which monitor and control their
environment
◆ Inevitably associated with hardware devices
• Sensors: Collect data from the system environment
• Actuators: Change (in some way) the system's
environment
◆ Time is critical. Real-time systems MUST
respond within specified times

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 3


Definition
◆ A real-time system is a software system where the
correct functioning of the system depends on the
results produced by the system and the time at which
these results are produced
◆ A ‘soft’ real-time system is a system whose operation
is degraded if results are not produced according to
the specified timing requirements
◆ A ‘hard’ real-time system is a system whose operation
is incorrect if results are not produced according to the
timing specification

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 4


A real-time system model
Sensor Sensor Sensor Sensor Sensor Sensor

Real-time
control system

Actuator Actuator Actuator Actuator

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 5


Stimulus/Response Systems
◆ Given a stimulus, the system must produce a
response within a specified time
◆ Periodic stimuli. Stimuli which occur at
predictable time intervals
• For example, a temperature sensor may be polled 10 times
per second
◆ Aperiodic stimuli. Stimuli which occur at
unpredictable times
• For example, a system power failure may trigger an
interrupt which must be processed by the system

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 6


Architectural considerations
◆ Real-time systems are usually designed as cooperating
processes with a real-time executive controlling these
processes
◆ Because of the need to respond to timing demands
made by different stimuli/responses, the system
architecture must allow for fast switching between
stimulus handlers
◆ Timing demands of different stimuli are different so a
simple sequential loop is not usually adequate

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 7


System elements
◆ Sensors control processes
• Collect information from sensors. May buffer information
collected in response to a sensor stimulus
◆ Data processor
• Carries out processing of collected information and computes
the system response
◆ Actuator control
• Generates control signals for the actuator

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 8


Sensor/actuator processes

Sensor Actuator

Stimulus Response

Sensor Data Actuator


control processor control

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 9


R-T systems design process
◆ Identify the stimuli to be processed and the
required responses to these stimuli
◆ For each stimulus and response, identify the
timing constraints
◆ Aggregate the stimulus and response processing
into concurrent processes. A process may be
associated with each class of stimulus and
response

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 10


R-T systems design process
◆ Design algorithms to process each class of
stimulus and response. These must meet the given
timing requirements
◆ Design a scheduling system which will ensure
that processes are started in time to meet their
deadlines
◆ Integrate using a real-time executive or operating
system

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 11


State machine modelling
◆ The effect of a stimulus in a real-time system may trigger
a transition from one state to another.
◆ Finite state machine models can be used for modelling
real-time systems.
◆ However, FSM models show all possible states of the
system and the events which trigger a transition from one
state to another.
◆ In a finite state machine, there is a limit on the number of
possible states. Models show the state transition from a
start state to a finish state

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 12


Microwave oven state machine
Full
power on

Full Timer
power Timer
Timeout
Full
power Set Timed Cooking
Idle
time operation complete
Half
power
Half Door
power Timer closed Start
Door
open Door
Half Operation open
Idle
power on Door enabled
closed

Operation
disabled

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 13


Microwave oven states
State Description
Half power on The oven power is set to 300 watts
Full power on The oven power is set to 600 watts
Set time The cookingtime is set to the user’s input
value
Operation disabled Oven operation is disabled for safety. Interior
oven light is on
Operation enabled Oven operation isenabled. Interior oven light
is off
Timed operation Oven in operation. Interior oven light is on.
Timer is counting down.
Cooking complete Timer has counted down to zero. Audible
alarm signal is on. Oven light is off.

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 14


Microwave oven stimuli

Stimulus Description
Half power The user has pressed the half power button
Full power The user has pressed the full power button
Timer The user has pressed one of the timer buttons
Door open The oven door switch is not closed
Door closed The oven door switch is closed
Start The user has pressed the start button
Timeout Timer signalindicating that set cooking time
is finished

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 15


Thread diagrams
◆ Used to structure and present state model
information
◆ Show the end-to-end processing of a specific set
of stimuli
◆ Thread diagrams should be produced for message
combinations. This means for systems with
multiple stimuli, this approach may be
impractical

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 16


Thread diagram - full power

Full Timer Door


power closed
Full power Set time Operation
Idle on enabled

Start

Timeout Timer
Timed Cooking done
Idle
operation complete

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 17


Real-time executives
◆ Real-time executives are specialised operating
systems which manage the processes in the RTS
◆ Responsible for process management and
resource (processor and memory) allocation
◆ May be based on a standard RTE kernel which
is used unchanged or modified for a particular
application
◆ Does not include facilities such as file
management

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 18


Executive components
◆ Real-time clock
• Provides information for process scheduling.
◆ Interrupt handler
• Manages aperiodic requests for service.
◆ Scheduler
• Chooses the next process to be run.
◆ Resource manager
• Allocates memory and processor resources.
◆ Dispatcher
• Starts process execution.

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 19


Non-stop system components
◆ Configuration manager
• Responsible for the dynamic reconfiguration of the system
software and hardware. Hardware modules may be replaced and
software upgraded without stopping the systems
◆ Fault manager
• Responsible for detecting software and hardware faults and
taking appropriate actions (e.g. switching to backup disks) to
ensure that the system continues in operation

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 20


Real-time executive components
◆ Replace with portrait slide

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 21


Periodic process servicing
◆ In most real-time systems, there will be several
classes of periodic process, each with different
periods (the time between executions),
execution times and deadlines (the time by
which processing must be completed)
◆ The real-time clock ticks periodically and each
tick causes an interrupt which schedules the
process manager for periodic processes
◆ The process manager selects a process which
is ready for execution

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 22


RTE process management

Scheduler R
esourcema
n ag
er D
espatcher
Chooseproc ess A
llo
catememory Startexecu
tiono nan
forexecution andproc
essor a vaila
bleprocessor

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 23


Monitoring and control systems
◆ Important class of real-time systems
◆ Continuously check sensors and take actions
depending on sensor values
◆ Monitoring systems examine sensors and
report their results
◆ Control systems take sensor values and control
hardware actuators

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 24


Security system
◆ System is required to monitor sensors on doors
and windows to detect the presence of intruders
in a building
◆ When a sensor indicates a break-in, system
switches on lights around the area and calls police
automatically
◆ Includes provision for operation without a mains
power supply

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 25


Security system
◆ Sensors
• Movement detectors, window sensors, door sensors.
• 50 window sensors, 30 door sensors and 200 movement
detectors.
◆ Actions
• When an intruder is detected, police are called
automatically.
• Lights are switched on in rooms with active sensors.
• An audible alarm is switched on.
◆ The system switches automatically to backup power
when a voltage drop is detected.

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 26


The R-T system design process
◆ Identify stimuli and associated responses
◆ Define the timing constraints associated with
each stimulus and response
◆ Allocate system functions to concurrent
processes
◆ Design algorithms for stimulus processing and
response generation
◆ Design a scheduling system which ensures that
processes will always be scheduled to meet
their deadlines

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 27


Stimuli to be processed
◆ Power failure
• Generated aperiodically by a circuit monitor. When
received, the system must switch to backup power within 50
ms
◆ Intruder alarm
• Stimulus generated by system sensors. Response is to call
the police, switch on building lights and the audible alarm

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 28


Timing requirements
Stimulus/Response Timing requirements
Power fail interrupt The switch to backup power mustbe com pleted
within a deadline of 50 ms.
Door alarm Each door alarm should be polled twice per
second.
Window alarm Each window alarm should be polled twiceper
second.
Movement detector Each movementdetector should be polled twice
per second.
Audible alarm The audible alarm should be switched on within
1/2 second of an alarm being raised by a sensor.
Lights switch The lights should be switched on within 1/2
second of an alarm being raised by a sensor.
Communications The call to the police should be started within 2
seconds of an alarm being raised by a sensor.
Voice synthesiser A synthesised message should be availablewithin
4 seconds of an alarm being raised by a sensor

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 29


Process architecture
◆ Replace with portrait slide

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 30


Control systems
◆ Security system is primarily a monitoring system.
Collects data from sensors but no real-time
actuator control
◆ Control systems are similar but, in response to
sensor values, system sends control signals to
actuators
◆ Example of a monitoring and control system is a
system which monitors temperature and switches
heaters on and off

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 31


A temperature control system
500Hz

Sensor
process

Sensor
500Hz values

Thermostat
process

Switch command
500Hz Room number Thermostat process

Heater control Furnace


process control process

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 32


Key points
◆ A real-time system is a system where software interacts
directly with some hardware devices and which must
respond within given time constraints
◆ Real-time system correctness depends not just
on what the system does but also on how fast it
reacts
◆ Real-time systems are usually designed as a
number of concurrent processes witch separate
processes associated with different types of hardware in
the system

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 33


Key points
◆ Real-time executives are responsible for
process and resource management. This involves
deciding what processes to run so that they can
satisfy the system timing constraints and
allocating resources to these processes
◆ Monitoring and control systems are a very
common type of real-time system. They poll
sensors and send control signal to actuators
depending on the sensor inputs

©Ian Sommerville 1996 M.Sc Course in Computer-based Systems Engineering Slide 34

You might also like