OS_SetThreadStackWarningOffset

Syntax

#include <nitro/os.h>
void OS_SetThreadStackWarningOffset( OSThread* thread, u32 offset );
  

Arguments

thread The thread for which you want to set a warning level.
offset The warning level offset

Return Values

None.

Description

Sets up the warning level for checking for stack overflow with the specified thread

This check mechanism writes the magic number at the top and bottom positions of the stack by default. It checks by seeing if this was rewritten. OS_SetThreadStackWarningOffset() is added to the top and bottom positions and sets up a warning level in the middle. It writes the magic number for checking if this section was rewritten (The magic number of the stack top and bottom positions is already written when the thread is created.).)

The reason for setting a magic number in the middle of the stack is to detect whether a stack overflow may occur before the stack is completely used and operation becomes unstable.

offset is the number of bytes from the bottom position of the stack and needs to be a multiple of 4. Setting zero cancels this setting.

A magic number is written in the middle of the stack, so operation might become unstable if the section is currently being used. Therefore, always carry out settings for the portion of the stack that you are sure is not being used immediately after creating the thread.

Example:
 :
OS_CreateThread( &thread, ...); 
OS_SetThreadStackWarningOffset( &thread, 0x100);
 :
OS_CheckStack( &thread );

See Also

OS_CreateThread, OS_CheckStack

Revision History

2004/04/29 Revised description
2004/01/21 Initial version


CONFIDENTIAL