Linux Kernel 2.6: the Future of Embedded Computing, Part II
In Part I of this article, we discussed three significant improvements--preemption points, an efficient scheduler and improved synchronization--have made the 2.6 Linux kernel the future of embedded computing. Here, we discuss further improvements and applications the 2.6 kernel offers embedded development.
USB 2.0, about forty times faster than conventional USB, makes its debut in Linux 2.6. The high speed USB devices support device bandwidth of up to 480 megabits per second, compared to 12 mbit/sec of current USB.
On the complete opposite end of the field, for the first time the kernel includes support that allows a Linux-powered machine to be a USB device rather than a USB host. This would allow, for example, your Linux-powered PDA to be plugged into your PC and to have both ends of the line speaking the proper protocol. Much of this support is new, but this is an essential direction for Linux to move into for embedded devices.
Wireless seems to be the buzzword today in the communication industry. Looking at the kind of research being carried out in such fields as pervasive computing, mobile computing and so on, the day is not far when the world becomes truly embedded and connected.
In the wireless networking space, support for both long-range devices--for example, AX.25 over amateur radio devices--and short-range devices--usually 802.11, but some older protocols exist--was updated during development of the 2.6 kernel. The largest change here is major components of the short-range subsystems for the various supported cards and protocols have been merged into a single wireless subsystem and API. This merge resolves a number of minor incompatibilities in the way different devices had been handled and strengthens Linux's support for the subsystem by making a central set of userspace tools that work with all supported devices. In addition to standardization, Linux 2.6 introduces a number of overall improvements, including better capability to notify in the event of a state change--such as a device that has a "roaming" state--and a change to TCP to better handle periodic delay spikes that occur with wireless devices.
In the wireless devices space, IrDA (the infrared protocol named for the Infrared Data Associates group) has received some advancements since the last major release, such as power management and integration into the new kernel driver model. The real advancements, however, have been made in providing Linux support for Bluetooth devices. Bluetooth as a protocol is designed to go anywhere and has been implemented in many devices ranging from PDAs, cell phones and printers to more bizarre things, such as automotive equipment. The protocol itself is made up of two different data link types: SCO (Synchronous Connection Oriented), for lossy audio applications, and L2CAP, (Logical Link Control and Adaptation Protocol), for a more robust connection supporting retransmits and so on. Both the SCO datalink for audio and the L2CAP for connection-oriented data transfers are available, making Linux a natural choice wherever no-fuss connectivity is a key requirement.
The human interface layer is the center of the user experience with a Linux system, including the video output, mice and keyboards. In the new version of the kernel, this layer has been reworked and modularized to a much greater extent than ever before. It now is possible to create a completely headless Linux system without any included support for a display or anything else. The primary benefit of this modularity may be for embedded developers making devices that can be administrated only over the network or serially. But end-users benefit too, as many of the underlying assumptions about devices and architectures has been modularized out.
Linux 2.6 also includes a number of smaller changes for human interaction. Touch screens, for example, now are supported. Linux also has changed the system request interface to better support systems without a local keyboard. The system request (sysrq) interface is a method for systems administrators at the local console to access debugging information, force a system reboot, remount filesystems read-only and do other wizardly things. Because Linux 2.6 now supports a completely headless system, it now is possible to trigger these events using the /proc filesystem. This support is available wirelessly, so the functionality could be performed from virtually any device.
Embedded systems sometimes are large systems of processors, as in telecom networks or mass storage systems, although there is some doubt whether they truly can be called embedded systems. Multiple processors share memory, either as symmetric or loosely coupled multiprocessors.
Symmetric multiprocessing designs are limited by making all memory equally accessible to all processors, making competition for memory the limiting factor in processing efficiency. Linux 2.6 provides a different way of achieving multiprocessing--it's called Non Uniform Memory Access, or NUMA. In NUMA, memory and processors are interconnected, but for each processor, some memory is close to that processor and other memory is farther away. Therefore, when memory contention occurs, the nearer processor has superior rights to the memory. The 2.6 kernel provides a set of functions that are aware of the memory/processor topology. The scheduler is able to use this information to favor tasks when they are using local memory, which reduces the memory contention bottleneck and enhances throughput. In addition, IRQ balancing has been improved significantly on multiprocessor systems through major changes to Linux's APIC support.
On the higher end of the spectrum are computers that provide exceptionally large resources, such as huge amounts of memory or high-throughput multiprocessors. These heavyweights have numerous embedded applications, such as mass data storage systems and special compute engines.
Embedded Linux developers who need huge amounts of memory have their choice of 64-bit microprocessors in Linux 2.6. The Intel Itanium 64 architecture was treated in previous releases of Linux, and support continues in 2.6. Linux 2.6 also continues to cover the AMD64 architecture by supporting the AMD Opteron microprocessor.
Improved support is available for other new Intel hardware features, including Intel's PAE (Physical Address Extension), which allows most newer 32-bit x86 systems to access up to 64GB of RAM but in a paged mode. Linux 2.6 support of PAE would be useful especially on systems that perform store-and-forward services for images, video and similar applications, in which large datasets must be handled quickly.
In addition to supporting new hardware features, internal limits also have been increased when possible. For example, the number of unique users and groups on a Linux system has been bumped from 65,000 to over 4 billion (16-bit to 32-bit), making Linux more practical on large file and authentication servers. Similarly, the number of PIDs (process IDs) before wraparound has been bumped up from 32,000 to 1 billion, improving application starting performance on busy and long-lived systems. Although the maximum number of open files has not increased, Linux with the 2.6 kernel no longer requires you to set what the limit is in advance; this number now self-scales. And finally, Linux 2.6 includes improved 64-bit support on block devices that support it, even 32-bit platforms such as i386. This allows for filesystems up to 16TB on common hardware.
Another major scalability improvement in Linux 2.6 is the kernel itself now can not only support more types of devices but also support more devices of a single type. Under all iterations of Linux , users and applications running on a system communicate with the attached hardware using numbered device nodes--the entries in the /dev directory. These device nodes were limited to 255 major devices (generally, one type of device gets one or more device nodes) and 255 minor numbers (generally, specific devices of that type.) For example, the /dev/sda2 device, the second partition on the first detected SCSI disk, gets a major number of 8, which is common for all SCSI devices It also gets a minor number of 2 to indicate the second partition. Different device types allocate their major and minor numbers differently, so it can't be said with assurance how many devices you can have on a Linux system. Unfortunately, this system breaks down badly on large systems where it would be possible, for example, to have many more than 255 of any specific device in a system, say, large storage arrays, print farms and so on. Under Linux 2.6, these limitations have been eased to allow for 4,095 major device types and a more than a million subdevices per type.
Although networking software is not related entirely to embedded software development, it is shipped along with every major OS in embedded and general market spaces. It plays an important part in defining the product's identity in the market.
Linux as an OS already supports most of the world's dominant network protocols, including TCP/IP (v4 and v6), AppleTalk, IPX and others. Like many of the changes in the other subsystems, most networking hardware changes with Linux 2.6 are under the hood and not immediately obvious. This includes low-level changes that take advantage of the device model and updates to many of the device drivers. For example, Linux now includes a separate MII (Media Independent Interface, or IEEE 802.3u) subsystem that is used by a number of the network device drivers. This new subsystem replaces many instances in which each driver was handling that device's MII support in slightly different ways and with duplicated code and effort.
On the software side, one of the most major changes is Linux's new support for the IPsec protocols. IPsec, or IP Security, is a collection of protocols for IPv4 (normal IP) and IPv6 that allow for cryptographic security at the network protocol level. And because the security is at the protocol level, applications do not explicitly have to be aware of it. This is similar to SSL and other tunneling/security protocols but at a much lower level. Currently supported in-kernel encryption includes various flavors of SHA (secure hash algorithm), DES (data encryption standard) and others.
Elsewhere on the protocol side, Linux has improved its support for multicast networking. Multicast networks are networks where a single sent packet is intended to be received by multiple computers. Primarily, this functionality is used by messaging systems, such as Tibco, and audio/video conferencing software. Linux 2.6 improves on this by now supporting several new SSM (Source Specific Multicast) protocols, including MLDv2 (Multicast Listener Discovery) and IGMPv3 (Internet Group Messaging Protocol.) These are standard protocols supported by most high-end networking hardware vendors, such as Cisco.
Linux 2.6 also has broken out a separate LLC stack. LLC, or Logical Link Control protocol (IEEE 802.2), is a low-level protocol used beneath several common higher-level network protocols, such as Microsoft's NetBeui, IPX and AppleTalk. As part of this change-over, the IPX, AppleTalk and Token Ring drivers have been rewritten to take advantage of the new common subsystem.
In addition to these large changes, a number of smaller changes also have been made. IPv6 has received some work and now can run on Token Ring networks. Linux's NAT/masquerading support has been extended to better handle protocols that require multiple connections, including H.323 and PPTP. On the Linux-as-a-router front, support for configuring VLANs on Linux is no longer experimental.
Again, this feature may not prove absolutely useful for smaller embedded devices, but it certainly matters in the case of distributed embedded systems. Overlaid on top of Linux's robust support for network protocols is Linux's equally robust support for network filesystems. In the Linux and UNIX-clone world, the most common of the network filesystems is the aptly named Network File System, or NFS. NFS is a complicated file sharing protocol. The primary transport protocol can utilize either TCP or UDP, but several additional sub-protocols also are required, each of which also runs on top of the separate RPC (remote procedure call) protocol. These include the separate mount protocol for authentication and NLM (network lock manager) for file locking.
In Linux 2.6, this core Linux filesystem received many updates and improvements. The largest of these improvements is Linux now experimentally supports the new and not widely adopted NFSv4 protocol version for both its client and server implementations. The new version supports stronger and more secure authentication (with cryptography), more intelligent locking, pseudo-filesystems and other changes. Not all of the new NFSv4 features have been implemented in Linux yet, but the support is relatively stable and could be used for some production applications. In addition, Linux's NFS server implementation has been made more scalable (up to 64 times as many concurrent users and a larger request queues), more complete (by supporting serving over TCP, in addition to UDP), more robust (individual filesystems drivers can adapt the way files on those systems are exported to suit their particularities) and more easily maintainable (management though a new nfsd filesystem instead of system calls.)
Other under-the-hood changes include separating lockd and nfsd and adding support for zero-copy networking on supported interfaces. NFS now is somewhat easier to secure by allowing the kernel lockd port numbers to be assigned by the administrator. The NFS client side also has benefited from a number of improvements to the implementation of the underlying RPC protocol, including a caching infrastructure, connection control over UDP and other improvements for TCP.
Linux 2.6 also includes improved support for the relatively new domain of distributed network filesystems, systems where files on a single logical volume can be scattered across multiple nodes. In addition to the CODA filesystem introduced in Linux 2.4, Linux now includes some support for two other distributed filesystems, AFS and InterMezzo. AFS, the Andrew filesystem, presently is restricted to read-only operations. The second newly supported filesystem, InterMezzo, also is newly supported under Linux 2.6. It allows for more advanced features such as disconnect operation, so you work on locally cached files, and is suitable for high-availability applications where you need to guarantee that storage is never unavailable or faked, when down. It also has applications for keeping data in sync between multiple computers, such as a laptop or PDA and a desktop computer.
Linux is easily the fastest growing operating system in the embedded world. The introduction of kernel 2.6 has boosted the use of Linux in real-time applications. It still does not come close to a real hard RTOS, and nursing such expectations is incorrect given the vast differences between the characteristics and requirements of general and real-time applications. But it can be expected that RTOSes with kernel 2.6 as the basic kernel now can compete with the biggies of the embedded world and offer the embedded developer community a reliable and free embedded operating system.
The Wonderful World of Linux 2.6, by Joseph Pranevich
Aseem R. Deshpande is a software engineer who studied at the University of Pune in India. He has been working as an embedded software developer for the past year and a half. His other interests include Grid computing and helping people to "fall". He can be contacted at email@example.com.