|HOME||Embedded Computing||Real-time Operating Systems (RTOS)|
Definition: A real-time system is one in which the correctness of the computations not only depends on their logical correctness, but also on the time at which the result is produced. That is, a late answer is a wrong answer. For example, many embedded systems are referred to as real-time systems. Cruise control, telecommunications, flight control and electronic engines are some of the popular real-time system applications where as computer simulation, user interface and Internet video are categorized as non-real time applications.
Below we discuss a couple of known real-time systems.
Electronic Engine: Here comes a real-time system example. Consider a computer-controlled machine on the production line at a bottling plant. The machine's function is simply to cap each bottle as it passes within the machine's field of motion on a continuously moving conveyor belt. If the machine operates too quickly, the bottle won't be there yet. If the machine operates too slowly, the bottle will be too far along for the machine to reach it. Stopping the conveyor belt is a costly operation as the entire production will come to halt.
Thus the range of motion of the machine coupled with the speed of the conveyor belt establishes a window of opportunity for the machine to put the cap on the bottle. This window of opportunity imposes timing constraints on the operation of the machine. Software applications with these kinds of timing constraints are termed as real-time applications. Here, the timing constraints are in the form of a period and deadline.Periodic and Deadline-oriented Tasks
The period is the amount of time between each iteration of a regularly repeated task. Such repeated tasks are called periodic tasks.
In the above example, suppose bottles pass under the machine at a rate of five per second. This means a new bottle has to show up every 200 millisecond. Thus the period of the task is 200 millisecond. This is the timing constraints within which the system has to perform the assigned task successfully. That is, real-time system is one that has to meet the timing constraints to avoid any possible failure. Thus every periodic task has to be finished within the defined period. It does not mean that a real-time system has to act fast.
Every task has to be deadline-oriented. That is, every task has to be accomplished within the set deadline. The deadline is a constraint on the latest time at which the operation has to come the end. Suppose the window of opportunity in the above example is 150 millisecond. The deadline is then 150 millisecond after the start time of the operation. Here the start time is the moment at which the bottle enters the working range of the machine.
Cruise Control: Consider a cruise control mechanism on an automobile. The basic operation of cruise control is to keep the speed of the vehicle constant. Suppose the driver has selected 60mph as the desired speed. If the vehicle is going slower or faster than the selected speed, then the embedded computer sends a signal to the engine controller to set the speed right. The frequency in which the computer checks whether the current speed of the vehicle is as per the set speed is called control rate and it is fixed by the control system designer. The checking frequency, on one side, should meet specifications but on the other side, it should not be obstructive to system functioning.Aperiodic Tasks
All real-time tasks need not to be periodic. Aperiodic tasks respond to randomly arriving events. Consider anti-lock braking. If the driver presses the brake pedal, the car must respond very quickly. The response time is the time between the moment the brake pedal is pressed, and the moment the anti-lock braking software actuates the brakes. If the response time was one second, an accident might occur. So, the fastest possible response is desired. But, like the cruise control algorithm, fastest is not necessarily best, because it is also desirable to keep the cost of parts down by using small microcontrollers. The point here is the application has to specify a worst-case response time and both the hardware and software has to be designed to meet the specifications.Types of Real-time Systems
A application or system can be classified as either real-time or non-real-time. For a non-real-time system, there is no important deadlines, that is, all of its deadlines can be missed.
A real-time system can be further divided into soft and hard real-time system on the basis of severity of meeting its deadlines. A hard real-time system can not afford missing even a single deadline. That is, it has to meet all the deadlines to be branded as a hard one. Whereas a soft real-time system takes the middlepath between a non-real-time system and a hard real-time system. That is, it can allow occasional miss.
One example of a hard real-time system is a flight controller. If action in response to new events is not taken within the allotted time, it could lead to an unstable aircraft, which could, in turn, lead to a crash.
The cruise control application discussed above is one of the examples for a soft real-time system. Suppose the software fails to measure current velocity in time for the control algorithm to use it. The control algorithm can still use the old value as there will not be much difference between the new value and the old value and this difference will not make a very high impact.
Real-time systems can be predictable and deterministic. Actually these terms are almost the same. A predictable real-time system is one whose behavior is always within an acceptable range. The behavior is specified on a system-wide basis such as "all tasks will meet all deadlines". Generally, the period, deadline, and worst-case execution time of each task need to be known to create a predictable system. An appropriate scheduling algorithm with a corresponding schedulability analysis is used to ensure a system is predictable.
A deterministic system is a special case of a predictable system. Not only is the timing behavior within a certain range, but that timing behavior can be pre-determined. For example, a system can be pre-allocated time slots for each task. Each task gets executed only during those time slots. Such a time must have execution time for every task known, as well as no anomalies that might cause deviation from the pre-determined behaviorConclusion
Market analysis groups have come out with statistical evidence that there is a vast scope for embedded systems software business in the days to come. As almost all the embedded systems are categorized as real-time systems, it is natural that embedded systems have to satisfy all the above properties of a real-time system. Thus real-time system design methodologies and mathematical techniques are set to play a very critical role in shaping the emerging embedded systems software industry.