Documentation

Mistake on this page? Email us

Porting the RTOS module

Module scope

The RTOS module is responsible for real-time operating system functions, and provides:

  • Threads.
  • Semaphores.
  • Mutexes.
  • Timers and Time functionality.
  • Memory Pool and Memory Management.
  • Message Queue.
  • Atomic Increment.
  • Random Number Generation.

The pal_plat_rtos.h header declares the RTOS functions.

Warning: You must implement all of the RTOS functions for your port to succeed.

Prerequisites for this porting stage

For a successful port, a platform needs:

  • The ability to software-reboot the platform.
  • Hardware real-time clock (recommended).
  • The ability to get system ticks:
    • The tick is the OS (platform) kernel system tick counter.
    • The system tick frequency must meet the minimum requirements.
  • Atomic operations.
  • Hardware root of trust.
  • A random number generator source.
  • Real time clock (RTC).

Porting result

After successfully porting the RTOS module, all PAL RTOS tests need to pass. Please see the Tests section for more information.

Porting notes

This section covers non-trivial functionality that the platform needs for a successful port.

Threads

  • The RTOS module supports up to PAL_MAX_NUMBER_OF_THREADS threads, as defined in pal_configuration.h.

In code, please refer to:

palThread_t g_palThreads[PAL_MAX_NUMBER_OF_THREADS];

General notes

  • You can perform special initializations by implementing the pal_plat_RTOSInitialize() API.
  • PAL_RTOS_WAIT_FOREVER: A function with this value will wait for ever.

Reference implementations

PAL provides reference implementations for the following platforms and OSs:

Mbed OS

  • Main RTOS generic functionality: pal_plat_rtos.cpp.

    Located in the folder Source/Port/Reference-Impl/OS_Specific/mbedOS/RTOS.

Linux

  • Main RTOS generic functionality: pal_plat_rtos.c.

    Located in the folder Source/Port/Reference-Impl/OS_Specific/Linux/RTOS.

  • Additional board specific functionality, if any, for current OSs is in the Board_Specific folder under the relevant target platform name.

    Located in the folder Source/Port/Reference-Impl/OS_Specific/Linux/Board_Specific/TARGET_<Target name>.