You are on page 1of 30

DESIGN FOR

REAL-TIME SYSTEMS

Real-time Systems - Systems in


which the correctness of the program
depends upon the time are which the
results are delivered as well as the
values calculated.
1
Outline

• The introduction to real-time system


– Some key issues that differentiate the real-time
systems from other types of computer software
• Analysis and simulation of real-time
systems
• Design for real-time systems

December 25, 1997 Assistance - Yaru Liu 2


Real-time System Overview
• Real-time software is highly coupled to the
external world
• Perform high-speed data acquisition and
control under severe time and reliability
constrains
• Time is the most important issue in real-
time system
• Fast and real-time are not the same
– Real-time is predictability and meeting
deadlines, not necessarily fast.
December 25, 1997 Assistance - Yaru Liu 3
System Considerations
Some differences between real-time software
development and other software engineering
effort:
• The design of a real-time system is resource
constrained
• Real-time systems are compact, yet complex
• Real-time systems often work without the presence
of a human user
December 25, 1997 Assistance - Yaru Liu 4
Performance Issues
• Each real-time design concern for software
must be applied in the context of system
performance
– Coordination between the real-time tasks
• Synchronization
• Shared resources, e.g., memory, cpu
– Processing of system interrupts
– I/O handling to ensure that no data are lost
– Specifying the system’s internal and external timing
constraints
– Scheduling of tasks to guarantee meeting deadlines

December 25, 1997 Assistance - Yaru Liu 5


Performance Issues
• The performance of a real-time system is
determined primarily by the system response time
and its data transfer rate
– System response time is the time within which a system
must detect an internal or external event and respond
with an action
– The data transfer rate indicates how fast serial or
parallel data, as well as analog or digital data, must be
moved into or out of the system
• Fundamental question
– Does it meet all deadlines or not?

December 25, 1997 Assistance - Yaru Liu 6


Performance Issues
• Key parameters that affect the system
response time
– Context switching
• the time and overhead to switch among tasks
– Interrupt latency
• the time lag before the switch is actually possible
– Speed of computation
– Speed of access to mass storage

December 25, 1997 Assistance - Yaru Liu 7


Interrupt handling
“Normal”
processing
flow
Software Interrupt handling
Interrupt
is posted •Save state of interrupted program
•Determine nature of the interrupt
•Service interrupt
•Restore state of interrupted program
•Return to interrupted program

December 25, 1997 Assistance - Yaru Liu 8


Nested Interrupt Handling

December 25, 1997 Assistance - Yaru Liu 9


Real-time Date Bases
• Distributed databases
– Multitasking is the commonplace and data are
often processed in parallel
– A failure of one database need not cause failure
of the entire system, if redundancy is build in
– Concurrency control problem. It involves
synchronizing the databases so that all copies
have the correct, identical information
• Use of time stamps and locking.

December 25, 1997 Assistance - Yaru Liu 10


Real-time operating systems
• Two broad classes of OS are used for RT work
– RTOS designed exclusively for RT applications
– General-purpose OS enhanced to provide RT RTOS
• Beware false claims -- checkout capabilities
• Must provide non-blocking I/O
• Must provide a priority mechanism
– For interrupts
– For executing tasks
• RTOS must have a memory locking mechanism
• Must provide timing control mechanisms
– Time resolution should be 1 ms. or less.

December 25, 1997 Assistance - Yaru Liu 11


Real-Time Operating Systems
• Must provide memory sharing threads
• Must provide efficient tasking (context)
switching
• Should provide synchronization mechanism
• Advanced RTOS may provide task
scheduling

December 25, 1997 Assistance - Yaru Liu 12


Real-time languages
• Some differences between a real-time language
and a general-purpose language
– Multitasking capability
– Constructs to directly implement real-time functions
• timing management
• task scheduling
– Features to help achieve program correctness
• package structures -- enable information hiding
• structured mutual exclusion -- monitor functions
• structured synchronization -- task rendezvous
• type attributes -- e.g., range(A) for array A
December 25, 1997 Assistance - Yaru Liu 13
Task Synchronization and
Communication
• Three general approaches
– Queuing semaphores
• manage several queues
– Mailboxes
• buffers which store message or message pointer sent
from one process to another
– Message systems
• one process sends a message to another
• Advanced concepts
– Tasking
– Rendezvous
– Monitors
December 25, 1997 Assistance - Yaru Liu 14
Analysis and simulation of real-
time systems
• Tools for real-time system analysis
– Statistical
– Hard real-time guarantees
• Simulation and modeling tools
– Analyze a system’s performance
– Build a prototype, execute it, and thereby get an
understanding of a system’s behavior

December 25, 1997 Assistance - Yaru Liu 15


Mathematical tools for real-time
system analysis
– DFD-like model
– Assign transitional probabilities between the
process states to each flow path
– Add to the process a “unit cost” that represents
the estimated ( or actual ) execution time
required to perform its function
– Add to the process an “entrance value” that
depicts the number of system interrupts (or
execution requests) corresponding to it

December 25, 1997 Assistance - Yaru Liu 16


Mathematical tools for real-time
system analysis
Data
arrival rate
P12 = 0.6 2
Information in
source 1
P13 = 0.4 3
Unit cost = 4.6
Compute:
• The expected number of visits to a process
• The time spent in the system when processing begins at a specific process
• The total time spent in the system
December 25, 1997 Assistance - Yaru Liu 17
DFD for Real-Time

December 25, 1997 Assistance - Yaru Liu 18


Queuing Model

December 25, 1997 Assistance - Yaru Liu 19


Queuing Reduction Rules

December 25, 1997 Assistance - Yaru Liu 20


Simplifying Networks

December 25, 1997 Assistance - Yaru Liu 21


Simulation and modeling tools
• The conceptual view
– Functional view is captured with activity-
charts, which are similar to conventional DFD
– Dynamic view uses state-charts ( similar to
CFD). Transitions between states are typically
triggered by events
– Integration: each level of an activity-chart,
there will usually be a state-chart

December 25, 1997 Assistance - Yaru Liu 22


Example

December 25, 1997 Assistance - Yaru Liu 23


Statechart for Example

December 25, 1997 Assistance - Yaru Liu 24


Simulation and modeling tools
• The physical view
– The conceptual model is the foundation, but not a real
system
– Decompose a system into subsystem, component, sub-
component
– Relation to conceptual model
• Analysis and simulation
– Statecharts syntactically correct
• complete - no obviously missing label, names
• consistency - e.g., correctness of I/O

December 25, 1997 Assistance - Yaru Liu 25


Simulation and modeling tools
• Running scenarios
– Correctness of function or behavior
– Engineer can play role of user & enter tests
• Programming simulations
– Simulation control language (SCL)
• Automatic translation of activity and
statecharts into code

December 25, 1997 Assistance - Yaru Liu 26


Real-time design
• Incorporate all of the fundamental concepts
and principles associated with high-quality
software
• A set of unique problems
– Representation of interrupts and context switching
– Concurrency as manifested by multitasking and
multiprocessing
– Inter-task communication and synchronization

December 25, 1997 Assistance - Yaru Liu 27


Real-time design (cont’d)
– Wide variations in data and communication rates
– Resource management of shared resources
– Representation of timing constraints
– Need for scheduling
– Asynchronous processing
– Necessary and unavoidable coupling with operating
systems, hardware, and other external system
elements
– High reliability (usually)

December 25, 1997 Assistance - Yaru Liu 28


Real-time design
• A number of modeling principles
– Explicit atomicity
– Interleaving
– Nonterminating histories and fairness
– Closed system principle - include environment
with computer system in analysis
– Structuring state by objects
– Sometimes, physically measure task times
December 25, 1997 Assistance - Yaru Liu 29
Summary
• The design of real-time software = all
aspects of conventional software design + a
new set of design criteria and concerns
• Real-time software must respond to real-world
events in a time frame dictated by those events
• Clock or event driven
• Can be very difficult to design and even more
difficult to test, verify and validate

December 25, 1997 Assistance - Yaru Liu 30

You might also like