comment on this article

From little acorns

It shouldn't be underestimated just how valuable free software has become.

The open source community is evolving: as entire sectors become dependent upon projects such as Android and other Linux derivatives, there is a distinct feeling that an invisible hand is on the steering wheel. It shouldn't be underestimated how valuable free software has become to the embedded engineering market, or surprising that large multinational companies are now highly active in the development of open source projects.

Take Android, for example. Not a week goes by without another Blue Chip company pledging allegiance to it. There are now several smartphones available which use the OS, free of charge and it is anticipated that Android will feature strongly in the burgeoning mobile internet device sector.

While Apple remains tight lipped about the OS used inside the iPad, one thing seems certain – it isn't Android. Nevertheless, it will probably be Android-based devices that will really provide the fillip needed to get this class of application off the ground. So does this mean that open source operating systems must now all be goliaths to be taken seriously – or at least have ambitions in that direction? It would appear not.

Despite the way in which it has evolved, the open source community remains a platform for enthusiasts. It strongly echoes the ethos behind the World Wide Web; openness and contributed wisdom. It's encouraging, then, to hear about a sapling open source project that could one day grow into a mighty oak.

It comes from an experienced engineer who, finding himself with some time on his hands, decided to develop a lightweight real time kernel. The incentive wasn't fame or fortune; rather, an altogether healthier desire to put his experience to good use and at the same time give something back to the open source community from which, he freely admits, he has drawn on himself during his career.

The developer is Kelvin Lawson and the kernel he has developed is Atomthreads. As all engineers will know, it isn't that difficult to find 'free' snippets of code on the internet. Most popular architectures will have official and unofficial sites that propagate free code and it is, again, something that isn't necessarily under the control of any particular individual.

Most semiconductor manufacturers will distance themselves from unofficial 'fan sites', as they provide something they couldn't hope to emulate with as much success; independent praise.

However, Lawson's development stands apart and although he maintains a respectful distance from manufacturers, his intention is to provide something of value, which not only complies with his high professional standards of quality, but which is also free for anyone to use.

The use of the word 'free' here is, as always when talking about software, important. Lawson has made Atomthreads available under the BSD licence, rather than the more popular GPL. "A lot of open source code is made available under GPL, which isn't ideal when deploying commercially," commented Lawson. He refers to the need to make the source code available under the terms of the license, something that can sometimes inhibit a competitive advantage. "With BSD, there are no restrictions or obligations," he added. It's clear that Lawson has devoted a lot of time and effort to the proposition of Atomthreads, but does it offer a convincing argument from a technical point of view?

Inspired by giants
Atomthreads is, as the name may suggest, a multithreaded real time scheduler. It offers what can be described as nominal functionality and doesn't purport to offer higher level functions – such as an IP stack or file system. Lawson admits these functions are often necessary. "In those instances, 99% of the time you would be better off using a heavy weight rtos," he accepted.

The positioning of Atomthreads isn't therefore straightforward. Its development was inspired by larger, commercially available, proprietary and open source rtos, while its goal was to be small, lightweight and powerful.

The result is a scheduler that is eminently suitable for use on a microcontroller and the initial offering targets the Atmel AVR/ATmega architecture. Lawson claims the reason behind this was based partly on the restrictions it would impose on him as a developer; being a small architecture meant Atomthreads would need to be commensurately small. However, Lawson does intend to support Atomthreads with ports to more powerful architectures, most notably to 16 and 32bit devices and, perhaps more interestingly, the ARM7 architecture.

Within a few days of its announcement, Lawson received four offers from individuals willing to port Atomthreads to other architectures – two of those offers were to port it to Texas Instruments' MSP430 family of ultra low power microcontrollers. The MSP430 has received considerable interest in energy harvesting applications and could feature strongly in intelligent sensor networks. A real time scheduler could provide the perfect software platform for application development.

Supporting an OS typically means developing drivers and Lawson maintains that most developers familiar with writing software for microcontrollers would be comfortable with the source code for Atomthreads – something that isn't necessarily true for other RTOSs, open source or otherwise. It would become necessary to develop drivers for Atomthreads in this case and Lawson believes the API he has developed and documented for Atomthreads would encourage even those developers with little or no experience of threaded kernels.

The direction Atomthreads takes from here is, Lawson admits, not clear. Judging from the initial interest, there could soon be a community of developers around the scheduler. If that happens, Lawson would look to develop an abstraction layer between the kernel and the drivers; an 'API for the API'. It would represent a new way of supporting an OS and, Lawson hopes, avoid creating an ecosystem that only supports specific ports of Atomthreads.

He cites other open source projects which now have vast libraries of drivers, each supporting the same operating system but for specific hardware platforms. The developer in Lawson sees this effort would entail needless repetition and is keen to avoid it. If he is successful, it could herald a new direction for open source communities in general. Unlike most 'free' code, Lawson has also gone to great lengths to provide an automated test suite, further evidence of his commitment to quality.

Perhaps the most encouraging indication that open source is still alive and well is that Atomthreads could inspire a new class of real time schedulers for tiny architectures, developed by experienced software engineers with the experience necessary to create a reliable and robust solution.

Atomthreads' features:
Atomthreads is a simple, small real time scheduler that uses semaphores in a round robin approach to service an unlimited number of threads with up to 255 priority levels (although this is extendable). The overhead involved with using Atomthreads is small; depending on the number of threads used and the frequency with which context switching takes place.

It isn't inconceivable to add Atomthreads to an existing code base targeting a microcontroller; if the code uses a well structured loop, implementing Atomthreads could be relatively straightforward and give much greater control over performance.

The flat structure of Atomthreads, contained within just a few C files, lends itself to easy adoption and simple porting.

Philip Ling

Related Downloads

Comment on this article

This material is protected by MA Business copyright See Terms and Conditions. One-off usage is permitted but bulk copying is not. For multiple copies contact the sales team.

What you think about this article:

Add your comments


Your comments/feedback may be edited prior to publishing. Not all entries will be published.
Please view our Terms and Conditions before leaving a comment.

Related Articles