Keil Logo

Stack Management

The Stack Management of the RTX kernel is designed for optimal memory usage. The RTX kernel system needs one stack space for the task that is currently in the RUNNING state:

  • Local Stack: stores parameters, automatic variables, and function return addresses. On the ARM device, this stack can be anywhere. However, for performance reasons, it is better to use the on-chip RAM for the local stack.

When a task switch occurs:

  • the context of the currently running task is stored on the local stack of the current task
  • the stack is switched to that of the next task
  • the context of the new task is restored
  • the new task starts to run.

The Local Stack also holds the task context of waiting or ready tasks.

Stack Management

The other stack spaces need to be configured from the ARM startup file. All tasks run in user mode. The task scheduler switches the user/system mode stack between tasks. For this reason, the default user/system mode stack (which is defined in the startup file) is used until the first task is created and started. The default stack requirements are very small, so it is optimal to set the user/system stack in the startup file to 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.