Keil™, An ARM® Company

RL-ARM User's Guide

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 os_stk_overflow() stack error function. The application will hang in an endless loop inside the stack error function. The variable task_id will contain the task ID of the task with the stack problem. You can 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
    

 

  • Enabled Stack Checking slightly decreases the kernel performance because on every task switch the kernel needs to execute additional code for stack checking.