More about what an RTOS is

Problem

The bare metal architecture (ISR + background task) seen before does not provide solutions to the following needs:

  • Structure application code in several "independent" units of execution
  • Share data between these units
  • Handle different priorities
  • Ensure that time constraints are met (or not met)
  • Etc.

A solution

An RTOS.

More precisely

RTOS = OS intended for real-time applications.

  • Provides minimal latency when handling events
  • Guarantees predictable response time

Soft and hard real time

  • Hard real time: when a system will cease to function if a deadline is missed, which can result in catastrophic consequences
  • Soft real time: when a system continues to function even if it’s unable to execute within an allotted time. If the system has missed its deadline, it will not result in critical consequences. The system can continue to function, though with undesirable lower quality of output
Source: Intel

This presentation is about soft real time only.

Benefits

  • Provides a way to split application code in several execution blocks
  • Allows to prioritize execution blocks
  • Application architecture easier to design: several execution blocks can concurrently process events
  • Can reuse existing middleware (TCP/IP stack, flash file system, time handling, etc.) more easily
  • Provides a common reference framework for teams of several developers
  • Makes application code more portable (to different hardware targets)
  • ...

Drawbacks

  • Requires more flash memory (from a few KB to a few tens of KB)
  • Requires more RAM (fixed quantity + quantity depending on execution blocks)
  • Consumes some processing power (a few %)
  • Associated learning curve must be taken into account
  • Brings in a software dependency

Components

Usual components:

  • Scheduler - assigns computing resource to the execution blocks (tasks or threads)
  • Services allowing concurrent accesses to shared resources
  • Communication services letting tasks exchange data
  • Time services
  • Memory allocation services
  • Middleware: Wi-Fi stack, Bluetooth stack, TCP/IP stack, USB stack, flash file system, GUI, etc.

GUI: Graphical User Interface