Linux or RTOS?

Sebastian Floss

On the importance of choosing the right OS

If the question was “Linux, Windows or OSX?”, a follow up question would quickly be about the target audience and the applications that need to run on the OS. 

That’s because those three are all so-called General Purpose OS’es and the decision in favour of one of them, at least in a consumer context, is more about a personal preference than anything else.

Since this article is asking the question “Linux or RTOS?” (where RTOS stands for "Realtime Operating System), let’s first have a look at what aspects of an operating system we’re interested in when targeting an IoT device.

The two core functions that any OS needs to be able to perform are :

  1. abstracting the hardware to a generalised level and providing services for simplifying development of a device’s utility functions
  2. providing a way of running several tasks or processes “simultaneously”  

What sets the plethora of available Operating Systems apart now is the availability of drivers for certain hardware and also the way the higher level abstraction is presented to application developers in form of software frameworks or libraries. Regarding the ability to schedule tasks there really only is a difference in the way this happens and most times this will be looked at only if certain “hard” timing requirements have to be met.

Linux has a long history and a wide adoption base by hardware manufacturers, therefore there’s few chips and extension boards that won’t have a linux driver available which can easily be compiled in by just changing a configuration setting. 

Most RTOSes that are fit for IoT (the ones like FreeRTOS or ThreadX) don’t have that. The drivers come from the chip manufacturers or have to be written from scratch and then integrated by the developer.

Now why would I go with an RTOS then in the first place?

Well here’s the thing: Linux (and all the other “General Purpose” OSes) are multi-user systems, designed to run on machines where you can install (almost) any application that was build for that OS. And you can run multiple applications at a time. While this is good for the desktop/notebook/tablet/smartphone world, it comes at the price of certain requirements in hardware.

Any GPOS needs an “application processor” type of CPU like ARMs Cortex A series, that features a Memory Management Unit (MMU) and is able to provide each running application with its own virtual memory space. Those CPUs need larger amounts of DRAM to account for that and are much more power hungry than their Cortex M counterparts, so you can’t really run them on a battery for more than a couple of days. With that and the bill of materials in mind at this point you should start asking yourself: do I really need to run an extensible set of multiple applications on my IoT device? 

The answer should really only be yes if your device is more of a “platform” that will be serving as a base for third parties to run their applications on.

In any other case an IoT device should have a pretty well defined set of functions that it was built to carry out and this is the perfect application for a small RTOS that just takes care of task scheduling for you. Regarding the driver and framework part, don’t worry - there are plenty of them available, instead of just selecting them at compile time though, you will have to put it all together in your IDE. While it may be a little more work, it comes with the benefit that the developers really need to think about what they need and thus serve the most important IoT OS-Security requirement “disable any unused services” right from the beginning.

Of course there is plenty more reasons why anyone would go with either type of OS. The intention in this short article is to emphasise, that the OS choice should not be made light-heartedly. Just because there is no expert for a certain technology on your team, for example, should not be the pivotal reason.


ImagineOn

ImagineOn GmbH
Neusser Str. 27-29
50670 Köln

@imagineoncgn

Ein schönes Beispiel, warum Beratungsfirmen selten Ihre tollen Ideen auch umsetzen... #TrustworthyTechnology in der… https://t.co/jRAAIoskL1

+49 221 120 947-0

hi@imagineon.de