Real-Time Software Engineering
Real-Time Software Engineering
Software Hardware
Real-Time Responsiveness
Timeliness
Effectiveness
Responsiveness in real-time is the critical difference between embedded systems and other
software systems, such as information systems, web-based systems or personal software
systems. For non-real-time systems, correctness can be defined by specifying how system
inputs map to corresponding outputs that should be produced by the system. In a real-time
system, the correctness depends both on the response to an input and the time taken to
generate that response. If the system takes too long to respond, then the required response
may be ineffective.
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.
Correctness depends
Real-time System
on timing
System Robustness
Error Handling
Hardware Implementation
Software Implementation
Embedded
System Design
System Timing
Additional Functionality
Real-time systems are often considered to be reactive systems. Given a stimulus, the system
must produce a reaction or response within a specified time. Stimuli come from sensors in
the systems environment and from actuators controlled by the system.
Immediate
Action
System Response Required System
Stimulus Response
Processes Time Monitors
Detected Executed
Stimulus Critical? Evaluate Outcome
Response
Options
• Periodic stimuli occur at predictable time intervals. For example, the system may
examine a sensor every 50 milliseconds and take action (respond) depending on that
sensor value (the stimulus).
• Aperiodic stimuli occur irregularly and unpredictably and may be signalled using the
computer's interrupt mechanism. An example of such a stimulus would be an interrupt
indicating that an I/O transfer was complete, and that data was available in a buffer.
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.
Real-time systems are therefore usually designed as cooperating processes with a real-time
executive controlling these processes.
Actuator
Stimulus Fast Switching Sensor Control Data Control
Occurs Initiated Process Processing Process
• Sensor 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 processes generate control signals for the actuators.
Processes collected
information and Data Processor
computes responses
Actuator
Generate control
Control
signals for actuators
Processes
Producer processes collect data and add it to the buffer. Consumer processes take data from
the buffer and make elements available. Producer and consumer processes must be mutually
excluded from accessing the same element. The buffer must stop producer processes
adding information to a full buffer and consumer processes trying to take information from
an empty buffer.
Buffer
The effect of a stimulus in a real-time system may trigger a transition from one state to
another.
State models are therefore often used to describe embedded real-time systems. UML state
diagrams may be used to show the states and state transitions in a real-time system.
No
Yes
Stimulus Current Transition UML State
New State
Detected State Possible? Diagram
Systems-
Efficient Code Preferred
Level
Generation Choice
Need for Languages
Predictable
Hardware
Timing?
Access Object-
Performance Deadline
Oriented
Overhead Challenges
Languages
Outputs to display,
alarm triggers, signals Responses
to reacting systems.
Observer, Analysis,
Display, Alarm, Processes
Reactor.
Applications like
monitoring and alarm Used in
systems
Outputs to actuators
Responses
and displays
Core functions
enabling system Processes
operations
Used in Stimuli
Applications in data acquisition Input values that initiate system
and multimedia actions
Processes Responses
Actions involving production, Output values that result from
buffering, and consumption system processes
Timing analysis
The correctness of a real-time system depends not just on the correctness of its outputs but
also on the time at which these outputs were produced. In a timing analysis, you calculate
how often each process in the system must be executed to ensure that all inputs are
processed and all system responses produced in a timely way. The results of the timing
analysis are used to decide how frequently each process should execute and how these
processes should be scheduled by the real-time operating system.
Process Real-time
Correctness Timing Process
Execution Operating
of Outputs Analysis Scheduling
Frequency System
Duration for
processing stimuli Execution Time
and responses
Critical time
constraints for system Deadlines
responses
Unchanged
Kernel
Process Standard
Management Kernel?
Modified
Kernel
Real-time
Resource
Operating
Allocation
Systems
Excludes File
Management
000000000000000000000000000000000000000000000000000000000000000000000001
The scheduler chooses the next process to be executed by the processor. This depends on a
scheduling strategy which may take the process priority into account. The resource manager
allocates memory and a processor for the process to be executed. The dispatcher takes the
process from ready list, loads it onto a processor and starts execution.
Scheduling strategies:
• Non-pre-emptive scheduling: once a process has been scheduled for execution, it
runs to completion or until it is blocked for some reason (e.g. waiting for I/O).
• Pre-emptive scheduling: the execution of an executing processes may be stopped if a
higher priority process requires service.
• Scheduling algorithms include round-robin, rate monotonic, and shortest deadline
first.
Non- Process
preemptive Runs to
Scheduling Completion
Round-robin
Scheduling Stop Current
Strategies Process
Higher
Preemptive Scheduling Rate
Priority
Scheduling Algorithms Monotonic
Process? Continue
Current
Process Shortest
Deadline
First