What is "real-time" Unix

David B Stewart dstewart at fas.ri.cmu.edu
Tue Oct 31 06:06:10 AEST 1989


In article <1991 at sactoh0.UUCP> you write:
>I always thought that "real-time" meant something that happens now.

Unfortunately that is what too many people think.

The definition of a real-time system (as it has been published many times,
so I don't know the original author) is the following:

"A real-time system is one in which the correctness of the computations not
only depends upon the logical correctness of the computation but also upon
the time at which the result is produced. If the timing constraints of the
system are not met, system failure is said to have occurred.  Hence, it is
essential that the timing constraints of the system are guaranteed to be
met.  Guaranteeing timing behavior requires that the system be predictable.
It is also desirable that the system attain a high degree of utilization
while satisfying the timing constraints of the system."

A good example is a robot that has to pick up something from a conveyor
belt.  The piece is moving, and the robot has a small window to pick up
the object.  If the robot is late, the piece won't be there anymore,
and thus the job will have been done incorrectly, even though the robot
went to the right place.  

Another example is the servo loops in an airplane when on auto-pilot.  
The sensors of the plane must continuously supply the control computer
with proper measurements.  If a measurement is missed, the performance
of the airplane can degrade, sometimes to unacceptable levels.

I am at the tail end of writing a "True" Real-time Operating System (called
CHIMERA II).  The idea of Real-Time systems you had above is unfortunately
the same idea that many manufacturers of real-time operating systems also
have (even some of the so-called gurus of real-time systems don't know what
a real-time system is!).  These real-time systems call themselves 'real-time'
because their system provides the following features:

- high performance (over 80%CPU utilization for control rates over 
100Hz.  If UNIX tries to run control programs at 100Hz,
it will be lucky to achieve 50% cpu utilization, because of the overhead
involved in the operating system).  [As a publicity note for my own work :-)
CHIMERA II provides over 92% CPU utilization at 1000 Hz, and over 99% 
utilization at 100Hz].

- highest-priority-first scheduling:  This lets one process be given priority
over another, but it is not truly 'real-time scheduling' as many manufacturers 
will make you believe because this type of scheduling does not take 'time'
into account.

- Accurate time-pausing:  This is a true real-time system feature provided 
by any so-called Real-time Operating System, but it is not enough.

The most important feature of all, which most every real-time operating system 
I have seen to date is lacking, is the one to account for that original 
example I mentioned:  the ability to perform deadline scheduling.  I.e.,
this process must finish by time X, if not, it is wrong.  An important
feature in such a system is "What happens if I do miss the deadline?".
If you NEVER EVER missed a deadline, and there was NEVER EVER a chance
of missing a deadline, then who needs an operating system?  That would
mean that you have a system that was perfectly consistent, and never
had any types of interrupts or problems which could cause a system to
fail.  That latter type of system can be built purely in hardware.  However,
very few such systems exist.  Most systems allow users to interrupt a
process, of if there is a hardware problem, (such as on a production
line if a piece of machinery breaks down), something out of the ordinary
must be done.  It is situations like these which require some type of
'Emergency' action to perform if a deadline is missed.  In the first
example of the robot & conveyor belt,  what happens if the robot is
late?  Do you stop the conveyor belt?  Do you back it up?  Do you
turn on a light on the operators console, so that he can manually
remove the piece?  Do you send a message to the next robot in the system
so that it reacts accordingly?  And in the case of the Airplane ...
Do you just try to complete the calculation as quick as possible?  Do
you abort the calculation, and just start over?  In any type of reliable
and predictable system, this type of deadline scheduling with emergency
action is a necessity.  Most real-time operating systems do not provide
such features, which was one of the prime motivations for us to write
our own Real-time operating System.  [A multi-processing system with
low-overhead interprocessor communication was another the other
prime motivation.]


The best article that I have seen describing 'What are Real-Time Systems'
is one written by John A. Stankovic, from the University of Massachusetts.
The article is entitled, "Misconceptions about Real-Time Programming", and it
was published in the IEEE publication "Computer", October 1988.  It is
well worth the reading.


>Like running "rn" is real-time. 


The answer is No.  'rn' doesn't have any 'deadlines' or timing constraints
to be met.  Of course, a user would like to have the fastest possible
response, but whether an operation takes 0.1 seconds, 1 second, or 10 seconds,
the end result is the same, and the system is not considered to have failed.

>Therefore isn't Unix already
>real-time without it having to be added to the kernel?

UNIX does not give any accurate form of incorporating time into a system.
The sleep() and usleep() are the closest things to time that UNIX offers,
but it is nowhere close to meeting the requirements of real-time control
systems.


I hope the above discussion will arouse more interest into Real-Time Systems,
and answer some of the questions people have about real-time systems.

~dave
--
David B. Stewart, Dept. of Elec. & Comp. Engr., and The Robotics Institute, 
	Carnegie Mellon University,  email: stewart at faraday.ece.cmu.edu 
The following software is now available (public domain); ask me for details
        CHIMERA II, A Real-time OS for Sensor-Based Control Applications
-- 
David B. Stewart, Dept. of Elec. & Comp. Engr., and The Robotics Institute, 
	Carnegie Mellon University,  email: stewart at faraday.ece.cmu.edu 
The following software is now available (public domain); ask me for details
        CHIMERA II, A Real-time OS for Sensor-Based Control Applications



More information about the Comp.unix.wizards mailing list