Freertos Stack Overflow Hook [Closed]

According to FreeRTOS documentation regarding stack overflow:

The application must provide a stack overflow hook function if configCHECK_FOR_STACK_OVERFLOW is not set to 0. The hook function must be called vApplicationStackOverflowHook(), and have the prototype below:

void vApplicationStackOverflowHook( TaskHandle_t xTask,signed char *pcTaskName );

And in FreeRTOS the following prototype is defined inside tasks.h file:

 /* Callback function prototypes. --------------------------*/
 extern void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );

So, I set configCHECK_FOR_STACK_OVERFLOW to 2 and implement the function in my application code:

void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
{
    while (1)
    {
        /* my code. Prints stuff directly to the console*/
    }
}

My question is whether or not this implementation is correct? i.e, the hook implementation is in my application code, and the declaration in tasks.h remains untouched.

3

Looks right to me. You will find many, many, many examples in the FreeRTOS/Demo directory of the FreeRTOS download. The rationale for using 2 rather than 1 is here:

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest