Zibb

Feature

Embedded Linux nears real time

With new kernel updates and multiple latency-reduction options, Linux has become a viable alternative for many real-time-embedded-system designs.

By Warren Webb, Technical Editor -- EDN, 9/16/2004

AT A GLANCE
  • A newly released update to Linux delivers kernel pre-emption, improved scheduling, and a Posix (Portable Operating System Interface for Unix) for enhanced real-time performance.
  • Depending on the timing requirements, real-time-embedded-system developers can choose stock Linux or modified distributions with improved latency.
  • Several RTOS vendors provide Linux tools and support and promote their proprietary software for hard-real-time applications.
  • Concerns over open-source security, general-public-license contamination, and new legal challenges discourage some developers from taking the Linux plunge.

Although Linux has captured the imagination of embedded-device designers worldwide, commercial operating systems continue to dominate real-time applications. With a multiuser architecture, a non-pre-emptable kernel, and a scheduler based on fairness instead of priority, Linux forced developers to rewrite portions of it or install a second kernel to gain real-time features. Responding to these deficiencies, a dedicated Linux support community has recently delivered an updated kernel that incorporates many time-sensitive features and makes Linux suitable for a larger range of real-time applications.

As embedded projects move up to 32-bit processors to satisfy customer demands for more elaborate systems and sophisticated interfaces, many designs require a new operating system. Linux initially attracts designers because it is free to download, comes with full source code, and is compatible with a wide range of processors. A more detailed examination reveals modular architecture, user-friendly licensing, a worldwide support community, a reputation for reliability, a standard programming interface, free tools, and a mature, well-tested code base. Although these features are ideal for a large segment of the embedded-system world, the lack of precise timing in response to external events has been the biggest weakness for real-time applications.

The standard Linux kernel has not been suitable for real-time for several basic architectural reasons. For example, when a process calls a kernel service, such as the scheduler or a device driver, this call disables interrupts and makes it impossible to pre-empt Linux until the service completes execution. Likewise, the stock Linux scheduler uses a fairness algorithm that guarantees even the lowest priority process some CPU time, even though a higher priority process may be waiting. Although the timing is not predictable, Linux also relies on page swapping to move user code into and out of virtual memory.

To deal with these problems and make the kernel more responsive, the Linux support community has devised patches and workarounds that deliver deterministic performance. One approach has been to add pre-emption points within the kernel to reduce process latency and still protect critical code sections. For example, using MontaVista's modified Linux kernel, the worst-case pre-emption latency on typical embedded processors drops from hundreds of milliseconds to less than 1 msec, and the average pre-emption latency falls to tens of microseconds (Figure 1). A modified scheduler also ensures that the processor executes the highest priority tasks. Although these patches are imperfect, they offer a drastic improvement over the standard Linux kernel. The main drawbacks of these real-time modifications are that they are nonstandard and require unique support and reimplementation for each kernel update.

Two kernels, please

A second approach is to add a small real-time kernel to handle the high-priority tasks while Linux runs as the lowest priority to schedule the remaining, non-real-time tasks. This approach delivers the best real-time performance because it doesn't allow Linux to disable interrupts. RTAI (Real Time Application Interface) and RTLinux are two open-source projects that their developers based on the dual-kernel approach. Although the free version of RTLinux is still available, many recent improvements have gone into RTLinux/Pro, a proprietary version by FSMLabs. Disadvantages of dual-kernel architectures are that real-time tasks must run in kernel space, and the normal Linux-process-data isolation and -protection are nonexistent.

Embedded and real-time projects received a boost with the December 2003 release of Version 2.6 of the Linux kernel. Many of the real-time patches to Version 2.4 have become a permanent part of Linux and are standard build options. In this latest version, the kernel includes numerous pre-emption points that allow the scheduler to suspend an active task and initiate a higher priority process. Developers can also build a kernel without the page-swapping virtual-memory system that wreaks havoc on process timing. In addition, Version 2.6 includes a rewritten process-scheduler algorithm that speeds task switching in multitasking applications. Version 2.6 also includes improvements of the Linux Posix (Portable Operating System Interface for Unix) implementation. This set of programming-interface standards enables programmers to write application source code that is portable between operating systems. You can view the Posix specification at the Open Group Web site, www.unix.org.

In addition to the real-time improvements, Version 2.6 includes numerous updates that benefit embedded, desktop, and server applications. For example, Bluetooth and USB 2.0 enhance peripheral-interface options, the ALSA (Advanced Linux Sound Architecture) allows applications to process multiple audio streams, and Video4Linux adds a video subsystem. Another improvement for deeply embedded systems yields a smaller footprint build for applications with no user interface. Version 2.6 also adopts much of the uClinux (pronounced "you see Linux") project into the mainstream kernel. The uClinux project allows Linux to run on low-cost microcontrollers without memory-management units.

Although 2.6 is a major improvement for all embedded-system applications, several nontechnical issues still worry prospective new Linux users. For example, the SCO Group's legal challenge, claiming that Linux contains remnants of proprietary Unix code, could force changes to the kernel or even require royalty payments. You can find the latest information and a complete history of the SCO controversy at the Linux Online Web site, www.linux.org. The software community is also debating a potential security issue: Terrorists could contribute tainted software through the open-source-development process to possibly subvert Linux-based military and defense systems.

The user-friendly Linux licensing agreement has positive and sometimes negative consequences for embedded-system developers. On the positive side, you can download a free copy of Linux, adapt it to your product, and sell as many copies as you want without paying royalties. Still, Linux is not public-domain software; it is licensed under the GNU GPL (general-public license) with rules for its use. If you modify and distribute GPL software, your modifications automatically fall under the GPL, and you must give the source code to anyone who asks for it. Your application programs and device drivers may remain proprietary as long as they are separate and distinct from the Linux kernel and contain no GPL code. This code isolation is a constant source of anxiety among developers, especially those designing small-footprint embedded systems in which a ROM image links together all software.

Can't beat 'em

Concerned with the growing popularity of Linux for all types of embedded systems, many commercial-RTOS vendors have fashioned plans to join the open-source movement by providing tools and support and promoting their proprietary software for the hard-real-time applications. LynuxWorks was one of the first to take this approach by offering its own distribution: BlueCat Linux. The latest production release, Version 5.0, includes the Linux 2.6 kernel with its improved pre-emption, scheduling, and Posix capabilities. LynuxWorks provides compatible development tools and support services for Linux and the company's proprietary LynxOS software. For developers using Windows-based hosts, LynuxWorks offers VisualLynux, an extension of the Microsoft Visual Studio IDE that lets developers build either LynxOS or BlueCat Linux applications.

Wind River Software, the largest proprietary RTOS vendor, made news recently by announcing a partnership with Red Hat to jointly develop Red Hat Embedded Linux. Although it is not yet available, Red Hat Embedded Linux will initially target the COTS (commercial off-the-shelf) segment of the device-software market for carrier-grade network equipment, such as high-end routers and switches. Red Hat's Linux will be the foundation of Wind River Linux-based platforms; Wind River's development tools, middleware, and services will integrate Red Hat's Linux. Wind River admits numerous examples of multiprocessor systems in which designers use both Linux and VxWorks in telecom, aerospace, defense, and the high-end of the industrial-automation industries.

With an eye toward the multiblade, network-communications, and embedded-system market, Enea Embedded Technology has teamed with MetroWerks to provide a Linux platform-creation suite, CodeWarrior development tools for both Linux and Enea's OSE RTOS, a customer-specified board-support package, and licenses and support for both Linux and OSE. This combination allows developers to choose from OSE, OSEck for DSPs, and Linux, depending on the blade function. Enea also offers a transparent message-passing gateway that provides communications among applications irrespective of the operating system. Enea's basic tool set, the Orchestra platform-development suite, is available now on an annual-subscription basis for $4995 per developer per project.

The development-tool segment of the embedded-system market is especially important to real-time applications. Although all Linux implementations use versions of the same kernel and core GNU-compiler collection tool chain, they are configured differently and require additional support software, depending on the platform and the application. Adopting the trend toward graphical or visual interfaces, several tool vendors have integrated their offerings into the graphical, open-source Eclipse development platform (www.eclipse.org), which simplifies tool discovery, integration, and execution. For example, the TimeStorm development and testing environment from TimeSys is a Linux-, Windows- and Solaris-based development tool set that gives you control over creating, editing, compiling, managing, and debugging C/C++/Java embedded and real-time applications (Figure 2). TimseSys tools are available individually on a node-locked or floating-license basis. The TimseSys Time0storm IDE subelement plus the required first year of subscription support costs $5400.

Linux-ready hardware

Embedded-single-board-computer vendors are also teaming with Linux distributors to offer customers an off-the-shelf software package preconfigured for their hardware. For example, Kontron based its 6U, single-slot, CompactPCI CP605 CPU on the Pentium 4 processor (Figure 3). It is available in either a high-performance version, operating at 2 to 2.4 GHz, or a low-power-dissipation version, using the Mobile Pentium 4-M processor operating at 1.2 to 2.2 GHz. Besides two Gigabit Ethernet ports and one Fast Ethernet port, the board provides five USB 2.0 ports. The CP605 also supports the PICMG 2.16 packet-switching-backplane specification and provides a 32-bit, 33-MHz PMC interface. TimeSys offers a free board-support evaluation package for the CP605 and a complete software tool chain for Linux-application development.

An extended-temperature Arcom PC/104 single-board computer based on the 400-MHz PXA255 Intel XScale processor now supports the hard-real-time Linux operating system from FSMLabs (Figure 4). Arcom supplies the Viper board with an evaluation version of RTLinux/Pro, and FSMLabs also distributes the board with RTLinux/Pro preinstalled. The Viper features a flat-panel graphics controller, an audio controller, 10/100BaseT Ethernet, five serial ports, dual USB, digital I/O, onboard flash memory, and CompactFlash expansion. Prices for the Viper M16-F8, including 16 Mbytes of DRAM, 8 Mbytes of flash memory, and 256 kbytes of battery-backed SRAM, start at $435.

The new CELF (Consumer Electronics Linux Forum) industry group focuses on the advancement of Linux as an open-source platform for consumer-electronics devices. The recently released CELF Specification and Reference Implementation focuses on the improvement of Linux real-time characteristics to support audio and video feeds in devices such as set-top boxes, digital-video recorders, and videocameras. You can download a copy of the specification and reference implementation at www.celinuxforum.org. If you want more information on Linux for embedded systems, you can find an enormous amount of information on both open-source and commercial Linux products at www.linuxdevices.com. This site contains recent news, articles, and tutorials on Linux programming; lists of available distributions; and forums on embedded-system topics.

A range of successful and embedded commercial products are using Linux, and it is gaining traction in the real-time-system market. With a new kernel that emphasizes timing improvements and an enthusiastic development community, Linux will unquestionably appeal to a growing portion of the real-time-system market.

You can reach Technical Editor Warren Webb at 1-858-513-3713, fax 1-858-486-3646, e-mail wwebb@edn.com.

 

 


For more information...
For more information on products such as those discussed in this article, contact any of the following manufacturers directly, and please let them know you read about their products in EDN.

Arcom
www.arcom.com
Consumer Electronics Linux Forum
www.celinuxforum.org
Eclipse Project
www.eclipse.org
Enea Embedded Technology
www.ose.com
Finite State Machine Labs Inc
www.fsmlabs.com
GNU Compiler Collection
http://gcc.gnu.org
Kontron
www.kontron.com
LinuxDevices
www.linuxdevices.com
Linux Online
www.linux.org
LynuxWorks
www.lynuxworks.com
MetroWerks
www.metrowerks.com
MontaVista Software
www.mvista.com
Open Group
www.unix.org
Realtime Application Interface
www.aero.polimi.it/~rtai/
Red Hat Software
www.redhat.com
RTLinux
www.rtlinux.org
SCO Group
www.sco.com
TimeSys Corp
www.timesys.com
Wind River Systems
www.windriver.com
  



Reed Business Information Resource Center

Featured Company


Related Resources

ADVERTISEMENT

ADVERTISEMENT

Related Content

 

By This Author


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2009 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites