Keil Logo

Stack Size

The stack usage of a particular task depends on its amount of local automatic variables and the number of subroutine levels. On task switch, the RTX kernel stores also ARM registers on the stack. Devices with Hardware Floating Point unit need additional space for storing the VFP registers. The size of stack used for the context save is:

  • 64 bytes
    devices without Hardware Floating Point: ARM7, ARM9 without VFP unit, Cortex-M0, Cortex-M1, Cortex-M3, Cortex-M4 without Floating Point Unit, Cortex-R4 if floating point is not used.
  • 200 bytes
    devices with Hardware Floating Point: ARM9 with VFP unit, Cortex-M4 with FPU, Cortex-R4 if floating point is used.

The minimum stack size is thus the sum of the context save size, the size of local variables and the number of subroutine levels.

  • OS_STKSIZE specifies the amount of RAM allocated for the stack of each task. Stack size is defined in U32 (unsigned int). However, Configuration Wizard converts the specified size and displays it in bytes. Stack size with the following define is 400 bytes.
    #define OS_STKSIZE    100
    

Note

  • Interrupt functions do not use the stack of the interrupted task.
  • The Cortex-M4 tasks, where the Floating Point arithmetics is not used, do not store the additional VFP registers on context save. The context save for tasks with no Floating Point calculations is still 64 bytes.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.