1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>OS_SetThreadStackWarningOffset</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">OS_SetThreadStackWarningOffset <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1>
12<H2>Syntax</H2>
13<DL>
14  <DD>
15  <PRE><CODE>#include &lt;nitro/os.h&gt;</CODE></PRE>
16  <PRE><CODE>void OS_SetThreadStackWarningOffset( OSThread* thread, u32 offset );
17  </CODE></PRE>
18</DL>
19<H2>Arguments</H2>
20<TABLE border="1" width="100%">
21  <TBODY>
22    <TR>
23      <TD width="13%"><EM><STRONG>thread</STRONG></EM></TD>
24      <TD width="87%">The thread for which you want to set a warning level.</TD>
25    </TR>
26    <TR>
27      <TD width="13%"><EM><STRONG>offset</STRONG></EM></TD>
28      <TD width="87%">The warning level offset</TD>
29    </TR>
30  </TBODY>
31</TABLE>
32<H2>Return Values</H2>
33<P>None.</P>
34<H2>Description</H2>
35<P>Sets up the warning level for checking for stack overflow with the specified thread</P>
36<P>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. <code>OS_SetThreadStackWarningOffset()</code> 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.).)</P>
37<P>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.</P>
38<P><em><strong><code>offset</code></strong></em> 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.</P>
39<P>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.</P>
40<BLOCKQUOTE style="background-color:#ffffc0">Example:
41<pre> :
42OS_CreateThread( &amp;thread, ...);
43OS_SetThreadStackWarningOffset( &amp;thread, 0x100);
44 :
45OS_CheckStack( &amp;thread );
46
47</pre>
48</BLOCKQUOTE>
49<H2>See Also</H2>
50<P><a href="../thread/OS_CreateThread.html"><code>OS_CreateThread</a></code>, <code><a href="OS_CheckStack.html">OS_CheckStack</a></code></P>
51<H2>Revision History</H2>
52<P>2004/04/29 Revised description<br /> 2004/01/21 Initial version</P>
53<hr><p>CONFIDENTIAL</p></body>
54</HTML>