Homepage  

uxTaskGetStackHighWaterMark
[Task Control]

task. h
unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask );

INCLUDE_uxTaskGetStackHighWaterMark must be defined as 1 for this function to be available. See the configuration section for more information.

The stack used by a task will grow and shrink as the task executes and interrupts are processed. uxTaskGetHighWaterMark() returns the minimum amount of remaining stack space that was available to the task since the task started executing - that is the amount of stack that remained unused when the task stack was at its greatest (deepest) value. This is what is referred to as the stack 'high water mark'.

Parameters:
xTask The handle of the task being queried. A task may query its own high water mark by passing NULL as the xTask parameter.

Returns:
The value returned is the high water mark in words (for example, on a 32 bit machine a return value of 1 would indicate that 4 bytes of stack were unused). If the return value is zero then the task has likely overflowed its stack. If the return value is close to zero then the task has come close to overflowing its stack.
Example usage:

    void vTask1( void * pvParameters )
    {
    unsigned portBASE_TYPE uxHighWaterMark;

        /* Inspect our own high water mark on entering the task. */
        uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );

        for( ;; )
        {
            /* Call any function. */
            vTaskDelay( 1000 );

            /* Calling the function will have used some stack space, we would therefore now expect
            uxTaskGetStackHighWaterMark() to return a value lower than when it was called on
            entering the task. */
            uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
        }
    }






Copyright (C) 2003 - 2008 Richard Barry
Any and all data, files, source code, html content and documentation included in the FreeRTOS distribution or available on this site are the exclusive property of Richard Barry. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Richard Barry.