2.8 Operating Systems Abstraction Layer

MPLAB Harmony v3 supports multiple RTOS. Each RTOS has its own API call to create tasks, run the scheduler, semaphore, or mutex handling. To enable the compatibility of MPLAB Harmony v3 drivers in a non-RTOS environment (Bare-Metal) and across various RTOSs, MPLAB Harmony v3 provides an abstraction layer known as Operating Systems Abstraction Layer (OSAL). OSAL supports a minimal feature set that was abstracted from many different RTOS products for maximum compatibility. The focus of the OSAL is providing the minimum set of mechanisms necessary for safe operation of libraries in a multi threaded environment.

Primary OSAL Features

The OSAL features are as follows:

  • Mutexes: Used to manage the ownership of resources, therefore can only be accessed exclusively by a single thread at a time
  • Semaphores: Primarily used to synchronize between different threads
  • Critical sections: Used to protect a section of code, thus it must be executed atomically (uninterrupted or indivisibly)
  • Memory allocation: Used to support RTOS-specific memory management (Abstracts malloc and free if no RTOS-specific memory management)
  • Initialization and Information: OSAL support and OS information
Figure 2-6. OSAL and RTOS Mapping