Introduction to Real-Time System


In real-time system, “real-time” means executing high-priority tasks with minimum delay and all the task response time could be well predicted.

In this blog post, I would like to briefly discuss the real-time application and the real-time operating system for real-time systems.

Real-Time Applications

Many applications, especially non-critical applications, do not need to be served in real-time. For example, when we try to open a new website, the operating system might finish some other tasks that it thinks are more important before it open the website for you. Having some delay of opening the website and the response time of opening the same website varies each time usually do not have a huge impact on us.

Many applications need to be served in real-time, otherwise there will be dire consequences. For example, spaceship is a real-time application. When the speed of a spaceship is about to exceed a certain threshold, the power manager task must run immediately to shut off the power, otherwise the spaceship might have the risk of breaking down. The response time needs to be known and very deterministic so that the design of the application could take the response time into account. Otherwise, it is possible the spaceship will break down even if there is an unexpected additional delay of only several milliseconds.

SpaceX Falcon Heavy Recycle

For example, suppose the safe traveling threshold for a spaceship is $600,000$ m/h, and the response time of the task of shutting off the power is $1$ s. If we know the current spaceship traveling speed is the $580,000$ m/h, the acceleration is $10,000$ m/hs, the task of shutting off the power should be executed before the spaceship traveling speed reaches the $590,000$ m/h. Otherwise, when the power is shut off, the traveling speed will already be larger than the safe traveling threshold.

As we could probably tell, most of the real-time applications involve actuation in the real world.

Real-Time Operating System

Operating systems that were designed to serve real-time applications are real-time operating systems (RTOS).

It will assign priorities to different tasks, and its scheduling scheme is preemptive. In multi-task settings with an one-CPU system, when a high-priority task gets executed, the low-level task will be paused so that the high-priority task could be executed with minimum delay. The low-level task will resume once the high-priority task is done. The response time for the high-priority task and the low-priority task could be both well predicted since the the scheduling is deterministic.

RTOS Scheduling Scheme

Knowing the response time, every task has a specific deadline. The deadline can be a hard deadline, which the task should absolutely catch, or a soft deadline, which the task might miss, depending on the task property. If for whatever reason a task misses a hard deadline, the RTOS might just crash.

Developing an RTOS is all about designing and implementing the scheduling scheme, and making the system more real-time by reducing the overhead time for context-switch and preemption.

Typical RTOS includes QNX Neutrino, Zephyr, etc. Of course, Windows is not an RTOS.

Embeddings devices are used for many real-world real-time applications and therefore RTOS are widely used for embedding devices.



Lei Mao

Posted on


Updated on


Licensed under