RTLinux is a
hard realtime
Real-time computing (RTC) is the computer science term for hardware and software systems subject to a "real-time constraint", for example from event to system response. Real-time programs must guarantee response within specified time constrai ...
real-time operating system
A real-time operating system (RTOS) is an operating system (OS) for real-time applications that processes data and events that have critically defined time constraints. An RTOS is distinct from a time-sharing operating system, such as Unix, which m ...
(RTOS)
microkernel
In computer science, a microkernel (often abbreviated as μ-kernel) is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, ...
that runs the entire
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
as a fully
preemptive process. The hard real-time property makes it possible to control robots, data acquisition systems, manufacturing plants, and other time-sensitive instruments and machines from RTLinux applications. The design was patented.
Despite the similar name, it is not related to the
Real-Time Linux
The Linux Foundation (LF) is a non-profit technology consortium founded in 2000 as a merger between Open Source Development Labs and the Free Standards Group to standardize Linux, support its growth, and promote its commercial adoption. Additi ...
project of the
Linux Foundation
The Linux Foundation (LF) is a non-profit technology consortium founded in 2000 as a merger between Open Source Development Labs and the Free Standards Group to standardize Linux, support its growth, and promote its commercial adoption. Additi ...
.
RTLinux was developed by Victor Yodaiken, Michael Barabanov, Cort Dougan and others at the
New Mexico Institute of Mining and Technology
The New Mexico Institute of Mining and Technology (New Mexico Tech and formerly New Mexico School of Mines) is a public university in Socorro, New Mexico. It offers over 30 bachelor of science degrees in technology, the sciences, engineering, man ...
and then as a commercial product at FSMLabs.
Wind River Systems
Wind River Systems, also known as Wind River (trademarked as Wndrvr), is an Alameda, California–based company, subsidiary of Aptiv PLC. The company develops embedded system and cloud software consisting of real-time operating systems software, ...
acquired FSMLabs embedded technology in February 2007 and made a version available as Wind River Real-Time Core for
Wind River Linux
Wind River Systems, also known as Wind River (trademarked as Wndrvr), is an Alameda, California–based company, subsidiary of Aptiv PLC. The company develops embedded system and cloud software consisting of real-time operating systems software, ...
. As of August 2011, Wind River has discontinued the Wind River Real-Time Core product line, effectively ending commercial support for the RTLinux product.
Background
The key RTLinux design objective
was to add hard real-time capabilities to a commodity operating system to facilitate the development of complex control programs with both capabilities.
For example, one might want to develop a real-time motor controller that used a commodity database and exported a web operator interface. Instead of attempting to build a single operating system that could support real-time and non-real-time capabilities, RTLinux was designed to share a computing device between a real-time and non-real-time operating system so that (1) the real-time operating system could never be blocked from execution by the non-real-time operating system and (2) components running in the two different environments could easily share data. As the name implies RTLinux was originally designed to use Linux as the non-real-time system
but it eventually evolved so that the RTCore real-time kernel could run with either Linux or
Berkeley Software Distribution
The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
(BSD)
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
.
Multi-Environment Real-Time
Multi-Environment Real-Time (MERT), later renamed UNIX Real-Time (UNIX-RT), is a hybrid time-sharing and real-time operating system developed in the 1970s at Bell Labs for use in embedded minicomputers (especially PDP-11s). A version named Duple ...
(MERT) was the first example of a real-time operating system coexisting with a Unix system. MERT relied on traditional virtualization techniques: the real-time kernel was the ''host'' operating system (or
hypervisor
A hypervisor (also known as a virtual machine monitor, VMM, or virtualizer) is a type of computer software, firmware or hardware that creates and runs virtual machines. A computer on which a hypervisor runs one or more virtual machines is calle ...
) and Bell Systems Unix was the ''guest''. RTLinux was an attempt to update the MERT concept to the PC era and commodity hardware. It was also an attempt to also overcome the performance limits of MERT, particularly the overhead introduced by virtualization.
Instead of encapsulating the guest OS in a virtual machine, RTLinux virtualized only the guest interrupt control. This method allowed the real-time kernel to convert the guest operating system into a system that was completely preemptible but that could still directly control, for example, storage devices. In particular, standard drivers for the guest worked without source modification although they needed to be recompiled to use the virtualization "hooks". See also
paravirtualization
In computing, paravirtualization or para-virtualization is a virtualization technique that presents a software interface to the virtual machines which is similar, yet not identical, to the underlying hardware–software interface.
The intent o ...
. The Unix ''
pipe
Pipe(s), PIPE(S) or piping may refer to:
Objects
* Pipe (fluid conveyance), a hollow cylinder following certain dimension rules
** Piping, the use of pipes in industry
* Smoking pipe
** Tobacco pipe
* Half-pipe and quarter pipe, semi-circula ...
'' was adapted to permit real-time and non-real-time programs to communicate, although other methods such as shared memory were also added.
From the programmer's point of view, RTLinux originally looked like a small threaded environment for real-time tasks plus the standard Linux environment for everything else. The real-time operating system was implemented as a
loadable kernel module
In computing, a loadable kernel module (LKM) is an object file that contains code to extend the running kernel, or so-called ''base kernel'', of an operating system. LKMs are typically used to add support for new hardware (as device drivers) and/ ...
which began by virtualizing guest interrupt control and then started a real-time scheduler. Tasks were assigned static priorities and scheduling was originally purely priority driven. The guest operating system was incorporated as the lowest priority task and essentially acted as the idle task for the real-time system. Real-time tasks ran in kernel mode. Later development of RTLinux adopted the Portable Operating System Interface (
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
)
POSIX threads
POSIX Threads, commonly known as pthreads, is an execution model that exists independently from a language, as well as a parallel execution model. It allows a program to control multiple different flows of work that overlap in time. Each flow of ...
application programming interface (
API
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
) and then permitted creation of threads in user mode with real-time threads running inside guest processes. In multiprocessor environments threads were locked to processor cores and it was possible to prevent the guest thread from running on designated core (effectively reserving cores for only real-time processing).
Implementation
RTLinux provides the ability to run special real-time tasks and interrupt handlers on the same machine as standard Linux. These tasks and handlers execute when they need to execute no matter what Linux is doing. The worst case time between the moment a hardware interrupt is detected by the processor and the moment an interrupt handler starts to execute is under 15 microseconds on RTLinux running on a generic x86 (circa 2000). A RTLinux periodic task runs within 35 microseconds of its scheduled time on the same hardware. These times are hardware limited, and as hardware improves RTLinux will also improve. Standard Linux has excellent average performance and can even provide millisecond level scheduling precision for tasks using the POSIX soft real-time capabilities. Standard Linux is not, however, designed to provide sub-millisecond precision and reliable timing guarantees. RTLinux was based on a lightweight virtual machine where the Linux "guest" was given a virtualized interrupt controller and timer, and all other hardware access was direct. From the point of view of the real-time "host", the Linux kernel is a thread. Interrupts needed for deterministic processing are processed by the real-time core, while other interrupts are forwarded to Linux, which runs at a lower priority than real-time threads. Linux drivers handled almost all
I/O. First-In-First-Out pipes (
FIFO) or shared memory can be used to share data between the operating system and RTLinux.
Objective
The key RTLinux design objective is that the system should be transparent, modular, and extensible . Transparency means that there are no unopenable black boxes and the cost of any operation should be determinable. Modularity means that it is possible to omit functionality and the expense of that functionality if it is not needed. And extensibility means that programmers should be able to add modules and tailor the system to their requirements. The base RTLinux system supports high speed interrupt handling and no more. It has simple priority scheduler that can be easily replaced by schedulers more suited to the needs of some specific application. When developing RTLinux, it was designed to maximize the advantage we get from having Linux and its powerful capabilities available.
Core components
RTLinux is structured as a small core component and a set of optional components. The core component permits installation of very low latency interrupt handlers that cannot be delayed or preempted by Linux itself and some low level synchronization and interrupt control routines. This core component has been extended to support SMP and at the same time it has been simplified by removing some functionality that can be provided outside the core.
Functions
Most RTLinux functions are in a set of loadable kernel modules that provide optional services and levels of abstraction. These modules include:
# rtl sched - a priority scheduler that supports both a "lite POSIX" interface described below and the original V1 RTLinux API.
# rtl time - which controls the processor clocks and exports an abstract interface for connecting handlers to clocks.
# rtl posixio - supports POSIX style read/write/open interface to device drivers.
# rtl fifo - connects RT tasks and interrupt handlers to Linux processes through a device layer so that Linux processes can read/write to RT components.
# semaphore - a contributed package by Jerry Epplin which gives RT tasks blocking semaphores.
# POSIX mutex support is planned to be available in the next minor version update of RTLinux.
# mbuff is a contributed package written by Tomasz Motylewski for providing shared memory between RT components and Linux processes.
Realtime tasks
RTLinux realtime tasks get implemented as
kernel module
In computing, a loadable kernel module (LKM) is an object file that contains code to extend the running kernel, or so-called ''base kernel'', of an operating system. LKMs are typically used to add support for new hardware (as device drivers) and/o ...
s similar to the type of module that Linux uses for drivers, file systems, and so on. Realtime tasks have direct access to the hardware and do not use virtual memory. On initialization, a realtime task (module) informs the RTLinux kernel of its deadline, period, and release-time constraints.
Threads
RT-Linux implements a POSIX API for a thread's manipulation. A thread is created by calling the
pthread_create
function. The third parameter of
pthread_create
is a function which contains the code executed by the thread.
It is necessary to set thread priorities in RTLinux. Threads with higher priorities can preempt threads with lower priorities. For example, we can have a thread controlling a stepper motor. In order to move the motor fluently, it is necessary to start this thread in strictly regular intervals. This can be guaranteed by assigning a high priority to this thread. The example threads2.c sets different thread priorities. Setting of thread priority is done by code shown below:
int init_module(void)
The output the program is as follows.
Thread 1 started
Thread 2 started
Thread 3 started
Message: this is thread 1
Message: this is thread 2
Message: this is thread 2
Message: this is thread 2
Message: this is thread 1
Message: this is thread 1
Message: this is thread 3
Message: this is thread 3
Message: this is thread 3
The thread 2 has the highest priority and the thread 3 has the lowest priority. The first message is printed by the middle priority thread 1 because it is started a short time before the thread 2.
See also
*
RTAI
Real-time application interface (RTAI) is a real-time computing, real-time extension for the Linux kernel, which lets users write applications with strict timing constraints for Linux. Like Linux itself the RTAI software is a community effort. ...
. RTAI began as a variant of RTLinux called "MyRTlinux" and in later releases was claimed by its authors not to use the patented RTLinux virtualization technique.
*
RMX (operating system)
Real-time Multitasking eXecutive (iRMX) is a real-time operating system designed for use with the Intel 8080 and 8086 family of processors.
Overview
Intel developed iRMX in the 1970s and originally released RMX/80 in 1976 and RMX/86 in 1980 to ...
*
SCHED_DEADLINE
SCHED_DEADLINE is a CPU scheduler available in the Linux kernel since version 3.14,
Linux Weekly News, Deadline scheduling for Lin ...
*
Xenomai
Xenomai is a real-time development software framework cooperating with the Linux kernel to provide wikt:pervasive, pervasive, interface-agnostic, hard real-time computing support to user space application software seamlessly integrated into the Li ...
*
Preemption (computing)
In computing, preemption is the act of temporarily interrupting an executing task, with the intention of resuming it at a later time. This interrupt is done by an external scheduler with no assistance or cooperation from the task. This preempt ...
*
Linux on embedded systems
Operating systems based on the Linux kernel are used in embedded systems such as consumer electronics (eg. set-top boxes, smart TVs and personal video recorders (PVRs)), in-vehicle infotainment (IVI), networking equipment (such as routers, sw ...
*
Real-time testing Real-time testing is the process of testing real-time computer systems.
Software testing is performed to detect and help correct bugs (errors) in computer software. Testing involves ensuring not only that the software is error-free but that it ...
References
Sources
Dougan, Cort (2004), "Precision and predictability for Linux and RTLinuxPro", Dr. Dobbs Journal, February 1, 2004Yodaiken,Victor (1997), US Patent 5,995,745
External links
Article about RTLinux synchronization''A Real-Time Linux'' Victor Yodaiken and Michael Barabanov, New Mexico Institute of Technology
*
{{Microkernels
Linux kernel variant
Real-time operating systems