Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
55 views1 page

Real-Time Software Engineering

Uploaded by

Neda'a Hamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Real-Time Software Engineering

Uploaded by

Neda'a Hamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Real-time Software Engineering

The big picture


Computers are used to control a wide range of systems from simple domestic machines,
through games controllers, to entire manufacturing plants. Their software must react to
events generated by the hardware and, often, issue control signals in response to these
events. The software in these systems is embedded in system hardware, often in read-only
memory, and usually responds, in real time, to events from the system's environment.

Software Hardware

Control Signals Read-Only Memory


Embedded
Event Reactions Sensor Inputs
Systems

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.

Choose the appropriate system type based on responsiveness


needs.

Real-time Systems Non-real-time Systems


Prioritize timely responses Focus on input-output
mapping

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.

Real-time System Hierarchy

Correctness depends
Real-time System
on timing

Operation degrades if Soft Real-time


timing is missed System

Operates incorrectly if Hard Real-


timing is missed time System

Characteristics of embedded systems:


• Embedded systems generally run continuously and do not terminate.
• Interactions with the system's environment are unpredictable.
• There may be physical limitations that affect the design of a system.
• Direct hardware interaction may be necessary.
• Issues of safety and reliability may dominate the system design.

Continuous Operation Unpredictable Interactions

Non-terminating Environmental Variability


++++++++++++++++++++++++++++++++++++++++++++++99999999999999999999999999999
999
Continuous Processing Dynamic Conditions
Embedded
Systems
Direct Hardware Interaction Physical Limitations
Characteristics
Sensor Integration Resource Constraints
Actuator Control Hardware Limitations

Safety and Reliability

System Robustness
Error Handling

Embedded system design


The design process for embedded systems is a systems engineering process that has to
consider, in detail, the design and performance of the system hardware. Part of the design
process may involve deciding which system capabilities are to be implemented in software
and which in hardware. Low-level decisions on hardware, support software and system
timing must be considered early in the process. These may mean that additional software
functionality, such as battery and power management, has to be included in the system.

Navigating Embedded System Design Choices

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.

Understanding Real-time System Stimuli

Aperiodic Stimuli Periodic Stimuli


Occur irregularly Occur at
and unpredictably predictable
intervals

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.

Real-time System Response Sequence

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.

Real-time System Process Architecture

Collect information Sensor Control


from sensors Processes

Processes collected
information and Data Processor
computes responses

Actuator
Generate control
Control
signals for actuators
Processes

Processes in a real-time system have to be coordinated and share information. Process


coordination mechanisms ensure mutual exclusion to shared resources. When one process
is modifying a shared resource, other processes should not be able to change that resource.
When designing the information exchange between processes, you have to take into
account the fact that these processes may be running at different speeds.

Mutual Exclusion Information Exchange

Shared Resource Protection Speed Variability


Process
Process Synchronization Data Consistency
Coordination
Mechanisms

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.

Producer Processes Consumer Processes

Data Collection Data Retrieval


Producer-
Buffering Data Utilization
Consumer
Model

Buffer

Full Buffer Prevention


Empty Buffer Prevention

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

Programming languages for real-time systems development have to include facilities to


access system hardware, and it should be possible to predict the timing of particular
operations in these languages. Systems-level languages, such as C, which allow efficient
code to be generated are widely used in preference to languages such as Java. There is a
performance overhead in object-oriented systems because extra code is required to
mediate access to attributes and handle calls to operations. The loss of performance may
make it impossible to meet real-time deadlines.

Systems-
Efficient Code Preferred
Level
Generation Choice
Need for Languages
Predictable
Hardware
Timing?
Access Object-
Performance Deadline
Oriented
Overhead Challenges
Languages

Architectural patterns for real-time software


Characteristic system architectures for embedded systems:
• Observe and React pattern is used when a set of sensors are routinely monitored and
displayed.
• Environmental Control pattern is used when a system includes sensors, which provide
information about the environment and actuators that can change the environment.
• Process Pipeline pattern is used when data has to be transformed from one
representation to another before it can be processed.

Innovative Architectural Patterns for Embedded


System Efficiency
Environmental
Control
This pattern integrates
sensors and actuators
to monitor and alter the
environment.
Observe and
React Process Pipeline
This pattern involves This pattern transforms
monitoring sensors and data from one
displaying their data in representation to
real-time. another for processing.

Observe and React pattern description


The input values of a set of sensors of the same types are collected and analyzed. These
values are displayed in some way. If the sensor values indicate that some exceptional
condition has arisen, then actions are initiated to draw the operator's attention to that value
and, in certain cases, to take actions in response to the exceptional value.
Stimuli
Values from sensors attached to the system.
Responses
Outputs to display, alarm triggers, signals to reacting systems.
Processes
Observer, Analysis, Display, Alarm, Reactor.
Used in
Monitoring systems, alarm systems.

Observe and React Pattern

Input values from


Stimuli
sensors

Outputs to display,
alarm triggers, signals Responses
to reacting systems.
Observer, Analysis,
Display, Alarm, Processes
Reactor.

Applications like
monitoring and alarm Used in
systems

Environmental Control pattern description


The system analyzes information from a set of sensors that collect data from the system's
environment. Further information may also be collected on the state of the actuators that are
connected to the system. Based on the data from the sensors and actuators, control signals
are sent to the actuators that then cause changes to the system's environment. Information
about the sensor values and the state of the actuators may be displayed.
Stimuli
Values from sensors attached to the system and the state of the system actuators.
Responses
Control signals to actuators, display information.
Processes
Monitor, Control, Display, Actuator Driver, Actuator monitor.
Used in
Control systems.

Control System Architecture

Outputs to actuators
Responses
and displays

Inputs from sensors


Stimuli
and system state

Core functions
enabling system Processes
operations

Control Systems Used in

Process Pipeline pattern description


A pipeline of processes is set up with data moving in sequence from one end of the pipeline
to another. The processes are often linked by synchronized buffers to allow the producer
and consumer processes to run at different speeds. The culmination of a pipeline may be
display or data storage or the pipeline may terminate in an actuator.
Stimuli
Input values from the environment or some other process
Responses
Output values to the environment or a shared buffer
Processes
Producer, Buffer, Consumer
Used in
Data acquisition systems, multimedia systems

Understanding System Frameworks

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

Factors in timing analysis:


• Deadlines: the times by which stimuli must be processed and some response
produced by the system.
• Frequency: the number of times per second that a process must execute so that you
are confident that it can always meet its deadlines.
• Execution time: the time required to process a stimulus and produce a response.

Timing Analysis Factors in Real-time Systems

Duration for
processing stimuli Execution Time
and responses

Execution rate to meet


Frequency
deadlines consistently

Critical time
constraints for system Deadlines
responses

Real-time operating systems


Real-time operating systems are specialized 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 kernel which is used unchanged or modified for a
particular application. Do not normally include facilities such as file management.

Unchanged
Kernel
Process Standard
Management Kernel?
Modified
Kernel
Real-time
Resource
Operating
Allocation
Systems

Excludes File
Management

000000000000000000000000000000000000000000000000000000000000000000000001

Real-time operating system 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.

Components of a Real-time Operating System

Dispatcher Starts process execution

Resource Allocates memory and


Manager processor resources

Chooses the next process to


Scheduler run

Manages aperiodic service


Interrupt Handler requests

Provides timing information for


Real-time Clock scheduling

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.

Real-time Software Execution Process

Scheduler Chooses Process

Resource Manager Allocates Memory

Dispatcher Loads Process

Dispatcher 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

You might also like