Edoardo Barbieri
on 25 January 2024
Real-time Linux vs RTOS – Part I
Discover Real-time with our latest whitepaper: A CTO’s Guide to Real-time Linux
Welcome to this two-part blog series on Linux vs RTOS (Real-time Operating System). This series will explain the differences between achieving real-time requirements with a Linux kernel and doing the same with an RTOS.
Part I will explain the basics behind a real-time capable kernel running Linux vs RTOS. In Part II, we will delve deeper into the pros and cons of each approach and how to make an informed comparison between the two. Let’s get started.
What is real-time all about?
The demand for real-time capabilities is rising in the ever-evolving computing landscape, with forecasts indicating that nearly 30% of the world’s data will require real-time processing by 2025 [1]. To understand how to meet real-time requirements, it helps to have a clear definition of the concept.
“Real timeliness” is the ability of an Operating System (OS) to provide a required level of service in a bounded response time [2]. In a real-time system, not only does the correctness of a computation depend on the logical correctness of the result, but also on the time at which it produces it [3].
On the software side, alternative approaches are available to fulfil real-time requirements. Which one should your business adopt? Where should enterprises land on the Linux vs RTOS debate?
Real-time with Linux
Real-time computing via the Linux kernel is gaining traction as a valuable solution, especially in systems running the latest silicon, with precision and deterministic response times.
The concept of preemption lies at the core of real-time Linux. It involves interrupting the current thread of execution to process higher-priority events promptly. Deterministic response times are unattainable in Linux without kernel preemption. PREEMPT_RT, hosted at the Linux Foundation, is the de-facto Linux real-time implementation. While it doesn’t aim for the lowest latencies possible, it introduces mechanisms like priority inheritance and replaces locking primitives, making the Linux kernel preemptible with deterministic response times.
Real-time Ubuntu with the out-of-tree PREEMPT_RT patches, brings real-time capabilities to the forefront. Offering reduced kernel latencies as required by demanding workloads, Real-time Ubuntu provides a time-predictable task execution environment. Furthermore, Canonical supports the Real-time Ubuntu Linux kernel for over 10 years, enabling device manufacturers to focus on their business drivers.
Meeting real-time requirements with an RTOS
An RTOS provides an alternative to real-time Linux solutions. Unlike general-purpose operating systems. An RTOS focuses on deterministic response times and precise control over task scheduling. Enterprises often use an RTOS in mission-critical scenarios with extreme latency-dependent use cases, where a missed deadline results in system failure. An RTOS excels at managing task priorities, allowing critical tasks to take precedence over less time-sensitive processes. This prioritisation is crucial in scenarios where the system must guarantee operations will occur within a specific timeframe.
On the other hand, an RTOS’ suitability for applications in critical systems where any form of system failure is intolerable, may come with some drawbacks, which we will touch upon in Part II.
Is it always possible to achieve the “best performance” with either a real-time capable Linux kernel or an RTOS? And can development teams rest assured there is one clear choice between the two approaches depending on their systems’ requirements? Let’s find out.
Reducing latency with Linux vs RTOS
A real-time capable Linux kernel does not guarantee maximum latency because performance strictly depends on the system at hand. From networking to cache partitioning, every shared resource can affect cycle times and be a source of jitter. Every level can be a source of latency, from the hardware to the kernel and the application.
Similarly, even the most efficient RTOS can be useless in the presence of other latency sinks. Specific tuning for each use case is required, and an optimal combination of tuning configs for a particular hardware may still lead to poor results in a different environment. This means that one can’t guarantee a maximum latency “in the abstract”, as performance strictly depends on the specific system.
Making an informed choice between real-time Linux vs RTOS
The choice between RTOS and real-time Linux hinges on the specific latency requirements of a system, balancing the need for determinism, overhead, and resource efficiency.
While Real-time Ubuntu Linux with the PREEMPT_RT patch offers a robust solution for several scenarios, a dedicated RTOS may be preferable in a critical embedded system. A real-time capable Linux kernel is ideal for strong latency-dependent use cases but for extreme latency requirements an RTOS may be more suitable. Understanding the intricacies of both options is key to making an informed decision that aligns with a business’s demands and constraints.
Stay tuned for Part II of this mini-series, where we will discuss the relevant considerations to keep in mind when choosing between a Linux kernel or an RTOS in a real-time system.
Download the latest whitepaper on real-time Linux now!