Real-Time Operating System (RTOS)

A Bit of Background

A high priest tending to his shrine
A high priest tending to his shrine (Source: Silicon.co.uk)

The idea or concept of an operating system originates from the early 1960s. This was the era of “big iron” or mainframe computers.

Initially, computers were used much like programmable calculators. Computers ran a single computational task for one user at a time. Each user with a computational task would first code an algorithm for the task and then bring the program to the computer department, typically as a stack of punched cards or a roll of paper tape.

The “high priests” serving the machine would then enter the user’s program into the machine and start the calculation. The program ran until it finished with results or crashed. The results of a calculation were typically presented as printed sheets with text.

Evolving out of a need to streamline these manual tasks were operating systems.

Essential Operations

Modern operating systems perform many essential functions. The following are some of them (in decreasing order of importance):

  • Scheduling
  • Memory management
  • Supporting a file system
  • Networking
  • Providing an application programming interface (API)

Scheduling

Scheduling is about when and how to allocate computational resources to different tasks and users. This is especially important in multitasking and real-time systems. Some computational resources are one of a kind. For example, a single CPU cannot be used by more than one task at a time.

In an attempt to optimize performance and shuffle priorities, scheduling algorithms have been extensively studied in academia and software development projects.

Memory Management

Operating systems act as the
Operating systems act as the "go-between" guy (Source: MiniTool)

Memory management is another critical function in operating systems such as Windows, Mac, and Linux. Modern operating systems utilize virtual memory addressing, where each application appears to have its own unified address space consisting of various types of memory, like RAM and mass storage (i.e. hard disk or SSD).

If virtual addresses are used, they must be translated to real addresses in order to access memory. The OS takes care of this by means of a specific piece of hardware, the memory management unit (MMU), which is nowadays integrated into the CPU. The MMU also protects the address space of each application from being overwritten by other applications and crashing the application.

Microcontrollers, in general, don’t have an MMU and hence cannot run Linux and similar OSs. However, newer microcontrollers in the ARM Cortex-M family include a memory protection unit (MPU). This is akin to a simplified MMU and provides some of the same benefits, like protecting the memory space of a task against corruption by another task.

APIs

An OS greatly simplifies the implementation of applications by presenting an application programming interface (API), which is an abstract model of the computer system and hardware. Without an API, each application would need to include its own code for common tasks like as writing to a file and communicating with peripherals. This would be a highly inefficient and needless duplication of efforts. With an API, the application only needs to issue a system call, and the OS then handles all the unpleasant and complicated details.

Back to Contents

Advertisement
Advertisement
Real-Time Operating System (RTOS)

RTOS Basics

An Arduino thermometer project
An Arduino thermometer project (Source: Arduino Project Hub)

Who Needs an OS?

Many embedded microcontroller applications don’t actually need an OS at all. An example would be a simple thermostat. First, the microcontroller would read the actual temperature from a sensor. Then, it would switch a heater on if the actual temperature is less than a target temperature. Otherwise, the heater is switched off.

For applications like this, where the tasks are few and simple, an operating system isn’t needed. Indeed, any OS imposes an additional load on its system’s resources, leaving less available for the application itself.

On the other hand, in an embedded system with many tasks of different priorities and time constraints, a real-time OS can be beneficial or even necessary.

What Is Real Time?

Wikipedia defines a real-time operating system (RTOS) as “an operating system in which the time to process an input stimulus is less than the time lapsed until the next input stimulus of the same type.” This is an often-quoted definition.

Furthermore, RTOSs are usually characterized as “hard” or “soft”. This has to do with the consequences of missing a deadline in responding to a stimulus or an event. In a hard RTOS, the consequences could be catastrophic, for example in aircraft flight control systems or self-driving cars. In soft RTOSs, a missed deadline might well have a negative impact on something but cause no disaster.

Back to Contents

Advertisement
Advertisement
Real-Time Operating System (RTOS)

RTOS Characteristics

WinAVR, a popular development tool
WinAVR, a popular development tool (Source: yogee1707 via Instructables)

When considering an RTOS, it’s worthwhile to pay attention to a few details and important characteristics.

Licensing

Commonly seen with RTOSs, “open source” seldom means “completely free”, even if the products and related intellectual properties are available without payment. In most cases, there are some albeit minor restrictions in using the product.

This is all spelled out in the license terms. They’re often not very significant for one-off projects, but they may be worth reading for larger-scale or commercial deployments.

Support

Board support packages with ready-to-use examples are very good for starting a project rapidly and smoothly without too much trouble.

Development Tools

An integrated development environment (IDE) is a toolset for developing embedded applications. This includes at least a code editor, compiler, and debugger. Sometimes other tools are also included, like a code library.

Protocols

In the Internet of things (IoT), most devices are interconnected by wireless networks. More recent RTOSs include protocol stacks for several types of wireless networks: WiFi, Bluetooth, and Bluetooth Mesh, LoRa, etc.

Back to Contents

Advertisement
Advertisement
Real-Time Operating System (RTOS)

Noteworthy RTOSs

An RTOS presented as a collection of modules
An RTOS presented as a collection of modules (Source: Micrium)

RTOSs are available in a bewildering variety – more than any other kind of OS. A Wikipedia listing presents nearly 200 RTOSs divided into different categories according to types of licenses (open source or proprietary), application areas, development status, and so on.

Open source is obviously the preferred license type for maker projects and casual experimentation, as it comes with the advantage of being free. On the other hand, there is usually no direct support from the OS developer. Users are thus limited to community support (if it exists), good documentation, and easy-to-install examples. Some open-source RTOS providers offer commercial-level support against a monthly payment or other similar schemes.

Several RTOSs started out as proprietary products but were later released into the public domain. The RTEMS operating system is one such example, with an interesting history starting in the 1980s. Originally an acronym for “Real-Time Executive for Missile Systems”, RTEMS was then relabeled “Real-Time Executive for Military Systems” and finally “Real-Time Executive for Multiprocessor Systems”.

Looking at more recent open-source RTOS offerings, the most interesting ones are clearly targeting IoT applications and include enhanced support for easily connecting a device to a cloud platform such as Amazon Web Services (AWS) or the IBM Watson IoT Platform.

To illustrate many of the aspects discussed here, let’s take a look at three well-known RTOS examples:

  • Mynewt, developed by the Apache Software Foundation
  • FreeRTOS, with 15 years of development by Real Time Engineers and managed since 2017 by Amazon
  • Mbed OS, one part of the comprehensive Mbed ecosystem for the rapid development of IoT devices using the ARM Cortex-M microcontroller family

Back to Contents

Advertisement
Advertisement
Real-Time Operating System (RTOS)

Mynewt

Adafruit nRF52 BLE board with Mynewt
Adafruit nRF52 BLE board with Mynewt (Source: Adafruit)

The open-source Mynewt OS is in active development under stewardship by the Apache Software Foundation. Apache advertises itself as the “world’s largest open-source foundation,” with more than 39,000 volunteers contributing code to hundreds of projects.

Mynewt is especially strong when it comes to wireless protocols. It offers a Bluetooth Low Energy (BLE) 5.0 stack and Bluetooth Mesh support. LoRa and LoRaWAN protocols are supported as well.

Details

  • License: Apache 2.0
  • Kernel size: 6 KB
  • Wireless protocols: BLE 5, BLE Mesh, LoRa, LoRaWAN, 6LoWPAN
  • Other communications protocol: CoAP
  • Security: Secure bootloader
  • Development tools: Newt Tool
  • Microcontroller architectures: ARM Cortex-M0 to M7, MIPS, RISC-V
  • Board support: Approx. 40 boards from 10 manufacturers

Back to Contents

Advertisement
Advertisement
Real-Time Operating System (RTOS)

FreeRTOS

FreeRTOS is used in association with AWS
FreeRTOS is used in association with AWS (Source: Mahavir Jain via Medium)

FreeRTOS was developed by Real Time Engineers, an organization located in Bristol, UK. In 2017, stewardship for further development was transferred to Amazon, which also provides a version of FreeRTOS with libraries for IoT support, specifically for AWS.

FreeRTOS is also available in two other special variants. Commercial licensing is available in the form of OpenRTOS, and for safety-critical systems, a version called SafeRTOS is available, developed by Wittenstein High Integrity Systems (WHIS), a FreeRTOS partner that specializes in safety.

Details

  • License: MIT License, commercial licensing also available for OpenRTOS
  • Kernel size: Depends on the configuration, min. 9 KB
  • Wireless protocols: Wi-Fi, BLE
  • Other communications protocols: Not specified
  • Security: SafeRTOS (security-qualified variant)
  • Development tools: Support for more than 15 toolchains
  • Microcontroller architectures: More than 40 options, including ARM Cortex-M0 to M7, MIPS, and RISC-V
  • Board support: Approx. 55 boards from 8 vendors

Back to Contents

Advertisement
Advertisement
Real-Time Operating System (RTOS)

Mbed OS

The conceptual architecture of Mbed OS 6
The conceptual architecture of Mbed OS 6 (Source: Arm Mbed)

The Mbed OS is one part of a comprehensive ecosystem for the rapid development of IoT devices based on the ARM Cortex-M microcontroller family. Mbed includes a toolchain and IDE for online use (the Mbed Online Compiler), which is based on ARM default tools, such as the version 6.14 compiler. Alternatively, GNU tools can be used instead of ARM tools.

In addition to the online IDE, there is also a desktop version, Mbed Studio, available for Windows, Linux, and Mac. The development tools can also be used via a command-line interface (CLI).

The documentation includes many examples and tutorials.

Details

  • License: Apache 2.0
  • Kernel size: Depends on the configuration
  • Wireless protocols: Wi-Fi, BLE, BLE Mesh, LoRa, LoRaWAN, 6LoWPAN sub-GHz Mesh, cellular
  • Other communications protocols: Ethernet, NFC, RFID
  • Security: ARM PSA, ARM Pelion (for device management)
  • Development tools: Mbed Online Compiler, Mbed Studio, CLI, many third-party tools
  • Microcontroller architectures: Cortex-M0 to M7
  • Board support: Approx. 170 boards from 30 vendors

Back to Contents

Advertisement
Advertisement
Advertisement