Beruflich Dokumente
Kultur Dokumente
Not all systems need an RTOS; but of with a basic definition of a real-time sys- the effects of a late computation may be
those that do, does the designer know tem, as defined in the Frequently Asked catastrophic. Simply put, a hard real-time
what about the system is “real time”? Questions for the comp.realtime news- system is one where all activities must be
An RTOS can play a key role in deter- group (news://comp.realtime or groups- completed on time. A flight control sys-
mining how a system runs, and it’s beta.google.com/group/comp.realtime): tem is a good example.
critical to choose an RTOS based upon
system requirements. “A real-time system is one in which the On the other hand, soft real time is a prop-
correctness of the computations not only erty of the timeliness of a computation
Real time is a sometimes misunderstood depends upon the logical correctness of where the value diminishes according to
and misapplied property of operating sys- the computation but also upon the time at its tardiness. A soft real-time system can
tems. Moreover, there is often disagree- which the result is produced. If the timing tolerate some late answers to soft real-
ment as to when a Real-Time Operating constraints of the system are not met, sys- time computations, as long as the value
System (RTOS) is needed. For instance, tem failure is said to have occurred.” hasn’t diminished to zero. Deadlines may
when designing an industrial control be missed, but the number and frequency
system or medical instrument, most engi- Real time, then, is a property of systems of such misses must typically comply
neers and system designers would con- where time is literally of the essence. In a with Quality of Service (QoS) metrics.
cur that an RTOS is necessary. However, real-time system, the value of a computa-
questions arise, when it comes to other tion depends on how timely the answer is. Frequently, soft real time is erroneously
applications, such as tracking systems For example, a computation that is com- applied to OSs that cannot guarantee
and a variety of in-vehicle devices. Is an pleted late has a diminishing value, or computations will be completed on time.
RTOS needed here? Or would a general- no value whatsoever, and a computation Such OSs are best described as quasi real
purpose OS such as Linux or Windows do completed early is of no extra value. Real time or pseudo real time OSs in that they
the job? Often, such systems do require time is always a matter of degree, since execute real-time activities in preference
an RTOS, but the issue isn’t recognized even batch computing systems have a real to others whenever necessary, but don’t
until later in the design phase. time aspect to them. Nobody wants to get adequately account for non-schedulable
their payroll deposit two weeks late! activities in the system. Put simply, soft
Therefore, it’s important to understand real time shouldn’t be confused with non
why the real-time capabilities provided Problems arise when many activities com- real-time.
by an RTOS are not only beneficial, but pete for a system’s resources; in fact, this
necessary for a wide variety of embedded is where we begin to apply the real-time Positive impact
systems. For instance, consider a system property to operating systems. In imple- Traditionally, RTOSs have been used in
where users expect or need immediate menting any real-time system, a critical hard real-time environments where fail-
feedback to input. With an RTOS, a devel- step in the process will be the determina- ure to perform activities in a timely man-
oper can ensure that the system always tion of a schedule of activities that enables ner can result in harm to persons or prop-
provides feedback in a timely fashion, all activities to be completed on time. erty. But an RTOS can be just as useful
even when the system is handling many for applications that must meet QoS guar-
other compute-intensive activities. The Any real-time system will comprise dif- antees, particularly when failure to do
user is never left wondering whether the ferent types of activities: those that can be so could result in financial penalty. This
system has, in fact, accepted the button scheduled, those that cannot be scheduled covers obvious service scenarios, such
push or recognized the voice command. (for example, operating system facilities as “30 minutes or it’s free,” but it also
and interrupt handlers), and non real-time includes intangible penalties, such as lost
In a nutshell, an RTOS allows develop- activities. If non-schedulable activities opportunities or loss of market share.
ers to control how long a system will take can execute in preference to schedulable
to perform a task or respond to critical activities, they will affect the ability of the Moreover, real-time technology can be
events. Deadlines can be met within pre- system to handle time constraints. applied to conventional systems in ways
dictable, and wholly consistent, timelines, that positively impact the user experi-
even under heavy system loads. Hard vs. soft real time ence, either by improving the perceived
Often, a distinction is made between hard response to certain events or by ensuring
What, exactly, is real time? and soft real time. A hard real-time con- that important activities execute preferen-
To appreciate what real time is, what it straint is one for which there is no value tially with respect to others in the system.
isn’t, and why it’s beneficial, let us start to a computation if it is late and where For instance, consider a device that pres-
ents live video, such as MPEG movies. If ensures that OS services themselves, inversions. Consequently, a high-priority
this device depends on software for any which are internal factors, don’t introduce thread that becomes ready to run can pre-
part of its content delivery, it may experi- non-schedulable activities that could vio- empt a lower-priority thread.
ence dropped frames at a rate that the user late basic requirement 3.
perceives as unacceptable. With an RTOS, Within this framework all device driv-
however, the developer can precisely con- RTOS vs. GPOS ers and operating system services apart
trol the order in which software processes The key characteristic that separates from basic scheduling and Interprocess
execute and thereby ensure that playback an RTOS from a General-Purpose OS Communication (IPC) exist as separate
occurs at an appropriate and consistent (GPOS) is the predictability inherent in processes within the system. All services
media rate. all of the requirements specified above. are accessed through a synchronous mes-
A GPOS such as Linux attempts to use a sage-passing IPC mechanism that allows
RTOS: A working definition “fairness” policy when scheduling threads the receiver to inherit the priority of the
What, exactly, constitutes a hard real- and processes to the CPU. This gives all client. This priority-inheritance scheme
time operating system? No universally applications in the system a chance to allows OSR 5 to be met by carrying the
accepted definition exists, but here is a make progress, but doesn’t establish the priority of the original real-time activity
good working definition based on real- supremacy of real-time threads in the into all service requests and subsequent
time scheduling theory and consistent system or preserve their relative priori- device driver requests.
with industry practice: A hard RTOS ties, as is required to guarantee that they Figure 1
must guarantee that a feasible schedule finish on time. Likewise, all priority There is an attendant flexibility available
can be executed given sufficient compu- information is usually lost when a system as well. Since OSR 1 and OSR 5 (refer
tational capacity if external factors are service, usually performed in a kernel back to Table 1) stress that device-driver
discounted. External factors, in this case, call, is executing on behalf of the cli- requests need to operate in priority order,
are devices that may generate interrupts, ent thread. This results in unpredictable at the priority of the client, throughput for
including network interfaces that gener- delays and thus prevents an activity from normal operations can be substantially
ate interrupts in response to network traf- completing on time. reduced. Using this model, an operating
fic. In other words, if a system designer service or device driver can be swapped
controls the environment, the operating By contrast, the microkernel architecture out in favor of a real-time version that sat-
system itself will not be the cause of any used in an OS like the QNX Neutrino isfies these requirements.
tardy computations. To provide such guar- RTOS is designed to deal directly with all
antees, the OS must satisfy the following of these requirements (Figure 2). Because A closer look
basic conditions: of its modular design, a microkernel A closer examination of OSR 2 (the OS
RTOS can employ granular synchroniza- must provide priority inheritance or pri-
1. Higher-priority tasks always execute tion mechanisms, ensuring that latencies ority-ceiling emulation) showcases the
in preference to lower-priority tasks are unaffected by system services. value of having services execute at a pri-
(see Figure 1). ority determined by the client of the ser-
2. Priority inversions, which may result The microkernel itself simply manages vice. To begin, we must look at how task
when a higher-priority task needs a processes and threads within the system, synchronization can result in blocking,
resource allocated to a lower-priority and allows them to communicate with and how this blocking can, in turn, cause
one, are bounded. each other. Scheduling is always per- priority inversion.
3. Non-schedulable activities, includ- formed at the thread level, and threads are
ing both non real-time activities and always scheduled according to their fixed Let’s say two jobs are running, Job 1 and
operating system activities, don’t priority – in the case of priority inver- Job 2, and that Job 1 has the higher prior-
exceed the remaining capacity in any sion, by the priority as adjusted by the ity. If Job 1 is ready to execute, but must
particular division. microkernel to compensate for priority wait for Job 2 to complete an activity,
In Figure 1, the RTOS scheduler deter- Operating System Requirements for Real Time
mines which thread should run by look-
OSR 1 The OS must support fixed-priority preemptive scheduling for tasks. (Both
ing at the priority assigned to every thread threads and processes, as applicable)
ready for execution. The thread with
the highest priority is selected to run. OSR 2 The OS must provide priority inheritance or priority-ceiling emulation for
Because of condition 3, we must discount synchronization primitives. This prevents cases of unbounded priority
inversion, where a higher-priority task cannot obtain a resource from a
those activities outside of the control of
lower-priority task.
the operating system, yielding the exter-
nal factors provision above. OSR 3 The OS kernel must be preemptible.
OSR 4 Interrupts must have a fixed upper bound on latency. By extension, support
From these conditions, we can derive the for nested interrupts is required.
Operating System Requirements (OSRs)
listed in Table 1. OSR 5 Operating system services must execute at a priority determined by the
client of the service. All services on which the client depends must inherit
that priority. Priority inversion avoidance must be applied to all shared
OSR 3 and OSR 4 impose a fixed upper resources used by the service.
bound on the latency that may occur on
the onset of any real-time activity. OSR 5 Table 1