Article: Introducing MediaLinux — a new real-time Linux approach
Nov 11, 2003 — by LinuxDevices Staff — from the LinuxDevices Archive — 4 viewsForeword: Last week, Softier made news with one of the first native ports of Linux to a Digital Signal Processor (DSP) architecture, introducing its “MediaLinux” and “MediaBIOS” for TI's DM64x DSP platform. In this article, Softier CTO Eatamar Drory and Senior Programmer Or Sagi discuss the unique approach to real-time processing that enables MediaLinux to run existing TI DSP algorithms untouched within the context of real time processes. Added benefits to this design include predictable scheduling and short interrupt latency. The article discusses key architectural points of the MediaLinux approach in comparison with two well-known alternatives.
by Eatamar Drory and Or Sagi
Softier's MediaLinux (GPLed) architecture is called “Symmetrical Hosting,” as there is no distinction between real-time and non-real-time processes. MediaLinux, a standard uClinux based kernel (currently 2.4.20), is hosted on the (non-GPL) MediaBIOS infrastructure.
MediaBIOS provides OS components, a BSP (board support package), run-time optimized utilities such as a relocatable COFF loader and flash utilities, VLIW optimized functions, and an interface to encapsulated media processing.
MediaBIOS was developed as a general purpose real-time media processing framework, enabling a wide variety of hosting operating systems to easily migrate to the unique architecture of TI's VLIW DSP.
MediaBIOS's design goal was to preserve TI's investment in media processing algorithms (Audio/Video) and to allow them to run unmodified based on compliance with TI eXpressDSP design rules. As a result, developers can take advantage of hundreds of available third party algorithms (such as MPEG1/2/4, MP3, AAC, etc.).
MediaLinux was designed to stay current with main-line Linux, rather than create a new modified branch. Its architecture is based on implementing every Linux process as a MediaBIOS task, such that there is no distinction between real-time and non-real-time tasks (the symmetrical approach).
This approach is illustrated next:
Figure 1: MediaLinux Real Time Approach — Symmetrical Hosting
Handling of real-time issues in Linux involves two consecutive paths of execution: the first path being from the event (interrupt, signal, etc) until entering the scheduler; the second path being from invocation of the scheduler until the corresponding real-time destination begins running.
MediaLinux's added real-time feature, “Context Agnostic Scheduling” (CAS), takes advantage of the symmetric OS implementation. This allows invocation of the MediaLinux scheduler from any context, yielding a constant guaranteed latency for the first scheduling phase of delivering an event. The actual implementation uses the underlying optimized MediaBIOS scheduler to perform the context switch under control of the Linux scheduler. This solves the latency issue of the first phase scheduling process. In the second phase of the scheduling process, kernel readiness issues to perform a context switch at any given point in time are addressed by standard Open Source industry preemption patches, which are also applicable to MediaLinux.
Key Points of the Symmetrical Hosting approach:
- Softier real-time design
- Every Linux process is implemented via an underlying MediaBIOS process
- No distinction between real-time and non real-time tasks (symmetric)
- All system resources including interrupt handling, are under Linux kernel control
- Includes “Context Agnostic Scheduling”
- Single OS (standard Linux)
- Can selectively employ “Preemption Improvement” kernel real-time patches
- Not an “Interrupt Abstraction”
The Alternatives
Preemption Improvement
The “Preemption Improvement” approach strives to reduce process latency and make the Linux kernel more responsive by introducing more preemption points. This is achieved by reversing the standard Linux preemption strategy, which prevents preemption unless specifically allowed. Instead, “Preemption Improvement” allows preemption at all times, unless a newly defined method, namely an extension of the current SMP “spinlock” mechanism, protects critical sections and prevents preemption. This approach is illustrated below:
Figure 2: Mainstream Linux Real Time Approach — Preemption Improvement
“Preemption Improvement” also incorporates modifications to interrupt handling. This permits preemption on return from interrupts; improving the scheduling time by introducing a new scheduling algorithm with a fixed overhead. It should be noted that this approach improves system responsiveness and reduces latency. However, it cannot guarantee true real-time latency characteristics, as the execution path is complex and prevents deterministic conclusions.
Key Points of the Preemption Improvement approach:
- Major contributors: MontaVista, TimeSys
- Allows scheduling on return from interrupt
- Based on controlled preemption prevention
- No distinction between real-time and non real-time processes
- Requires modifications to the Linux kernel code
- Typically a monolithic program that is tightly linked to specific machine dependent code
- Owns all of the processor resources (memory, I/O, interrupts, etc?)
Interrupt Abstraction
The “Interrupt Abstraction” approach distinguishes between those processes that are real-time and other Linux processes which are considered non-real-time. This is achieved by a dual kernel approach, where a real-time operating system (RTOS) is given control over all of the system resources. The RTOS runs all real-time tasks as higher priority tasks and the Linux OS is implemented as a single lower priority task in the RTOS space. This approach guarantees predictable interrupt response times by preventing the Linux kernel from disabling hardware interrupts.
The “Interrupt Abstraction” paradigm requires the use of new RTOS APIs to communicate between the RT and the non-RT processes. Some industry experts might consider these new APIs to be proprietary and or non-standard Linux, thus not conforming to the true “spirit” of Linux.
Bell Laboratories first introduced this layered OS approach as MERT (Multi-Environment Real-Time Operating System) in 1975. In 1997, FSM Labs introduced and patented another known variation of this approach, summarized by the following FSM Labs patent abstract:
“A general purpose computer operating system is run using a real time operating system. A real time operating system is provided for running real time tasks. A general-purpose operating system is provided as one of the real time tasks. The general purpose operating system is preempted as needed for the real time tasks and is prevented from blocking preemption of the non-real time tasks.”
Figure 3: The Interrupt Abstraction Approach
Key points of the “Interrupt Abstraction” approach:
- Major implementations: RTLinux, RTAI
- Distinction between real-time and non-real-time tasks (non symmetric)
- Interrupt handling removed from Linux control
- Real-Time tasks run in RTOS space, not Linux space
- Involves a Dual-Kernel approach
- System resources are under RTOS (non-Linux) control
Conclusions
In the past, using Linux in Embedded applications required an innovative approach to real-time processing due to the multi-user roots of the original kernel. Recent approaches such as “Preemption Improvement” and “Interrupt Abstraction” provided partial answers appropriate to a specific class of applications. MediaLinux's “Symmetrical Hosting” approach is different in that it is able to offer main-line kernel compatibility while maintaining real time characteristics. Developers of embedded applications can take advantage of the standard Linux programming environment while benefiting from the real-time characteristics of a Linux-controlled real time framework provided by the DSP infrastructure.
About the Authors: — Eatamar Drory is CTO of Softier, Inc. Or Sagi is senior programmer at Softier. Additional information about Softier is available on Softier's website.
This article was originally published on LinuxDevices.com and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.