RTOS Memory Model

Table of Contents

  1. Threads

mbed OS 2 and mbed OS 5

This is the handbook for mbed OS 2. If you’re working with mbed OS 5, please see the new handbook and API References. For the latest information about RTOS, please see the RTOS API. For the latest memory model, please see Memory Model.

Memory Model

  1. mbed Memory Model
  2. RTOS Memory Model

This is a basic overview of the memory model used by the mbed RTOS.

Threads

Each thread of execution in the RTOS has its separate stack.

When you use the RTOS, before explicitly initializing any additional thread, you will have 4 separate stacks:

  • The stack of the Main Thread (executing the main function).
  • The Idle Thread executed each time all the other threads are waiting for external, or scheduled events. This is particularly useful to implement energy saving strategies. (ie sleep).
  • The Timer Thread that executes all the time scheduled tasks (periodic and non periodic).
  • The stack of OS Scheduler itself (also used by the ISRs).
      +-------------------+   Last Address of RAM
      | Scheduler Stack   |
      +-------------------+
      | Main Thread Stack |
      |         |         |
      |         v         |
      +-------------------+
RAM   |                   |
      |                   |
      +-------------------+
      |         ^         |
      |         |         |
      |       Heap        |
      +-------------------+
      | ZI                |
      +-------------------+
      | ZI: Idle Stack    |
      +-------------------+
      | ZI: Timer Stack   |
      +-------------------+
      | RW                |  
      +===================+  First Address of RAM
      |                   |
Flash |                   |