CMSIS-RTOS2: Stack Requirements

| CMSIS-RTOS2 Version 2.1.3 Real-Time Operating System: API and RTX Reference Implementation

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Stack Requirements

Keil RTX v5 kernel functions are executed in handler mode (using PendSV/SysTick/SVC) and the tables below lists the maximum stack requirements for the Main Stack (MSP) that the user should consider.

The stack for the osKernelStart function is referred as "Startup" and RTX v5 uses 32 bytes (with Arm Compiler). However the user should also consider additional stack that might be allocated by the 'main' function of the embedded application. The following picture shows a worst-case memory allocation of the Main Stack.

Main Stack usage of RTX v5 applications

The stack requirements depend on the compiler and the optimization level. RTX v5 supports event annotations and this configuration impacts also the stack requirement.

Arm Compiler ARMCC V6.10: Main Stack requirements for PendSV/SysTick/SVC

Optimization | RTX Kernel | RTX Kernel + Event Recorder
--- | --- | ---
-O1 (Debug) | 152 bytes | 280 bytes
-Os (Balanced) | 120 bytes | 256 bytes
-Oz (Size) | 112 bytes | 248 bytes

Arm Compiler ARMCC V5.06: Main Stack requirements for PendSV/SysTick/SVC

Optimization | RTX Kernel | RTX Kernel + Event Recorder
--- | --- | ---
-O0 (Debug) | 176 bytes | 360 bytes
-O1 | 112 bytes | 248 bytes
-O2 | 112 bytes | 256 bytes
-O3 | 112 bytes | 248 bytes