# OS_GetStackStatus

## C Specification

      #include <nitro/os.h>

      OSStackStatus OS_GetStackStatus( const OSThread* thread );

## Arguments

thread | The thread to be checked.

## Return Values

`OS_STACK_OVERFLOW` — The last magic number of the stack is rewritten.
`OS_STACK_UNDERFLOW` — The topmost magic number of the stack is rewritten.
`OS_STACK_ABOUT_TO_OVERFLOW` — The magic number of the warning level set by the user is rewritten.

When none of previous 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 of the stack (in addition, if set, at a warning level that is set by the user), 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`.

Determination occurs 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), it returns `OS_STACK_NO_ERROR`. If none of these condition are met (none of the magic numbers have been overwritten), it returns `OS_STACK_NO_ERROR`.

## See Also

`OS_SetThreadStackWarningOffset`, ``OS_CheckStack``

## Revision History

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

CONFIDENTIAL