# OS_GetStackStatus

## Syntax

      #include <nitro/os.h>

      OSStackStatus OS_GetStackStatus( const OSThread* thread );

## Arguments

thread | The thread to be checked.

## Return Values

`OS_STACK_OVERFLOW` — The magic number at the bottom of the stack is rewritten.
`OS_STACK_UNDERFLOW` — The magic number at the top of the stack is rewritten.
`OS_STACK_ABOUT_TO_OVERFLOW` — The warning level magic number set by the user is rewritten.

When none of the previous cases apply, returns `OS_STACK_NO_ERROR` (defined as `0`).

## Description

Checks for stack leaks with regards to a specified thread and obtains the status

This function checks a magic number that is preset in the top and bottom (in addition, a warning level if set by the user) of the stack, to see whether it is overwritten (if that portion is ever used).

If the magic number at the bottom of the stack is overwritten, it returns `OS_STACK_OVERFLOW`.
If the magic number at the top of the stack is overwritten, it returns `OS_STACK_UNDERFLOW`.
If the magic number at the warning level set by the user in the stack is overwritten, it returns `OS_STACK_ABOUT_TO_OVERFLOW`.

The stack is checked in this order so that `OS_STACK_OVERFLOW` is returned when both the top and bottom of the stack are overwritten.

If none of these condition are met (none of the magic numbers have been overwritten), `OS_STACK_NO_ERROR` is returned. `OS_STACK_NO_ERROR` is defined as 0, so whether an error has occurred can be determined by whether the value is 0 or non-zero.

## See Also

`OS_SetThreadStackWarningOffset`, ``OS_CheckStack``

## Revision History

2005/09/06 Added const to OSThread* type variables.
2004/10/28 Revised return value description.
2004/04/29 Initial version.

CONFIDENTIAL