Thursday, November 02, 2006

Hard, Real-Time Linux vs. RTOSes

OK, I know that this topic has been addressed before, but times are a changin'. With the latest set of real-time patches being accepted into the 2.6.18 kernel, Linux is really becoming capable of hard, real-time performance. With the introduction of priority inheritance support and interrupt threads, we can now see a level of determinism that was previously only available in the RTOSes and real-time microkernels like RTLinux, RTAI and Akamai. The data that I've seen from real applications on real hardware (MP3 playback on 200MHz ARM) shows that the jitter seen even with the preemptible kernel patch is gone.

Interrupt threads are another capability that will drastically alter how drivers and the like are written. Think about it, what instructions of a processor *must* be executed from a hardware interrupt context? Return from Interrupt is about it. Now, if you could prioritize your interrupts, like we used to do on the VMEBus, and couple it with the ability to uniquely identify the source of an interrupt via a vector-like mechanism, you have interrupt threads and PCIe MSIs. We can use the O(1) scheduler to deterministically guarantee dispatch time of interrupts in the same way that we dispatch user threads.

Now, there will always be a need for small kernels on lower-end processors. There is a beauty to the sub-8K kernel running on a dedicated processor. But, the nature of the embedded business has changed drastically. It's rare to find a processor with less than 8MBs of RAM attached to it these days.

In fact, I've created usable, dedicated Linux systems with sub-300KB kernels and sub-second boot times. The typical arguments against Linux are evaporating in light of much of the work going on in the community today. This will only continue in the future.

Even with all of the improvements though, Linux is still slower than the real-time microkernels like RTAI and Akamai. But, only 2-3% slower in the tests that I've seen. If that 2-3% means that you miss your deadlines, then you've got much bigger problems on your hands. And, if you're building flight-control or medical hardware, you'd better stay with a DO-178 certified O/S -- at least for the time being.

Linux will never be all things to all people. I know that and you should too. But, when compared to Symbian, Micro$oft Windows Mobile or XP-Embedded and, in some cases, even QNX, LynxOS and even VxWorks, Linux looks pretty good. If you need to run on an ARM7 or 8051 with 64K of RAM, stay with ThreadX or C-Exec. But, if you're going to use any 32 or 64-bit processor with at least 4MBs of RAM, give Linux a look. You'll be surprised at what it can do these days.