Building "instant-up" real-time operating systems

Michael Dorin

May 18, 2008

Michael Dorin

Getting an operating system running on any new target system is always a challenge that could be made simpler if an embedded system developer had a way of getting a real-time operating system up and running in an "instant." Such an instant-up operating system (IOS) would need no more than some initial compilation with minimal hardware resources required.

This article describes three IOS environments:

1. The cooperative scheduler;

2. The Protothreads tool set, written by Adam Dunkels, described in detail on Protothreads' website www.sics.se/~adam/pt/, and

3. A blending of Protothreads with a cooperative real-time scheduler.

Many seasoned software developers have often faced this classic situation: the hardware team completes a new board and the software team needs to get something working on it. Likely a boot loader and a batch of test utilities will need to be written quickly. A multitasking operating system would sure be handy for this job, but porting a modern operating system will take time and is possibly overkill. The development schedule is likely several weeks behind and as a result, software is now the "brick wall"--there is no time for anything fancy.

Wouldn't it be nice to have an operating system running in an instant? And to have an operating system that doesn't require complex porting to new hardware? Or one that only needs to be compiled with the new target compiler in order to run?

Recently, while taking a real-time operating systems class at Metro State University in St. Paul, I learned about a cooperative scheduler based on work from Michael J. Pont (author of Patterns for Time-Triggered Embedded Systems) in which tasks can be created and executed at different priorities. An implementation of this scheduler produces an extremely small cooperative operating system, which is also very easy to port: an instant-up operating system (IOS #1).

About the same time, I was also introduced to Protothreads, written by Adam Dunkels. To quote from the website, "Protothreads are extremely lightweight stackless threads . . . ." They are written in C and "provide linear code execution for event-driven systems." Protothreads are a collection of C macros that give a simple way to have multiple threads running completely in C.

There are no worries about stack allocations or context switching, since the compiler does the heavy lifting. Protothreads provides a method to create threads that seemingly don't run to completion and give virtual concurrency. Protothreads, of course, don't give true concurrency, but threads can be organized as though they do. And Protothreads is easy to port. Voila! IOS #2.

Discovery of Protothreads got me wondering: what would happen if it were blended with a cooperative scheduler? Would this result in IOS #3, merging the virtual concurrency of Protothreads with the scheduling provided by the cooperative scheduler? I found that porting either of them is easy. Indeed, in the case of the cooperative scheduler, only a regular "tick" or timeout is required.

< Previous
Page 1 of 5
Next >

Loading comments...

Most Commented

Parts Search Datasheets.com

KNOWLEDGE CENTER