Categories
operating systems rtlinux software business systems

The Embedded Enterprise, Pruit-Igoe, Ayn-Rand, the telecommunications stack and why software does not suck

Programmers will readily tell you that “Windows sucks” or “Linux sucks” or “POSIX sucks” why this or that software is badly designed, bloated, slow, buggy, un-needed, ugly, and generally disgusting. But, Windows is actually an immensely useful and sophisticated program with astounding capabilities – Linux is too. POSIX is a comprehensive solution to many difficult problems. These programs and APIs are widely used because they solve real problems. Large, complex, “high capability” software is never as simple and clean as it seems like it should be to programmers, but I think that’s because the Le Corbusier fallacy is so hard to resist. It is possible, with some effort and skill, to write a prototype Operating System or Data-base or web browser that is fast, lean, clean, and beautifully structured. But the demands of the applications will conflict with the clean etc. design and force all sorts of changes. The Le Corbusier fallacy is the belief that the aesthetics of the architect trump the sloppy requirements of the mere users. In actual architecture, this belief results in unlivable high rise slums , but in programming we get either failed projects or “prototypes” that don’t actually serve any purpose. Programmers are too ready to dismiss working code that actually does something useful because they are entranced with imagined clean, pure, designs. I’m certainly not arguing against designing software or in favor of sloppy design, far from it. Software design must be motivated by external considerations – the utility of the software, not by some internal idea of what is “clean”.

The telecommunications stack we have been building and starting to deliver to customers is an unbelievably complex software structure that is capable of incredible feats. Imagine a Windows application, using .Net and SQLServer that maintains customer data, a SuSe Linux based Oracle SS7 application, a fault tolerance and remote maintenance scheme running on Carrier Grade Linux, and large number of pedal-to-the-metal RTLinux POSIX threads maintaining VOIP connections – all on a single multicore multiprocessor connected by shared memory with TCP/IP running over it. This system is not something that can be easily captured in some whiteboard drawing of boxes. It’s a city, not a housing project.

Categories
rtlinux software business

Back from India

We were going into a government facility in Mumbai, and the guard points at me and asks, as if finding it hard to believe “He is a foreigner?” This was my fourth visit to India and, like all the others so far, mostly a rushed series of meetings and trips to airports, but I got to meet a lot of smart people, hear about some amazing projects, and even saw some northern Western Ghats as we drove from Puni to Mumbai – mountains are always good.

We started in Bangalore just as Diwali ended (flying in at night, the fireworks were awesome) for the Embed Asia conference at the beautiful campus of the Indian Institute of Science. Professor S.K. Sinha took me on a whirlwhind tour of the EE department where a mere 12 layer board is just part of a student project and the race for the sub-$100 laptop is on. If only they did projects like that at US computer science departments these days instead of specializing in advanced grant grubbing and similar topics. I also saw some great robotics projects in the Embedded Systems lab at IIT Mumbai where my one-time Ph.D. advisor, Prof. Krithivasan Ramaritham has now become a Dean. The embedded lab projects have to do with automatic cruise control. I want to see one of the auto-rickshaws driving through Mumbai on automatic control, but believe it would require major breakthroughs in computer science and quantum physics.

India reminds me of Lew Wallace’s famous exit line as he fled New Mexico back in the 1800s. Maybe it has something to do with chilis. (Photo is Ramesh and Ramana at Puni Reservoir)

Categories
operating systems rtlinux software business systems

Soft real time continues to sag

Paul McKenney once wrote:

Despite such complications, priority inheritance works reasonably well for exclusive locks, and is a major component of Ingo Molnar’s CONFIG_PREEMPT_RT patch. There are strongly held opinions both for and against priority inheritance, for example. http://www.linuxdevices.com/articles/AT7168794919.html

in which Victor Yodaiken considers priority inheritance to be harmful, and, as near as I can tell, soft realtime to be irrelevant. […] The big advantage of priority inheritance is that it is simple for its users. Use of priority inheritance does degrade scheduling latency compared to a carefully hand-crafted solution, and priority inheritance’s implementation is difficult for reader-writer locks, to say nothing of memory allocation or communications primitives.Nevertheless, priority inheritance does seem to have a significant role to play in mainstream “metal hard” realtime. It is not perfect, but, then again, what is?

And I think this is a good summary of the differences between the “soft”( muddle through) and “hard” (design properly) approaches to real-time. In FSMLabs design approach, “simple for users” is good, but not good enough to overcome “doesn’t work reliably”. Priority inheritance itself is not a big deal: we can add it, and have added it, as a more complicated mode for mutexes when needed to make legacy code port. But in our world, correctness is more important than convenience. Perhaps only highly qualified engineers who understand timing should write real-time code directly: others can use pre-made components or automatic tools (like Matlab simulink) or wait until there are more advanced test tools. The idea of using an engineering technique known to be incorrect simply because it is convenient, is I think an indication of the weak state of software engineering. This same caution applies elsewhere: the effects of kernel programmers trying to write web pages or source code management methods on the fly are also not pretty. It would be convenient if I could develop data base systems without understanding data base theory – but I can’t. McKenney’s “despite such complications” follows a note of some of the fatal problems I had covered in the cited article and elsewhere – but a solution to these problems is nowhere found.

The weakness of the soft real-time approach results in the weakness of the PREEMPT_RT systems in Linux (although it is clear that the developers are starting, finally, to copy a working solution – RTLinux and to slowly abandon their design.) Anyways, a draft analysis of what is wrong with PREEMPT_RT can be found here. Although I doubt McKenney is consciously modifying his argument on the basis of the business model of his employer, it is interesting to consider who profits from a technology that requires customers to both purchase large amounts of engineering services (to tune and configure) and to over-specify hardware.

Categories
operating systems rtlinux systems

Soft real-time and soft design strategies versus QOS

[ see revised version ]

(edited August 18 2007 to add back link and formatting)

“Soft real-time” is a perfect example of the “soft design” I was complaining about in the previous post. There are perfectly good ways of characterizing quality of service assurances. For example, you could say that the average = x and there are no outliers more than n standard deviations from the mean. Or you could state that over any interval of time t seconds there will be at most n delays of more than E milliseconds or so on. But soft real-time is usually characterized by a lot of handwaving. Doug Jenson has a semi-precise definition:

The general case of a deadline (which is a soft deadline) has utility measured in terms of lateness (completion time minus deadline), tardiness (positive lateness), or earliness (negative lateness). Larger positive values of lateness or tardiness represent lower utility, and consequently larger positive values of earliness represent greater utility.

That is, he says a soft real-time system will have a function

0 =< Utility(Deadline, Error) =< 1

where, for my purposes Error > 0 for a late computation and Error < 0 for an early computation. But, but, and but, you never see the utility functions in discussions of so-called “soft real-time” systems because very few quality of service (QOS) systems have a nice linear function. If you are playing videos, then there will be a big difference between requirements for editing (which may permit no frames later than 100 microseconds) and consumer viewing which will be a moving target but may allow up to 1 frame more than 1 millisecond late over a second but no more than 1 frame more than 20 milliseconds late over 10 seconds or something like that. Why don’t we see these kind of measures for soft real-time systems? Because, in practice, in order to make any QOS assurances, you need to be able to make hard assurances. If one frame is 1.5 milliseconds late, you have to guarantee that the next frame won’t be late by more than 100 microseconds and so on. So, in practice, “soft real-time” means doesn’t really work, but I haven’t measured it.

Soft-real-time is not the same as QOS. QOS is defined against some specification. Soft-real-time has no more technical meaning than “fast”.


Technorati Profile

Categories
operating systems rtlinux systems

Programming design style

Someone needs to come up with a slick name for “designed to fail during test instead of production” or for the more common “soft” type of programming. When we write code, we assume we screwed up somewhere, an assumption based on years of bitter experience (well, we assume someone screwed up, maybe in the tools, maybe in the spec, maybe in hardware that comes with 10G of obscure errata, or maybe even now and then someone else in the company). In any case, we test and fix. We design code to fail on the slightest suspicion that something is not right – so our tests can catch failure. Soft programming is full of palliatives that have the effect of causing catastrophes. Here’s an example: out of memory process killers in page allocators. The idea is that when memory becomes too tight, some randomly chosen (or heuristically chosen, comes to the same thing) process is terminated to make room for the others and to prevent deadlock. Somewhere down the line the OOM Killer will kill exactly the wrong process at exactly the wrong moment – because, contrary to what OS developers think, the applications are the purpose the the whole system. That somewhere down the line is improbable but inevitable. So OOM Killers make it unlikely that tests of OOM conditions will find the worst case. That seems exactly wrong. You should want your tests to find every possible flaw as soon as possible so that you can root them out of your released code. Is that so wrong?

Categories
operating systems rtlinux software business systems

The embedded enterprise

It is now possible to put together sophisticated and powerful embedded and control systems that are mostly composed of pre-existing working software. One of the demonstrations we showed at AMD’s recent embedded workshop was a small two processor (4 core) box running RTLinux and Windows XP. Embedded development teams for RTCore based products can mirror the decoupling of the RTCore architecture – one team can do the low level control application and other teams can work on all the non-time-dependent “enterprise” software. A printer controller might be developed by connecting a real-time component under RTCore that talks to sensors and actuators, a database and remote update/maintenance subsystem under Linux and an operator interface running under Windows XP. These three components can be developed independently by different teams as long as architects have correctly designed the interfaces. The RTCore component on current Opterons can guarantee either sub 10 microsecond or 1 microsecond worst case interrupt latency – depending on whether you share the processor core with Linux or dedicate a processor core to real-time. The Linux application could be made web accessible using Apache, for example, with a backend database either MySQL or Oracle or even DB2. The Windows application can go right to the video and our experience is that the double buffering of the Linux file system and Windows itself improves performance when running a virtualized windows kernel. A Sun Java application on the Linux side may connect to C# under Windows on one side and C++ or C executing in the RTCore environment on the other.

Let’s look at two example applications – a printer and an automobile “infotainment” system. One way to build a printer is as a system [FPGA: RTCore: Management: Operator] where RT software in RTCore manages a controlling FPGA on one side (that manages the sub microsecond requirements of the hardware) and provides paths for the Linux based Management and Windows based Operator subsystems to submit commands and get data. For a lighter infotainment system, perhaps using a single processor, we might need [Devices: RTCore: Display] where the RTcore component acts as a device accelerator, replacing dedicated hardware (such as a smart MPEG ) with software, a Windows based Display manages multimedia, and Linux is just used essentially as a BSP.

Security can be easily improved by making the three components cross check each other. For example, a remote update connecting to the Java based server under Linux may ask the Windows based and Rtcore based components to cross check certificates. An attacker would have to deal with three different operating system environments working together. Reliability can also be improved – e.g. by having Rtcore force a reboot of Linux or Windows if progress is not being made.

The underlying theme here which shows how far this new type of embedded software has moved from the traditional “hand crafted” embedded development process. Programmers have large functional components available to use in development instead of starting from the traditional impoverished low level embedded environment. The implications for both productivity and creativity are significant.

Categories
operating systems rtlinux systems

multicore and virtualization and real-time provisioning

We added the “reservation” capability to RTCore real-time POSIX threads a couple of years ago. Normally, the client platform operating system shares the processor with RTCore threads as a completely pre-emptible low priority thread. This works exceptionally well. Worst case interrupt latencies of under 10 microseconds on Opterons and under 20 on Arm9s are possible – and this is worst case under load and measured over days or weeks not the usual lipstick-on-pig numbers common in the industry. For timer driven threads, we can make these times better by wasting a little compute time using the timer advance feature of RTCore, but for true “every microsecond matters” pedal-to-the-metal hard real-time, processor reservation is the way to go and the widespread availability of multi-core processors makes the case more compelling. Reservation works by making a processor core disappear from the view of the symmetric multiprocessing (SMP) client operating system so that only real-time threads run there. Reservation on RTCore is a mature technology that has been in use production systems for years. Interrupts are redirected, cores can be rebruceserved and unreserved dynamically, reservation works for user-space memory protected real-time threads and each real-time core runs its own cleanly separated real-time scheduler. The performance improvements are dramatic on true multiprocessors and nearly as dramatic on multi-core. With multi-core processors, we can start treating processor cores as allocatable resources. Consider a 2 core system where Windows XP runs under a virtual machine and real-time threads reserve the second core – executing out of L2 cache. The screen-shot in this note shows XP running while a real-time thread runs the “jitter” test on the second processor. Because processor reservation is designed within the POSIX API and on the basis of the “decoupled real-time” paradigm at the heart of RTCore, it offers the same interface for SMP and multi-core and has scaled up to multi-core along with the client operating systems.

Categories
operating systems rtlinux software business systems

Single core cell phone solution and marketing vs engineering

FSMLabs is finally able to discuss the single core cell phone handset solution we developed with Infineon Technologies last year. This system is cool technology – literally – since it allows parts count reduction on the handset and that reduces power consumption and that reduces heat production. More to the point, in a volume driven business, removing some hardware components phoneis big news. I hope that some of the “no software royalties” hard liners will now pause and consider why paying royalties (or a production license) in order to not have to ship chips and batteries for those chips may be, you know, profitable.

The technology is very interesting. Essentially, we squeeze a lot of performance out of an ARM9 – making it jump back and forth between user interface, radio control, and wireless stacks. Turns out, the ARM9 is up to the job – it was being held back by poorly designed software.

There have been many product announcements of the imminent release of Linux based single core cell phone solutions. I think that in this industry people sometimes forget that there are hard technical problems. Just having a visionary CEO say “make it so” and let loose the loudly singing marketing flock doesn’t actually get the bits to move right. Our software worked because of the smart engineering effort of Cort Dougan, Michael Barabanov, and Zwane Mwaikambo and the engineers they supervised and the work of the engineers at Infineon and also the excellent evaluation work done by Infineon engineering management that allowed them to avoid the mistake that everyone else made in searching for paths to this product. (of course there is a lot more to the phone than FSMLabs work, but RTLinux is agile enough to move the processor to the right place at the right time.)

Categories
operating systems rtlinux

Microkernels and why academic OS research is boring

Andy Tanenbaum writes a defense of microkernels that (1) misses the content of Linus Torvald’s critique, (2) ignores the most relevant paper on software development, David Parnas’ Software Jewels paper, and (3) pretends RTLinux does not exist. The problem with microkernels is that they are not modular and the problem with all the “nearly ready for prime time” microkernels is that they are not real products and the problem with many new academic OS projects is that they don’t have much new in them.

Parnas asks why we don’t see more elegant, simple, kludge-free “jewels” in systems software and he, rather gently, explains the compatibility, time pressures, and other constraints that make “clean and lean” so elusive. Parnas is just too nice to hammer the point home. Anyone can write small fast clean operating system that doesn’t do anything useful. Over and over, researchers stumble on the discovery that as you add minor inessential feature after minor inessential feature (all in response to some importuning victim who actually needs to do something with your creation), you recreate the “bloat” that wasn’t needed when your software didn’t do anything. In fact, the natural result of making a nice clean simple lean fast OS into something useful is the creation of another implementation of POSIX. VMS and then Windows NT are very POSIX like, despite the intentions of the designers and so is Mach in OS-X and so are many traditional RTOSs. After all this time, this should not be so surprising anymore.

Linus Torvald’s response to Tanenbaum is pretty clear, but Tanenbaum misses the point:

Linus also made the point that shared data structures are a good idea. Here we disagree. If you ever took a course on operating systems, you no doubt remember how much time in the course and space in the textbook was devoted to mutual exclusion and synchronization of cooperating processes. When two or more processes can access the same data structures, you have to be very, very careful not to hang yourself. It is exceedingly hard to get this right, even with semaphores, monitors, mutexes, and all that good stuff.

My view is that you want to avoid shared data structures as much as possible. Systems should be composed of smallish modules that completely hide their internal data structures from everyone else. They should have well-defined ‘thin’ interfaces that other modules can call to get work done. That’s what object-oriented programming is all about–hiding information–not sharing it. I think that hiding information (a la Dave Parnas) is a good idea.

And this gets both Torvalds and Parnas wrong. Information hiding is only good design when the hidden information is not needed by the software it is hidden from! If you hide information that you need to share you’re just wasting time. A great example of real modularity is the splitting off of the command interpreter (first in CTSS (corrected)) from the kernel. This split is possible because the designers recognized that there is very little information exchange between kernel and interpreter. An example of a fake module is the attempt of most microkernels to split virtual memory paging and storage caching. The most elegant and efficient message passing interface that can be imagined cannot fix the problem that too much information must be shared to make the resulting monstrosity run properly. Here’s Torvalds

The fundamental result of access space separation is that you can’t share data structures. That means that you can’t share locking, it means that you must copy any shared data, and that in turn means that you have a much harder time handling coherency. All your algorithms basically end up being distributed algorithms.

And Tanenbaum’s response is that sharing data structures is hard! Well, yeah – many engineering systems are complicated and hard to do right. During the 30 years of development of CTSS, Multics, UNIX, Plan9, and Linux, many components were split off into modules. What remains cannot be broken into decoupled parts in any obvious way. Let no man or woman split what Dennis and Ken have wrought without a damn good reason. Until the hardware changes or someone discovers something new about software structure in operating systems, complaining that this kernel model is complicated seems as useful as complaining that petroleum refineries are too big and filled with chemicals. The POSIX model is a high performing engineering design – it works well and it is just perverse to assume its success is due only to the ineptness of everyone else.

It would be very interesting to study a production operating system like Linux or Windows XP and try to discover hidden modularity – functions that appear to not need to be bound to each other. Do such functions exist? Perhaps – one was discovered only a decade ago. The basis of RTLinux is the recognition that “real-time” can be separated from a time-sharing kernel and put into a module that can operate in a decoupled manner. The result was immediately useful but RTCore, the RTLinux real-time kernel, does not correspond to any of the traditional “modules” advocated by microkernelistas. There is no reason to suppose more such unconventional modules cannot be found. If we keep going back to the same boring list of “modules” that are familiar to generations of students forced to look at that ridiculous layer cake picture of an operating system, however, we’ll keep getting the same lack of results and the same “almost as fast as, almost complete” projects.

Note: RTLinux has been property of WindRiver Systems since 2007

Note2: Here’s a more abstract look at modularity.

Note 3: 2019 – I should have also said something about loadable kernel modules.

Categories
operating systems rtlinux software business

GreenHills, foreigners, and the gummi bear threat

When GreenHills launched their anti-Linux offensive, they crossed a line – and I doubt they even knew it. To cast doubt on the value of Linux in critical applications, GreenHills tried to create a scare about the nationality and “loyalty” of engineers working on Linux. This is stupid on three levels. First, software security is an engineering property, not something passed on like a, a, well, a virus. There are established methods for vetting security, by test, by inspection of the design, and by inspection of the design process – none of these involves the visa status of the developers. Second, software is the flagship international product and has been since that Hungarian fellow von Neumann was working in Princeton. Maybe things look different in Santa Barbara, but in the rest of the world, software development is something that discriminates on the basis of talent and work and not anything else. Aldrich AmesFinally, it’s absurd to think that software companies can vett their employees better than government security agencies and we know that those agencies can employ people who work for the other side for years. Does Dan O’Dowd stalk around the GreenHills office looking for subtle signs of disloyalty and contraband? I tried to do that here, but other than Matt’s bag of gummi-bears, I saw nothing life threatening. Xenophobia is a poor substitute for solid engineering and it is a more real danger than hypothetical undercover programmers putting trojan horses into unsuspecting software.