1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<META name="GENERATOR" content="Microsoft FrontPage 5.0">
7<META http-equiv="Content-Style-Type" content="text/css">
8<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
9<title>OSSetIdleFunction</title>
10</head>
11
12<body>
13
14<h1>OSSetIdleFunction</h1>
15
16<h2>C Specification</h2>
17
18<dl>
19<dd><pre><code>#include &lt;revolution/os.h&gt;</code></pre>
20  </dd>
21<dd><pre>OSThread* OSSetIdleFunction( OSIdleFunction idleFunction,
22void*          param,
23void*          stack,
24u32            stackSize );</pre>
25  </dd>
26</dl>
27<h2>Arguments</h2>
28<TABLE border="1" cellpadding="3" cellspacing="0.1">
29  <tr>
30<TD width="120" bgcolor="#ffffe8"><i><b><code><STRONG><EM><CODE>idleFunction</CODE></EM></STRONG></code></b></i></TD>
31<TD width="520">Pointer to the function to execute. Specify a <CODE>NULL</CODE> pointer to cancel the current idle function.</TD>
32    </tr>
33  <tr>
34<TD width="120" bgcolor="#ffffe8"><i><b><code><STRONG><EM><CODE>param</CODE></EM></STRONG></code></b></i></TD>
35<TD width="520">Arguments to pass to the function.</TD>
36    </tr>
37  <tr>
38<TD width="120" bgcolor="#ffffe8"><i><b><code><STRONG><EM><CODE>stack</CODE></EM></STRONG></code></b></i></TD>
39<TD width="520">Stack used for idle functions.</TD>
40    </tr>
41  <tr>
42<TD width="120" bgcolor="#ffffe8"><i><b><code><STRONG><EM><CODE>stackSize</CODE></EM></STRONG></code></b></i></TD>
43<TD width="520">Stack size in bytes.</TD>
44    </tr>
45</TABLE>
46<h2>Return Values</h2>
47<P>Pointer to <STRONG><EM><CODE>OSThread</CODE></EM></STRONG> used for executing the specified idle functions.</P>
48<H2>Description</H2>
49<P>Creates a background thread that will execute while the game main loop is idle. In other words, the operating system will execute <STRONG><EM><CODE>idleFunction</CODE></EM></STRONG> while the game main loop is waiting for the <a href="../../vi/VIWaitForRetrace.html"><code>VIWaitForRetrace</code></a> function to return.</P>
50<P>The return value of the <a href="OSGetIdleFunction.html"><code>OSGetIdleFunction</code></a> function can be used to determine if the idle function has completed. If the background thread that this function creates is still active, a call to this function fails and returns <code>NULL</code>.</P>
51<P>This function is intended to provide convenience for creating background tasks without worrying about thread management.&nbsp;If more than one background task is required, use the <code><a href="OSCreateThread.html">OSCreateThread</a></code> function instead.</P>
52<P>The OS will write a magic word (OS_THREAD_STACK_MAGIC) into the last word of the stack. &nbsp; Stacks grow downward, so the magic word will be at the lowest address.&nbsp;The <code><a href="OSCheckActiveThreads.html">OSCheckActiveThreads</a> </code> function will check to ensure that the magic word remains intact when it is invoked.</P>
53
54
55
56<h2>See Also</h2>
57
58<p><a href="OSGetIdleFunction.html"><code>OSGetIdleFunction</code></a>, <code><a href="../../vi/VIWaitForRetrace.html">VIWaitForRetrace</a>,<a href="OSCheckActiveThreads.html">OSCheckActiveThreads</a></code></p>
59<H2>Revision History</H2>
60<P>03/01/2006 Initial version.</P>
61</body>
62</html>