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>Syntax</h2>
17<dl><dd><pre class="construction">
18#include &lt;revolution/os.h&gt;
19
20OSThread* OSSetIdleFunction( OSIdleFunction idleFunction,
21                             void*          param,
22                             void*          stack,
23                             u32            stackSize );
24</pre></dd></dl>
25
26<h2>Arguments</h2>
27<TABLE class="arguments" border="1" >
28  <tr>
29<TH>idleFunction</TH>
30<TD>Pointer to the function to be executed. Specifies a <CODE>NULL</CODE> pointer to cancel currently idle functions.</TD>
31  </tr>
32  <tr>
33<TH><STRONG><EM><CODE>param</CODE></EM></STRONG></TH>
34<TD>Arguments to be passed to the function.</TD>
35  </tr>
36  <tr>
37<TH><STRONG><EM><CODE>stack</CODE></EM></STRONG></TH>
38<TD>Stack used for idle functioins.</TD>
39  </tr>
40  <tr>
41<TH><STRONG><EM><CODE>stackSize</CODE></EM></STRONG></TH>
42<TD>Stack size (in bytes).</TD>
43  </tr>
44</TABLE>
45
46<h2>Return Values</h2>
47<P>Pointer to <CODE>OSThread</CODE> to execute the specified idle function.</P>
48
49<H2>Description</H2>
50<P>Creates a background thread that will execute while the game main loop is idle. Specifically, the operating system executes <SPAN class="argument">idleFunction</SPAN> while the game's main loop waits for the <A href="../../vi/VIWaitForRetrace.html"><CODE>VIWaitForRetrace</CODE></A> function to return.</P>
51<P>The <A href="OSGetIdleFunction.html"><CODE>OSGetIdleFunction</CODE></A> function's return value 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>
52<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 <A href="OSCreateThread.html"><CODE>OSCreateThread</CODE></A> function instead.</P>
53<P>The OS will write a magic word (<CODE>OS_THREAD_STACK_MAGIC</CODE>) into the last word of the stack. 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>
54
55<h2>See Also</h2>
56<P class="reference">
57<a href="OSGetIdleFunction.html">OSGetIdleFunction</a>,
58<a href="../../vi/VIWaitForRetrace.html">VIWaitForRetrace</a>,
59<a href="OSCheckActiveThreads.html">OSCheckActiveThreads</a>
60</p>
61
62<H2>Revision History</H2>
63<P>
642006/03/01 Initial version.<br>
65</P>
66
67<hr><p>CONFIDENTIAL</p></body>
68</html>