Title: Chapter 15: RealTime Software Design
1Chapter 15 Real-Time Software Design
- Yonsei University
- 2nd Semester, 2009
- Sanghyun Park
2Topics Covered
- System design
- Real-time executives
- Monitoring and control systems
- Data acquisition systems
3Real-Time Systems
- A real-time system is a software system where the
correct functioning of the system depends on the
_____ produced by the system and the ____ at
which these results are produced - Soft real-time system
- Hard real-time system
- Time is critical.Real-time systems MUST respond
within specified times
4Stimulus/Response Systems
- One way of looking at a real-time system is as a
stimulus / response system - Given a stimulus, the system must produce a
response within a specified time - Periodic stimuli
- Stimuli which occur at __________ time
intervals(A temperature sensor may be polled 10
times per second) - Aperiodic stimuli
- Stimuli which occur at ___________ times(A
system power failure may trigger an interrupt
which must be processed by the system)
5Architectural Considerations
- A real-time system has to respond to stimuli that
occurat different times - Control should be transferred to the appropriate
_______ for that stimulus as soon as it is
received - This is impractical in _________ programs
- Real-time systems are usually designed as a set
of _________, cooperating processes with a
real-time _________ controlling these processes
6A Real-Time System Model
7Sensor/Actuator Control Processes
8System Elements
- Sensor control
- Collect information from sensors.May buffer
information collected from a sensor - Data processor
- Carry out processing of collected information and
compute the system response - Actuator control
- Manage actuator operation
9Real-Time System Design Process
- Identify stimuli and associated responses
- Define the ______ constraints associated with
each stimulus and response - Aggregate the stimulus and response processing to
_________ processes - For each stimulus and response,design _________
to carry out the required computations - Design a _________ system which will ensure that
processes are started in time to meet their
deadlines - Integrate the system under the control of a
real-time _________
10Real-Time System Modeling
- The effect of a stimulus in a real-time system
may trigger a transition from one state to
another - ______ state model is a good, language-independent
wayof representing the design of a real-time
system - The UML includes notations for defining state
machine models
11State Machine ModelOf A Microwave Oven
12Real-Time Programming
- Hard real-time systems may have to be programmed
in ________ language to ensure that deadlines are
met - System-level languages such as C allow efficient
programs to be written but do not have constructs
to support concurrency or _______ resource
management - ___ as a language designed to support real-time
system design includes a general purpose
concurrency mechanism
13Java As A Real-Time Language
- Java supports lightweight concurrency (threads
and synchronized methods) and can be used for
some ____ real-time systems - Java is not suitable for hard real-time
programming or programming where precise control
of timing is required - Not possible to specify thread execution time
- Uncontrollable garbage collection
- Not possible to discover queue sizes for shared
resources - Variable virtual machine implementation
- Not allow for detailed run-time space or
processor analysis
14Real-Time Executives
- Real-time executives are analogous to an ________
system in a general-purpose computer - Responsible for process management and resource
(processor and memory) allocation - Components
- Real-time clock (timer)
- 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
15ComponentsOf A Real-Time Executives
16Starting A Process
17Stimuli Priority
- The executive has to be able to manage at least
two priority levels for the system processes - ________ level priority highest priority which
is allocated to processes requiring a very fast
response - ______ level priority allocated to periodic
processes
18Scheduling Strategies
- Non pre-emptive scheduling
- Once a process has been scheduled for
execution,it runs to _________ or until it is
blocked for some reason(e.g., waiting for
input) - Pre-emptive scheduling
- The execution of an executing process may be
stoppedif a ______ priority process requires
service - Scheduling algorithms
- Round-robin
- Rate monotonic
- Shortest deadline
19Monitoring and Control Systems
- Important standard/generic real-time system
class - Continuously check sensors and take actions
depending on sensor values - Monitoring systems take an actionwhen some
_________ sensor value is detected - Control systems ___________ control hardware
actuators depending on the value of associated
sensors
20Burglar Alarm System
- A 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, the system
switches on lights around the area and calls
police automatically - The system should include provision for operation
without a main power supply
21Stimuli To Be Processed
- Two classes
- Power failureGenerated automatically by a
circuit monitor.When received, the system must
switch to backup power within 50 ms - Intruder alarmStimulus generated by system
sensors.Response is to call the police, switch
on building lights and the audible alarm
22Stimulus/ResponseTiming Requirements
23Process Architectureof the Burglar Alarm System
24Control Systems
- The burglar alarm system is a _________ system
rather than a control system as it does not
include actuators which are directly affected by
sensor values - Control systems are similar but, in response to
sensor values, the system sends control signals
to actuators - An example of a control system is a building
_______ control system which monitors
temperatures and switches heaters on and off
25Process Architectureof a Temperature Control
System
26Data Acquisition System
- Collect data from sensors for subsequent
processing and analysis - Data collection processes and processing
processes may have different periods and
deadlines - Data collection may be faster than
processinge.g., collection information about an
explosion - ________ or ring buffers are a mechanism for
smoothing speed differences
27Reactor Data Collection
- A system collects data from a set of sensors
monitoring the neutron flux from a nuclear
reactor - Flux data is placed in a ring buffer for later
processing - The ring buffer is itself implemented as a
__________ process so that the collection and
processing processes may be synchronized
28The Architecture Of AFlux Monitoring System
29A Ring Buffer For Data Acquisition
30Mutual Exclusion
- _______ processes collect data and add it to the
buffer. ________ processes take data from the
buffer and make elements available - Producer and consumer processes must be mutually
________ from accessing the same element - The buffer must stop producer processes from
adding information to a full buffer and consumer
processes from trying to take information from an
empty buffer