Keil Logo

Stack Checking

It is possible that the stack is exhausted because of many nested subroutine calls or an extensive use of large automatic variables.

If Stack Checking is enabled, the kernel can detect the stack exhaustion problem and execute the system error function. The application will hang in an endless loop inside the error function with parameter err_code set to OS_ERR_STK_OVF. You can identify the task id with isr_tsk_get() function. Check the Active Tasks debug dialog for the task name.

The solution to this problem is to increase the stack size for all tasks in the configuration file. If only one task requires a big stack and RAM is limited, you can create this task with a user-provided stack space.

  • OS_STKCHECK enables the Stack Checking algorithm. It must be set to 1 to enable it or 0 to disable it. It is enabled by default.
    #define OS_STKCHECK    1
    

Note

  • Enabled Stack Checking slightly decreases the kernel performance because on every task switch the kernel needs to execute additional code for stack checking.
  • On stack overflow a runtime system error function is called.
  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.