gnuk/ChibiOS_2.0.8/docs/html/group__threads.html

1547 lines
112 KiB
HTML
Raw Normal View History

2010-08-10 03:11:02 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ChibiOS/RT: Threads</title>
<link href="custom.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<table style="text-align: center; width: 100%;" border="0"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 80px;"><img alt="ChibiOS/RT Logo" src="logo_small.png"></td>
<td><big><big>ChibiOS/RT</big></big><br><br>Architecture - Reference Manual - Guides</td>
<td style="width: 80px;"></td>
</tr>
</tbody>
</table>
<hr size="1">
2010-11-22 05:53:37 +00:00
<!-- Generated by Doxygen 1.7.1 -->
2010-08-10 03:11:02 +00:00
<div class="navigation" id="top">
<div class="tabs">
2010-11-22 05:53:37 +00:00
<ul class="tablist">
2010-08-10 03:11:02 +00:00
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
2010-11-22 05:53:37 +00:00
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Defines</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
2010-08-10 03:11:02 +00:00
<h1>Threads<br/>
<small>
[<a class="el" href="group__base.html">Base Kernel Services</a>]</small>
2010-11-22 05:53:37 +00:00
</h1> </div>
</div>
<div class="contents">
2010-08-10 03:11:02 +00:00
<p><div class="dynheader">
Collaboration diagram for Threads:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<center><table><tr><td><img src="group__threads.png" border="0" alt="" usemap="#group____threads"/>
<map name="group____threads" id="group____threads">
<area shape="rect" id="node2" href="group__base.html" title="Base Kernel Services" alt="" coords="7,5,132,32"/> </map>
</td></tr></table></center>
2010-08-10 03:11:02 +00:00
</div>
</p>
<hr/><a name="_details"></a><h2>Description</h2>
<p>Threads related APIs and services.</p>
<h2>Operation mode</h2>
<p>A thread is an abstraction of an independent instructions flow. In ChibiOS/RT a thread is represented by a "C" function owning a processor context, state informations and a dedicated stack area. In this scenario static variables are shared among all threads while automatic variables are local to the thread.<br/>
Operations defined for threads:</p>
<ul>
<li><b>Init</b>, a thread is prepared and put in the suspended state.</li>
<li><b>Create</b>, a thread is started on the specified thread function. This operation is available in multiple variants, both static and dynamic.</li>
<li><b>Exit</b>, a thread terminates by returning from its top level function or invoking a specific API, the thread can return a value that can be retrieved by other threads.</li>
<li><b>Wait</b>, a thread waits for the termination of another thread and retrieves its return value.</li>
<li><b>Resume</b>, a thread created in suspended state is started.</li>
<li><b>Sleep</b>, the execution of a thread is suspended for the specified amount of time or the specified future absolute time is reached.</li>
<li><b>SetPriority</b>, a thread changes its own priority level.</li>
<li><b>Yield</b>, a thread voluntarily renounces to its time slot.</li>
</ul>
<p>The threads subsystem is implicitly included in kernel however some of its part may be excluded by disabling them in <code><a class="el" href="chconf_8h.html" title="Configuration file template.">chconf.h</a></code>, see the <code>CH_USE_WAITEXIT</code> and <code>CH_USE_DYNAMIC</code> configuration options. </p>
2010-11-22 05:53:37 +00:00
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_thread.html">Thread</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Structure representing a thread. <a href="struct_thread.html#_details">More...</a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga1f7b83c73a5b850a3f33bddbdb024fb3">THD_STATE_READY</a>&nbsp;&nbsp;&nbsp;0</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Ready to run, waiting on the ready list. <a href="#ga1f7b83c73a5b850a3f33bddbdb024fb3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga247c4d33e862f51e90df9a602175f80b">THD_STATE_CURRENT</a>&nbsp;&nbsp;&nbsp;1</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Currently running. <a href="#ga247c4d33e862f51e90df9a602175f80b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gace00089d9d68ba83bb866396332c15d8">THD_STATE_SUSPENDED</a>&nbsp;&nbsp;&nbsp;2</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: <a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> created in suspended state. <a href="#gace00089d9d68ba83bb866396332c15d8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gad0b81cae859c0a6bc6a0d2036aa8e272">THD_STATE_WTSEM</a>&nbsp;&nbsp;&nbsp;3</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting on a semaphore. <a href="#gad0b81cae859c0a6bc6a0d2036aa8e272"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gac18de5096ff3c841e69672cab0868cdf">THD_STATE_WTMTX</a>&nbsp;&nbsp;&nbsp;4</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting on a mutex. <a href="#gac18de5096ff3c841e69672cab0868cdf"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga286c5b1a6459d654d5794fc17e93c939">THD_STATE_WTCOND</a>&nbsp;&nbsp;&nbsp;5</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__condvars.html#ga466f912bc9b09b133fae862993004ffe" title="Waits on the condition variable releasing the mutex lock.">chCondWait()</a></code>. <a href="#ga286c5b1a6459d654d5794fc17e93c939"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga1b56c4f78480669018aea61711430048">THD_STATE_SLEEPING</a>&nbsp;&nbsp;&nbsp;6</td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__threads.html#ga8b10a49e2ec522a5ddecabdc453afcab" title="Suspends the invoking thread for the specified time.">chThdSleep()</a></code> or <code><a class="el" href="group__threads.html#ga9e6e2f8d46d415e8f0862daf0be1d984" title="Suspends the invoking thread until the system time arrives to the specified value.">chThdSleepUntil()</a></code>. <a href="#ga1b56c4f78480669018aea61711430048"></a><br/></td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gaf726245829b74db3a77a5f4bcc17bf67">THD_STATE_WTEXIT</a>&nbsp;&nbsp;&nbsp;7</td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409" title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait()</a></code>. <a href="#gaf726245829b74db3a77a5f4bcc17bf67"></a><br/></td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gacd5f28475be26c300aa3444b9bad8feb">THD_STATE_WTOREVT</a>&nbsp;&nbsp;&nbsp;8</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code>chEvtWaitXXX()</code>. <a href="#gacd5f28475be26c300aa3444b9bad8feb"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga1227eb701b7ecaa8e8cd03edeeb79a92">THD_STATE_WTANDEVT</a>&nbsp;&nbsp;&nbsp;9</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__events.html#ga90d702300eecee3d05f83e95b155c3ee" title="Waits for all the specified events.">chEvtWaitAllTimeout()</a></code>. <a href="#ga1227eb701b7ecaa8e8cd03edeeb79a92"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gaff813590802bfd53cbf0560b680b89f5">THD_STATE_SNDMSG</a>&nbsp;&nbsp;&nbsp;10</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__messages.html#ga29a48a438e97dc47cb798a84e13764cb" title="Sends a message to the specified thread.">chMsgSend()</a></code>. <a href="#gaff813590802bfd53cbf0560b680b89f5"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gaf46c55b4468f0dad5cd0b3ef73e1be26">THD_STATE_WTMSG</a>&nbsp;&nbsp;&nbsp;11</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__messages.html#gae68fefbf9d0404bbf56ae354961fae41" title="Suspends the thread and waits for an incoming message.">chMsgWait()</a></code>. <a href="#gaf46c55b4468f0dad5cd0b3ef73e1be26"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga10583a3a3fb4c62693bb08796f8d13ae">THD_STATE_FINAL</a>&nbsp;&nbsp;&nbsp;12</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: After termination. <a href="#ga10583a3a3fb4c62693bb08796f8d13ae"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga03fc66bb40f45829816cd4e8353fead2">THD_MEM_MODE_MASK</a>&nbsp;&nbsp;&nbsp;3</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode mask. <a href="#ga03fc66bb40f45829816cd4e8353fead2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga222e36a338ac4048b1da998f112771ea">THD_MEM_MODE_STATIC</a>&nbsp;&nbsp;&nbsp;0</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode: static. <a href="#ga222e36a338ac4048b1da998f112771ea"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga706ca53f21d35623480e8e5a239c3fcb">THD_MEM_MODE_HEAP</a>&nbsp;&nbsp;&nbsp;1</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode: heap. <a href="#ga706ca53f21d35623480e8e5a239c3fcb"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga70a7c2fa69d7ca90e6f191c2ebd8cc6f">THD_MEM_MODE_MEMPOOL</a>&nbsp;&nbsp;&nbsp;2</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode: pool. <a href="#ga70a7c2fa69d7ca90e6f191c2ebd8cc6f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga756a0e7dec9a4d374b6b9e913c5adf81">THD_TERMINATE</a>&nbsp;&nbsp;&nbsp;4</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Termination requested. <a href="#ga756a0e7dec9a4d374b6b9e913c5adf81"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gaa36662628234799d205ff8c0cc6745c5">chThdSelf</a>()&nbsp;&nbsp;&nbsp;currp</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns a pointer to the current <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code>. <a href="#gaa36662628234799d205ff8c0cc6745c5"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gac71903de6268d886ff58022854b8b6dd">chThdGetPriority</a>()&nbsp;&nbsp;&nbsp;(currp-&gt;p_prio)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the current thread priority. <a href="#gac71903de6268d886ff58022854b8b6dd"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga44ea29c71507ec19cf668de199fcbcca">chThdLS</a>()&nbsp;&nbsp;&nbsp;(void *)(currp + 1)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the pointer to the <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code> local storage area, if any. <a href="#ga44ea29c71507ec19cf668de199fcbcca"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga91fad809cfc40e5e989b5bc893741f30">chThdTerminated</a>(tp)&nbsp;&nbsp;&nbsp;((tp)-&gt;p_state == THD_STATE_FINAL)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Verifies if the specified thread is in the <code>THD_STATE_FINAL</code> state. <a href="#ga91fad809cfc40e5e989b5bc893741f30"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga5591a9f97ff77b40bd5fc29f16f12a6b">chThdShouldTerminate</a>()&nbsp;&nbsp;&nbsp;(currp-&gt;p_flags &amp; THD_TERMINATE)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Verifies if the current thread has a termination request pending. <a href="#ga5591a9f97ff77b40bd5fc29f16f12a6b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gaca27314f95f0b691d5a83a017157fd09">chThdResumeI</a>(tp)&nbsp;&nbsp;&nbsp;chSchReadyI(tp)</td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Resumes a thread created with <code>chThdInit()</code>. <a href="#gaca27314f95f0b691d5a83a017157fd09"></a><br/></td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga851dc0c4ac72885bf09feebdef4673ac">chThdSleepS</a>(time)&nbsp;&nbsp;&nbsp;chSchGoSleepTimeoutS(THD_STATE_SLEEPING, time)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Suspends the invoking thread for the specified time. <a href="#ga851dc0c4ac72885bf09feebdef4673ac"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga5fc3d014124e558bc59c423a74668c8d">chThdSleepSeconds</a>(sec)&nbsp;&nbsp;&nbsp;chThdSleep(S2ST(sec))</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Delays the invoking thread for the specified number of seconds. <a href="#ga5fc3d014124e558bc59c423a74668c8d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga5aebc25e053a0094714abce4cad9f56f">chThdSleepMilliseconds</a>(msec)&nbsp;&nbsp;&nbsp;chThdSleep(MS2ST(msec))</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Delays the invoking thread for the specified number of milliseconds. <a href="#ga5aebc25e053a0094714abce4cad9f56f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga596f4015871a919694911bc50ba8bd94">chThdSleepMicroseconds</a>(usec)&nbsp;&nbsp;&nbsp;chThdSleep(US2ST(usec))</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Delays the invoking thread for the specified number of microseconds. <a href="#ga596f4015871a919694911bc50ba8bd94"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3">msg_t</a>(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a> )(void *)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> function. <a href="#gabfe59aa7d2ed1b8e57a2ce17bcbc1189"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35">init_thread</a> (<a class="el" href="struct_thread.html">Thread</a> *tp, <a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> prio)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initializes a thread structure. <a href="#ga4f6ae58bb3cedfc03aacde6d49e49d35"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030">chThdCreateI</a> (void *wsp, size_t size, <a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> prio, <a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a> pf, void *arg)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates a new thread into a static memory area. <a href="#gac6de13d4044b32d3ae9e2066b5d4c030"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga048e588238dd336c6059133b3d0c3435">chThdCreateStatic</a> (void *wsp, size_t size, <a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> prio, <a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a> pf, void *arg)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates a new thread into a static memory area. <a href="#ga048e588238dd336c6059133b3d0c3435"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga50b84e3e82a4e09c1066e1d422e4c780">chThdCreateFromHeap</a> (<a class="el" href="structmemory__heap.html">MemoryHeap</a> *heapp, size_t size, <a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> prio, <a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a> pf, void *arg)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates a new thread allocating the memory from the heap. <a href="#ga50b84e3e82a4e09c1066e1d422e4c780"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gad3ccc1a6f054c543258ed2fe97ed2f58">chThdCreateFromMemoryPool</a> (<a class="el" href="struct_memory_pool.html">MemoryPool</a> *mp, <a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> prio, <a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a> pf, void *arg)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates a new thread allocating the memory from the specified memory pool. <a href="#gad3ccc1a6f054c543258ed2fe97ed2f58"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga5a5d9388c64e4c1a3aec129d2831eefe">chThdSetPriority</a> (<a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> newprio)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Changes the running thread priority level then reschedules if necessary. <a href="#ga5a5d9388c64e4c1a3aec129d2831eefe"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga2c1ce2be73cd177af7e577b282232a7d">chThdResume</a> (<a class="el" href="struct_thread.html">Thread</a> *tp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Resumes a suspended thread. <a href="#ga2c1ce2be73cd177af7e577b282232a7d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga7ea7371fa41598ebd523622587ce3f22">chThdTerminate</a> (<a class="el" href="struct_thread.html">Thread</a> *tp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Requests a thread termination. <a href="#ga7ea7371fa41598ebd523622587ce3f22"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga8b10a49e2ec522a5ddecabdc453afcab">chThdSleep</a> (<a class="el" href="group__types.html#gae3e32a98d431a02106616da3071832dd">systime_t</a> time)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Suspends the invoking thread for the specified time. <a href="#ga8b10a49e2ec522a5ddecabdc453afcab"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga9e6e2f8d46d415e8f0862daf0be1d984">chThdSleepUntil</a> (<a class="el" href="group__types.html#gae3e32a98d431a02106616da3071832dd">systime_t</a> time)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Suspends the invoking thread until the system time arrives to the specified value. <a href="#ga9e6e2f8d46d415e8f0862daf0be1d984"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gacb0a8f22a8358487eaebab3c84b1c4a1">chThdYield</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Yields the time slot. <a href="#gacb0a8f22a8358487eaebab3c84b1c4a1"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac">chThdExit</a> (<a class="el" href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3">msg_t</a> msg)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Terminates the current thread by specifying an exit status code. <a href="#ga24ab3a3a4d70214ee360867a1c3c75ac"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gabefc5734beaf29ae0bcd52cd41744930">chThdAddRef</a> (<a class="el" href="struct_thread.html">Thread</a> *tp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Adds a reference to a thread object. <a href="#gabefc5734beaf29ae0bcd52cd41744930"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease</a> (<a class="el" href="struct_thread.html">Thread</a> *tp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Releases a reference to a thread object. <a href="#gaa22f80040cf192015be4607f31a0ac80"></a><br/></td></tr>
2010-11-22 05:53:37 +00:00
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3">msg_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409">chThdWait</a> (<a class="el" href="struct_thread.html">Thread</a> *tp)</td></tr>
2010-08-10 03:11:02 +00:00
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned. <a href="#ga94a5727ecdbe0f738dfc8e1ede1c3409"></a><br/></td></tr>
</table>
<hr/><h2>Define Documentation</h2>
<a class="anchor" id="ga1f7b83c73a5b850a3f33bddbdb024fb3"></a><!-- doxytag: member="chthreads.h::THD_STATE_READY" ref="ga1f7b83c73a5b850a3f33bddbdb024fb3" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_READY&nbsp;&nbsp;&nbsp;0</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Ready to run, waiting on the ready list. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00175">175</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-22 05:53:37 +00:00
<p>Referenced by <a class="el" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="ga247c4d33e862f51e90df9a602175f80b"></a><!-- doxytag: member="chthreads.h::THD_STATE_CURRENT" ref="ga247c4d33e862f51e90df9a602175f80b" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_CURRENT&nbsp;&nbsp;&nbsp;1</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Currently running. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00177">177</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="gace00089d9d68ba83bb866396332c15d8"></a><!-- doxytag: member="chthreads.h::THD_STATE_SUSPENDED" ref="gace00089d9d68ba83bb866396332c15d8" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_SUSPENDED&nbsp;&nbsp;&nbsp;2</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: <a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> created in suspended state. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00179">179</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-22 05:53:37 +00:00
<p>Referenced by <a class="el" href="group__threads.html#ga2c1ce2be73cd177af7e577b282232a7d">chThdResume()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="gad0b81cae859c0a6bc6a0d2036aa8e272"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTSEM" ref="gad0b81cae859c0a6bc6a0d2036aa8e272" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTSEM&nbsp;&nbsp;&nbsp;3</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting on a semaphore. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00181">181</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS()</a>, <a class="el" href="group__semaphores.html#ga0dc7b4339506de346d67b4560b271e44">chSemSignalWait()</a>, <a class="el" href="group__semaphores.html#gaa2c0367078533e291d2e889e251d8b67">chSemWaitS()</a>, and <a class="el" href="group__semaphores.html#ga924ec5d191bb8debe8727ae4dd5d6d03">chSemWaitTimeoutS()</a>.</p>
</div>
</div>
<a class="anchor" id="gac18de5096ff3c841e69672cab0868cdf"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTMTX" ref="gac18de5096ff3c841e69672cab0868cdf" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTMTX&nbsp;&nbsp;&nbsp;4</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting on a mutex. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00183">183</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS()</a>.</p>
</div>
</div>
<a class="anchor" id="ga286c5b1a6459d654d5794fc17e93c939"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTCOND" ref="ga286c5b1a6459d654d5794fc17e93c939" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTCOND&nbsp;&nbsp;&nbsp;5</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__condvars.html#ga466f912bc9b09b133fae862993004ffe" title="Waits on the condition variable releasing the mutex lock.">chCondWait()</a></code>. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00185">185</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__condvars.html#gab6357d80b01ed8d225ef1e30a66248f9">chCondWaitS()</a>, <a class="el" href="group__condvars.html#ga9cf6ebe4c9f28cb206fab14984a18d29">chCondWaitTimeoutS()</a>, and <a class="el" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS()</a>.</p>
</div>
</div>
<a class="anchor" id="ga1b56c4f78480669018aea61711430048"></a><!-- doxytag: member="chthreads.h::THD_STATE_SLEEPING" ref="ga1b56c4f78480669018aea61711430048" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_SLEEPING&nbsp;&nbsp;&nbsp;6</td>
</tr>
</table>
</div>
<div class="memdoc">
2010-11-22 05:53:37 +00:00
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__threads.html#ga8b10a49e2ec522a5ddecabdc453afcab" title="Suspends the invoking thread for the specified time.">chThdSleep()</a></code> or <code><a class="el" href="group__threads.html#ga9e6e2f8d46d415e8f0862daf0be1d984" title="Suspends the invoking thread until the system time arrives to the specified value.">chThdSleepUntil()</a></code>. </p>
2010-08-10 03:11:02 +00:00
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00187">187</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="gaf726245829b74db3a77a5f4bcc17bf67"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTEXIT" ref="gaf726245829b74db3a77a5f4bcc17bf67" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTEXIT&nbsp;&nbsp;&nbsp;7</td>
</tr>
</table>
</div>
<div class="memdoc">
2010-11-22 05:53:37 +00:00
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409" title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait()</a></code>. </p>
2010-08-10 03:11:02 +00:00
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00189">189</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409">chThdWait()</a>.</p>
</div>
</div>
<a class="anchor" id="gacd5f28475be26c300aa3444b9bad8feb"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTOREVT" ref="gacd5f28475be26c300aa3444b9bad8feb" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTOREVT&nbsp;&nbsp;&nbsp;8</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code>chEvtWaitXXX()</code>. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00191">191</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__events.html#ga6c219038c3e618e2142c6e1601997907">chEvtSignalI()</a>, <a class="el" href="group__events.html#gabd731d3ed2f037b2409e370676575f8d">chEvtWaitAny()</a>, <a class="el" href="group__events.html#gaf690406ccc833e2c9235e7e2041a6715">chEvtWaitAnyTimeout()</a>, <a class="el" href="group__events.html#ga77651e22578713ebe355c1213286c2e9">chEvtWaitOne()</a>, and <a class="el" href="group__events.html#ga2944a7fc82e7cc15537f5a7c04f457d3">chEvtWaitOneTimeout()</a>.</p>
</div>
</div>
<a class="anchor" id="ga1227eb701b7ecaa8e8cd03edeeb79a92"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTANDEVT" ref="ga1227eb701b7ecaa8e8cd03edeeb79a92" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTANDEVT&nbsp;&nbsp;&nbsp;9</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__events.html#ga90d702300eecee3d05f83e95b155c3ee" title="Waits for all the specified events.">chEvtWaitAllTimeout()</a></code>. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00193">193</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__events.html#ga6c219038c3e618e2142c6e1601997907">chEvtSignalI()</a>, <a class="el" href="group__events.html#ga8c5c6bf310a08cdc836d23f98a87dbf5">chEvtWaitAll()</a>, and <a class="el" href="group__events.html#ga90d702300eecee3d05f83e95b155c3ee">chEvtWaitAllTimeout()</a>.</p>
</div>
</div>
<a class="anchor" id="gaff813590802bfd53cbf0560b680b89f5"></a><!-- doxytag: member="chthreads.h::THD_STATE_SNDMSG" ref="gaff813590802bfd53cbf0560b680b89f5" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_SNDMSG&nbsp;&nbsp;&nbsp;10</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__messages.html#ga29a48a438e97dc47cb798a84e13764cb" title="Sends a message to the specified thread.">chMsgSend()</a></code>. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00195">195</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__messages.html#ga29a48a438e97dc47cb798a84e13764cb">chMsgSend()</a>, and <a class="el" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS()</a>.</p>
</div>
</div>
<a class="anchor" id="gaf46c55b4468f0dad5cd0b3ef73e1be26"></a><!-- doxytag: member="chthreads.h::THD_STATE_WTMSG" ref="gaf46c55b4468f0dad5cd0b3ef73e1be26" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_WTMSG&nbsp;&nbsp;&nbsp;11</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: Waiting in <code><a class="el" href="group__messages.html#gae68fefbf9d0404bbf56ae354961fae41" title="Suspends the thread and waits for an incoming message.">chMsgWait()</a></code>. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00197">197</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group__messages.html#ga29a48a438e97dc47cb798a84e13764cb">chMsgSend()</a>, and <a class="el" href="group__messages.html#gae68fefbf9d0404bbf56ae354961fae41">chMsgWait()</a>.</p>
</div>
</div>
<a class="anchor" id="ga10583a3a3fb4c62693bb08796f8d13ae"></a><!-- doxytag: member="chthreads.h::THD_STATE_FINAL" ref="ga10583a3a3fb4c62693bb08796f8d13ae" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_STATE_FINAL&nbsp;&nbsp;&nbsp;12</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> state: After termination. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00199">199</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-30 04:54:43 +00:00
<p>Referenced by <a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac">chThdExit()</a>, <a class="el" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease()</a>, and <a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409">chThdWait()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="ga03fc66bb40f45829816cd4e8353fead2"></a><!-- doxytag: member="chthreads.h::THD_MEM_MODE_MASK" ref="ga03fc66bb40f45829816cd4e8353fead2" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_MEM_MODE_MASK&nbsp;&nbsp;&nbsp;3</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode mask. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00204">204</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-30 04:54:43 +00:00
<p>Referenced by <a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac">chThdExit()</a>, and <a class="el" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="ga222e36a338ac4048b1da998f112771ea"></a><!-- doxytag: member="chthreads.h::THD_MEM_MODE_STATIC" ref="ga222e36a338ac4048b1da998f112771ea" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_MEM_MODE_STATIC&nbsp;&nbsp;&nbsp;0</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode: static. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00205">205</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-30 04:54:43 +00:00
<p>Referenced by <a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac">chThdExit()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="ga706ca53f21d35623480e8e5a239c3fcb"></a><!-- doxytag: member="chthreads.h::THD_MEM_MODE_HEAP" ref="ga706ca53f21d35623480e8e5a239c3fcb" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_MEM_MODE_HEAP&nbsp;&nbsp;&nbsp;1</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode: heap. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00206">206</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-22 05:53:37 +00:00
<p>Referenced by <a class="el" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="ga70a7c2fa69d7ca90e6f191c2ebd8cc6f"></a><!-- doxytag: member="chthreads.h::THD_MEM_MODE_MEMPOOL" ref="ga70a7c2fa69d7ca90e6f191c2ebd8cc6f" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_MEM_MODE_MEMPOOL&nbsp;&nbsp;&nbsp;2</td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> memory mode: pool. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00207">207</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
2010-11-22 05:53:37 +00:00
<p>Referenced by <a class="el" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
<a class="anchor" id="ga756a0e7dec9a4d374b6b9e913c5adf81"></a><!-- doxytag: member="chthreads.h::THD_TERMINATE" ref="ga756a0e7dec9a4d374b6b9e913c5adf81" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define THD_TERMINATE&nbsp;&nbsp;&nbsp;4</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Termination requested. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00208">208</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="gaa36662628234799d205ff8c0cc6745c5"></a><!-- doxytag: member="chthreads.h::chThdSelf" ref="gaa36662628234799d205ff8c0cc6745c5" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdSelf</td>
<td>(</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;currp</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns a pointer to the current <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code>. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00253">253</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="gac71903de6268d886ff58022854b8b6dd"></a><!-- doxytag: member="chthreads.h::chThdGetPriority" ref="gac71903de6268d886ff58022854b8b6dd" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdGetPriority</td>
<td>(</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;(currp-&gt;p_prio)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns the current thread priority. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00258">258</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga44ea29c71507ec19cf668de199fcbcca"></a><!-- doxytag: member="chthreads.h::chThdLS" ref="ga44ea29c71507ec19cf668de199fcbcca" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdLS</td>
<td>(</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;(void *)(currp + 1)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns the pointer to the <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code> local storage area, if any. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00263">263</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga91fad809cfc40e5e989b5bc893741f30"></a><!-- doxytag: member="chthreads.h::chThdTerminated" ref="ga91fad809cfc40e5e989b5bc893741f30" args="(tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdTerminated</td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype">&nbsp;</td>
<td class="paramname">tp</td>
2010-08-10 03:11:02 +00:00
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;((tp)-&gt;p_state == THD_STATE_FINAL)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Verifies if the specified thread is in the <code>THD_STATE_FINAL</code> state. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>the pointer to the thread </td></tr>
</table>
</dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>TRUE</em>&nbsp;</td><td>thread terminated. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>FALSE</em>&nbsp;</td><td>thread not terminated. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00272">272</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga5591a9f97ff77b40bd5fc29f16f12a6b"></a><!-- doxytag: member="chthreads.h::chThdShouldTerminate" ref="ga5591a9f97ff77b40bd5fc29f16f12a6b" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdShouldTerminate</td>
<td>(</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;(currp-&gt;p_flags &amp; THD_TERMINATE)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Verifies if the current thread has a termination request pending. </p>
<dl><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>TRUE</em>&nbsp;</td><td>termination request pended. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>FALSE</em>&nbsp;</td><td>termination request not pended. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00280">280</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="gaca27314f95f0b691d5a83a017157fd09"></a><!-- doxytag: member="chthreads.h::chThdResumeI" ref="gaca27314f95f0b691d5a83a017157fd09" args="(tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdResumeI</td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype">&nbsp;</td>
<td class="paramname">tp</td>
2010-08-10 03:11:02 +00:00
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;chSchReadyI(tp)</td>
</tr>
</table>
</div>
<div class="memdoc">
2010-11-22 05:53:37 +00:00
<p>Resumes a thread created with <code>chThdInit()</code>. </p>
2010-08-10 03:11:02 +00:00
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>the pointer to the thread </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00287">287</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga851dc0c4ac72885bf09feebdef4673ac"></a><!-- doxytag: member="chthreads.h::chThdSleepS" ref="ga851dc0c4ac72885bf09feebdef4673ac" args="(time)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdSleepS</td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype">&nbsp;</td>
<td class="paramname">time</td>
2010-08-10 03:11:02 +00:00
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;chSchGoSleepTimeoutS(THD_STATE_SLEEPING, time)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Suspends the invoking thread for the specified time. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>time</em>&nbsp;</td><td>the delay in system ticks, the special values are handled as follow:</p>
<ul>
<li><em>TIME_INFINITE</em> the thread enters an infinite sleep state.</li>
<li><em>TIME_IMMEDIATE</em> this value is accepted but interpreted as a normal time specification not as an immediate timeout specification.</li>
</ul>
</td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00301">301</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group___c_a_n.html#ga05d2448864b2cae4674ed7e6f3c576b8">canStart()</a>, <a class="el" href="group__threads.html#ga8b10a49e2ec522a5ddecabdc453afcab">chThdSleep()</a>, and <a class="el" href="group__threads.html#ga9e6e2f8d46d415e8f0862daf0be1d984">chThdSleepUntil()</a>.</p>
</div>
</div>
<a class="anchor" id="ga5fc3d014124e558bc59c423a74668c8d"></a><!-- doxytag: member="chthreads.h::chThdSleepSeconds" ref="ga5fc3d014124e558bc59c423a74668c8d" args="(sec)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdSleepSeconds</td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype">&nbsp;</td>
<td class="paramname">sec</td>
2010-08-10 03:11:02 +00:00
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;chThdSleep(S2ST(sec))</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Delays the invoking thread for the specified number of seconds. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>The specified time is rounded up to a value allowed by the real system clock. </dd>
<dd>
The maximum specified value is implementation dependent.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>sec</em>&nbsp;</td><td>the time in seconds </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00311">311</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga5aebc25e053a0094714abce4cad9f56f"></a><!-- doxytag: member="chthreads.h::chThdSleepMilliseconds" ref="ga5aebc25e053a0094714abce4cad9f56f" args="(msec)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdSleepMilliseconds</td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype">&nbsp;</td>
<td class="paramname">msec</td>
2010-08-10 03:11:02 +00:00
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;chThdSleep(MS2ST(msec))</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Delays the invoking thread for the specified number of milliseconds. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>The specified time is rounded up to a value allowed by the real system clock. </dd>
<dd>
The maximum specified value is implementation dependent.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>msec</em>&nbsp;</td><td>the time in milliseconds </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00322">322</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
<p>Referenced by <a class="el" href="group___m_m_c___s_p_i.html#ga9ff4f12fa759c3cb4aca2b64b11f1d22">mmcConnect()</a>.</p>
</div>
</div>
<a class="anchor" id="ga596f4015871a919694911bc50ba8bd94"></a><!-- doxytag: member="chthreads.h::chThdSleepMicroseconds" ref="ga596f4015871a919694911bc50ba8bd94" args="(usec)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chThdSleepMicroseconds</td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype">&nbsp;</td>
<td class="paramname">usec</td>
2010-08-10 03:11:02 +00:00
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;chThdSleep(US2ST(usec))</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Delays the invoking thread for the specified number of microseconds. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>The specified time is rounded up to a value allowed by the real system clock. </dd>
<dd>
The maximum specified value is implementation dependent.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>usec</em>&nbsp;</td><td>the time in microseconds </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00333">333</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="gabfe59aa7d2ed1b8e57a2ce17bcbc1189"></a><!-- doxytag: member="chthreads.h::tfunc_t" ref="gabfe59aa7d2ed1b8e57a2ce17bcbc1189" args=")(void *)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
2010-11-22 05:53:37 +00:00
<td class="memname">typedef <a class="el" href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3">msg_t</a>(* <a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a>)(void *)</td>
2010-08-10 03:11:02 +00:00
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a> function. </p>
<p>Definition at line <a class="el" href="chthreads_8h_source.html#l00211">211</a> of file <a class="el" href="chthreads_8h_source.html">chthreads.h</a>.</p>
</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga4f6ae58bb3cedfc03aacde6d49e49d35"></a><!-- doxytag: member="chthreads.h::init_thread" ref="ga4f6ae58bb3cedfc03aacde6d49e49d35" args="(Thread *tp, tprio_t prio)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * init_thread </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td>
<td class="paramname"> <em>tp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>prio</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Initializes a thread structure. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>pointer to the thread </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>prio</em>&nbsp;</td><td>the priority level for the new thread </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The same thread pointer passed as parameter. </dd></dl>
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00074">74</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-11-22 05:53:37 +00:00
<p>References <a class="el" href="group__internals.html#gaaef72a9005ecd65e7b5c22e95ad82388">list_init</a>, <a class="el" href="struct_thread.html#aa571d2963bd8100fa210715dc5669522">Thread::p_epending</a>, <a class="el" href="struct_thread.html#a1e044ddc7521288d6fb473756a214d23">Thread::p_flags</a>, <a class="el" href="struct_thread.html#a282cb59bdbe00fcdf9741c47b735fa1f">Thread::p_msgqueue</a>, <a class="el" href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017">Thread::p_mtxlist</a>, <a class="el" href="struct_thread.html#ae60cc22956f4c19965cb94045333aa9c">Thread::p_prio</a>, <a class="el" href="struct_thread.html#a38de11dd7f8cdcfbc45b2c467f400fe8">Thread::p_realprio</a>, <a class="el" href="struct_thread.html#af86d1da435197d113bc42fe8139a21c5">Thread::p_refs</a>, <a class="el" href="struct_thread.html#a3c3e9d6abccb62c3a5fab6ef043a391f">Thread::p_state</a>, <a class="el" href="struct_thread.html#a723aab9bf515e789c3d9ea81f9dbd6a0">Thread::p_time</a>, <a class="el" href="struct_thread.html#ad1088bc1f9970cc102dc28000134e9ab">Thread::p_waiting</a>, <a class="el" href="group__internals.html#ga6d19d0f3ff1fa599b6d9783dec180451">queue_init</a>, <a class="el" href="group__registry.html#ga365d4805b1329b068d9211b680f43388">REG_INSERT</a>, and <a class="el" href="group__config.html#ga758e6ac94f0ad132cd747325719e4d2f">THREAD_EXT_INIT</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-22 05:53:37 +00:00
<p>Referenced by <a class="el" href="group__system.html#gafe2c7de6567e98e487e009e81e3be10b">chSysInit()</a>, and <a class="el" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030">chThdCreateI()</a>.</p>
2010-08-10 03:11:02 +00:00
</div>
</div>
2010-11-22 05:53:37 +00:00
<a class="anchor" id="gac6de13d4044b32d3ae9e2066b5d4c030"></a><!-- doxytag: member="chthreads.h::chThdCreateI" ref="gac6de13d4044b32d3ae9e2066b5d4c030" args="(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg)" -->
2010-08-10 03:11:02 +00:00
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
2010-11-22 05:53:37 +00:00
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * chThdCreateI </td>
2010-08-10 03:11:02 +00:00
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>wsp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>prio</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a>&nbsp;</td>
<td class="paramname"> <em>pf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>arg</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
2010-11-22 05:53:37 +00:00
<p>Creates a new thread into a static memory area. </p>
2010-08-10 03:11:02 +00:00
<p>The new thread is initialized but not inserted in the ready list, the initial state is <code>THD_STATE_SUSPENDED</code>. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>A thread can terminate by calling <code><a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac" title="Terminates the current thread by specifying an exit status code.">chThdExit()</a></code> or by simply returning from its main function. </dd>
<dd>
2010-11-22 05:53:37 +00:00
Threads created using this function do not obey to the <code>CH_DBG_FILL_THREADS</code> debug option because it would keep the kernel locked for too much time.</dd></dl>
2010-08-10 03:11:02 +00:00
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[out]</tt>&nbsp;</td><td valign="top"><em>wsp</em>&nbsp;</td><td>pointer to a working area dedicated to the thread stack </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>size</em>&nbsp;</td><td>size of the working area </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>prio</em>&nbsp;</td><td>the priority level for the new thread </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>pf</em>&nbsp;</td><td>the thread function </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>arg</em>&nbsp;</td><td>an argument passed to the thread function. It can be <code>NULL</code>. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code> structure allocated for the thread into the working space area. </dd></dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00137">137</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-22 05:53:37 +00:00
<p>References <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="group__scheduler.html#ga0621c307e30868052b802fbc821297e8">HIGHPRIO</a>, <a class="el" href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35">init_thread()</a>, <a class="el" href="group__core.html#gaf5777aa68e4c4786b577953c7237a95d">SETUP_CONTEXT</a>, and <a class="el" href="group__core.html#gaf7a83c1c8bde96b77299c36dc598d33d">THD_WA_SIZE</a>.</p>
2010-08-10 03:11:02 +00:00
<p>Referenced by <a class="el" href="group__threads.html#ga50b84e3e82a4e09c1066e1d422e4c780">chThdCreateFromHeap()</a>, <a class="el" href="group__threads.html#gad3ccc1a6f054c543258ed2fe97ed2f58">chThdCreateFromMemoryPool()</a>, and <a class="el" href="group__threads.html#ga048e588238dd336c6059133b3d0c3435">chThdCreateStatic()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_gac6de13d4044b32d3ae9e2066b5d4c030_cgraph.png" border="0" usemap="#group__threads_gac6de13d4044b32d3ae9e2066b5d4c030_cgraph" alt=""/></div>
<map name="group__threads_gac6de13d4044b32d3ae9e2066b5d4c030_cgraph" id="group__threads_gac6de13d4044b32d3ae9e2066b5d4c030_cgraph">
<area shape="rect" id="node3" href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35" title="Initializes a thread structure." alt="" coords="141,5,213,32"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="ga048e588238dd336c6059133b3d0c3435"></a><!-- doxytag: member="chthreads.h::chThdCreateStatic" ref="ga048e588238dd336c6059133b3d0c3435" args="(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * chThdCreateStatic </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>wsp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>prio</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a>&nbsp;</td>
<td class="paramname"> <em>pf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>arg</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Creates a new thread into a static memory area. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>A thread can terminate by calling <code><a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac" title="Terminates the current thread by specifying an exit status code.">chThdExit()</a></code> or by simply returning from its main function.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[out]</tt>&nbsp;</td><td valign="top"><em>wsp</em>&nbsp;</td><td>pointer to a working area dedicated to the thread stack </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>size</em>&nbsp;</td><td>size of the working area </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>prio</em>&nbsp;</td><td>the priority level for the new thread </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>pf</em>&nbsp;</td><td>the thread function </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>arg</em>&nbsp;</td><td>an argument passed to the thread function. It can be <code>NULL</code>. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code> structure allocated for the thread into the working space area. </dd></dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00163">163</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-22 05:53:37 +00:00
<p>References <a class="el" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95">chSchWakeupS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030">chThdCreateI()</a>, <a class="el" href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61">RDY_OK</a>, <a class="el" href="group__debug.html#ga1379fe3590594def45a6a6c7a4faa41b">STACK_FILL_VALUE</a>, and <a class="el" href="group__debug.html#gad8d58eb160d991692ecc3bd4e04e0cbd">THREAD_FILL_VALUE</a>.</p>
2010-08-10 03:11:02 +00:00
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#a48012dd4151de3d40aa5139b230ed627">chibios_rt::BaseThread::BaseThread()</a>, and <a class="el" href="group__system.html#gafe2c7de6567e98e487e009e81e3be10b">chSysInit()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_ga048e588238dd336c6059133b3d0c3435_cgraph.png" border="0" usemap="#group__threads_ga048e588238dd336c6059133b3d0c3435_cgraph" alt=""/></div>
<map name="group__threads_ga048e588238dd336c6059133b3d0c3435_cgraph" id="group__threads_ga048e588238dd336c6059133b3d0c3435_cgraph">
<area shape="rect" id="node3" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95" title="Wakes up a thread." alt="" coords="165,56,264,83"/> <area shape="rect" id="node9" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030" title="Creates a new thread into a static memory area." alt="" coords="172,107,257,133"/> <area shape="rect" id="node5" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="316,5,396,32"/> <area shape="rect" id="node7" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="313,56,399,83"/> <area shape="rect" id="node11" href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35" title="Initializes a thread structure." alt="" coords="320,107,392,133"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="ga50b84e3e82a4e09c1066e1d422e4c780"></a><!-- doxytag: member="chthreads.h::chThdCreateFromHeap" ref="ga50b84e3e82a4e09c1066e1d422e4c780" args="(MemoryHeap *heapp, size_t size, tprio_t prio, tfunc_t pf, void *arg)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * chThdCreateFromHeap </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structmemory__heap.html">MemoryHeap</a> *&nbsp;</td>
<td class="paramname"> <em>heapp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>prio</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a>&nbsp;</td>
<td class="paramname"> <em>pf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>arg</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Creates a new thread allocating the memory from the heap. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>A thread can terminate by calling <code><a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac" title="Terminates the current thread by specifying an exit status code.">chThdExit()</a></code> or by simply returning from its main function. </dd>
<dd>
2010-11-22 05:53:37 +00:00
The memory allocated for the thread is not released when the thread terminates but when a <code><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409" title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait()</a></code> is performed. </dd>
2010-08-10 03:11:02 +00:00
<dd>
The function is available only if the <code>CH_USE_DYNAMIC</code>, <code>CH_USE_HEAP</code> and <code>CH_USE_WAITEXIT</code> options are enabled in <code><a class="el" href="chconf_8h.html" title="Configuration file template.">chconf.h</a></code>.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>heapp</em>&nbsp;</td><td>heap from which allocate the memory or <code>NULL</code> for the default heap </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>size</em>&nbsp;</td><td>size of the working area to be allocated </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>prio</em>&nbsp;</td><td>the priority level for the new thread </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>pf</em>&nbsp;</td><td>the thread function </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>arg</em>&nbsp;</td><td>an argument passed to the thread function. It can be <code>NULL</code>. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code> structure allocated for the thread into the working space area. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>NULL</em>&nbsp;</td><td>if the memory cannot be allocated. </td></tr>
</table>
</dd>
</dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00200">200</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-22 05:53:37 +00:00
<p>References <a class="el" href="group__heaps.html#ga3d364eec0bef8b1986f63b3288ebbd5f">chHeapAlloc()</a>, <a class="el" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95">chSchWakeupS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030">chThdCreateI()</a>, <a class="el" href="struct_thread.html#a1e044ddc7521288d6fb473756a214d23">Thread::p_flags</a>, <a class="el" href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61">RDY_OK</a>, <a class="el" href="group__debug.html#ga1379fe3590594def45a6a6c7a4faa41b">STACK_FILL_VALUE</a>, and <a class="el" href="group__debug.html#gad8d58eb160d991692ecc3bd4e04e0cbd">THREAD_FILL_VALUE</a>.</p>
2010-08-10 03:11:02 +00:00
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_ga50b84e3e82a4e09c1066e1d422e4c780_cgraph.png" border="0" usemap="#group__threads_ga50b84e3e82a4e09c1066e1d422e4c780_cgraph" alt=""/></div>
<map name="group__threads_ga50b84e3e82a4e09c1066e1d422e4c780_cgraph" id="group__threads_ga50b84e3e82a4e09c1066e1d422e4c780_cgraph">
<area shape="rect" id="node3" href="group__heaps.html#ga3d364eec0bef8b1986f63b3288ebbd5f" title="Allocates a block of memory from the heap by using the first&#45;fit algorithm." alt="" coords="195,5,277,32"/> <area shape="rect" id="node5" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95" title="Wakes up a thread." alt="" coords="187,56,285,83"/> <area shape="rect" id="node11" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030" title="Creates a new thread into a static memory area." alt="" coords="193,107,279,133"/> <area shape="rect" id="node7" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="337,5,417,32"/> <area shape="rect" id="node9" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="335,56,420,83"/> <area shape="rect" id="node13" href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35" title="Initializes a thread structure." alt="" coords="341,107,413,133"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="gad3ccc1a6f054c543258ed2fe97ed2f58"></a><!-- doxytag: member="chthreads.h::chThdCreateFromMemoryPool" ref="gad3ccc1a6f054c543258ed2fe97ed2f58" args="(MemoryPool *mp, tprio_t prio, tfunc_t pf, void *arg)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * chThdCreateFromMemoryPool </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_memory_pool.html">MemoryPool</a> *&nbsp;</td>
<td class="paramname"> <em>mp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>prio</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__threads.html#gabfe59aa7d2ed1b8e57a2ce17bcbc1189">tfunc_t</a>&nbsp;</td>
<td class="paramname"> <em>pf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>arg</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
2010-11-22 05:53:37 +00:00
<p>Creates a new thread allocating the memory from the specified memory pool. </p>
2010-08-10 03:11:02 +00:00
<dl class="note"><dt><b>Note:</b></dt><dd>A thread can terminate by calling <code><a class="el" href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac" title="Terminates the current thread by specifying an exit status code.">chThdExit()</a></code> or by simply returning from its main function. </dd>
<dd>
2010-11-22 05:53:37 +00:00
The memory allocated for the thread is not released when the thread terminates but when a <code><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409" title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait()</a></code> is performed. </dd>
2010-08-10 03:11:02 +00:00
<dd>
The function is available only if the <code>CH_USE_DYNAMIC</code>, <code>CH_USE_MEMPOOLS</code> and <code>CH_USE_WAITEXIT</code> options are enabled in <code><a class="el" href="chconf_8h.html" title="Configuration file template.">chconf.h</a></code>.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>mp</em>&nbsp;</td><td>pointer to the memory pool object </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>prio</em>&nbsp;</td><td>the priority level for the new thread </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>pf</em>&nbsp;</td><td>the thread function </td></tr>
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>arg</em>&nbsp;</td><td>an argument passed to the thread function. It can be <code>NULL</code>. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the <code><a class="el" href="struct_thread.html" title="Structure representing a thread.">Thread</a></code> structure allocated for the thread into the working space area. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>NULL</em>&nbsp;</td><td>if the memory pool is empty. </td></tr>
</table>
</dd>
</dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00245">245</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-22 05:53:37 +00:00
<p>References <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="group__pools.html#gab86190d70893fe708c75570af6720bd5">chPoolAlloc()</a>, <a class="el" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95">chSchWakeupS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030">chThdCreateI()</a>, <a class="el" href="struct_memory_pool.html#a962ca1e05036d54213b3a0eeaebb0ec6">MemoryPool::mp_object_size</a>, <a class="el" href="struct_thread.html#a1e044ddc7521288d6fb473756a214d23">Thread::p_flags</a>, <a class="el" href="struct_thread.html#ae0e65912a0c02df5477a3a524cd41d97">Thread::p_mpool</a>, <a class="el" href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61">RDY_OK</a>, <a class="el" href="group__debug.html#ga1379fe3590594def45a6a6c7a4faa41b">STACK_FILL_VALUE</a>, and <a class="el" href="group__debug.html#gad8d58eb160d991692ecc3bd4e04e0cbd">THREAD_FILL_VALUE</a>.</p>
2010-08-10 03:11:02 +00:00
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_gad3ccc1a6f054c543258ed2fe97ed2f58_cgraph.png" border="0" usemap="#group__threads_gad3ccc1a6f054c543258ed2fe97ed2f58_cgraph" alt=""/></div>
<map name="group__threads_gad3ccc1a6f054c543258ed2fe97ed2f58_cgraph" id="group__threads_gad3ccc1a6f054c543258ed2fe97ed2f58_cgraph">
<area shape="rect" id="node3" href="group__pools.html#gab86190d70893fe708c75570af6720bd5" title="Allocates an object from a memory pool." alt="" coords="232,12,309,39"/> <area shape="rect" id="node7" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95" title="Wakes up a thread." alt="" coords="221,69,320,96"/> <area shape="rect" id="node13" href="group__threads.html#gac6de13d4044b32d3ae9e2066b5d4c030" title="Creates a new thread into a static memory area." alt="" coords="228,132,313,159"/> <area shape="rect" id="node5" href="group__pools.html#ga152fb3460d6b7426f0b6803bb38a0070" title="Allocates an object from a memory pool." alt="" coords="372,5,452,32"/> <area shape="rect" id="node9" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="372,56,452,83"/> <area shape="rect" id="node11" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="369,107,455,133"/> <area shape="rect" id="node15" href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35" title="Initializes a thread structure." alt="" coords="376,157,448,184"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="ga5a5d9388c64e4c1a3aec129d2831eefe"></a><!-- doxytag: member="chthreads.h::chThdSetPriority" ref="ga5a5d9388c64e4c1a3aec129d2831eefe" args="(tprio_t newprio)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
2010-11-22 05:53:37 +00:00
<td class="memname"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a> chThdSetPriority </td>
2010-08-10 03:11:02 +00:00
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee">tprio_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>newprio</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Changes the running thread priority level then reschedules if necessary. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>The function returns the real thread priority regardless of the current priority that could be higher than the real priority because the priority inheritance mechanism.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>newprio</em>&nbsp;</td><td>the new priority level of the running thread </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The old priority level. </dd></dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00282">282</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20">chSchRescheduleS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7">currp</a>, <a class="el" href="group__scheduler.html#ga0621c307e30868052b802fbc821297e8">HIGHPRIO</a>, and <a class="el" href="group__scheduler.html#ga38aff897bc7950077d5985b3d4bcf4d5">LOWPRIO</a>.</p>
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#aa824957049b5d62a4d23b0c9758b30a5">chibios_rt::BaseThread::SetPriority()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_ga5a5d9388c64e4c1a3aec129d2831eefe_cgraph.png" border="0" usemap="#group__threads_ga5a5d9388c64e4c1a3aec129d2831eefe_cgraph" alt=""/></div>
<map name="group__threads_ga5a5d9388c64e4c1a3aec129d2831eefe_cgraph" id="group__threads_ga5a5d9388c64e4c1a3aec129d2831eefe_cgraph">
<area shape="rect" id="node3" href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20" title="Performs a reschedule if a higher priority thread is runnable." alt="" coords="155,5,272,32"/> <area shape="rect" id="node5" href="group__scheduler.html#ga0257cf203e72a766a52059750cb97e6e" title="Switches to the first thread on the runnable queue." alt="" coords="320,5,445,32"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="ga2c1ce2be73cd177af7e577b282232a7d"></a><!-- doxytag: member="chthreads.h::chThdResume" ref="ga2c1ce2be73cd177af7e577b282232a7d" args="(Thread *tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * chThdResume </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td>
<td class="paramname"> <em>tp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Resumes a suspended thread. </p>
2010-11-22 05:53:37 +00:00
<dl class="note"><dt><b>Note:</b></dt><dd>Use this function to resume threads created with <code>chThdInit()</code>.</dd></dl>
2010-08-10 03:11:02 +00:00
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>pointer to the thread </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the thread. </dd></dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00310">310</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <a class="el" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95">chSchWakeupS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="struct_thread.html#a3c3e9d6abccb62c3a5fab6ef043a391f">Thread::p_state</a>, <a class="el" href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61">RDY_OK</a>, and <a class="el" href="group__threads.html#gace00089d9d68ba83bb866396332c15d8">THD_STATE_SUSPENDED</a>.</p>
2010-11-22 05:53:37 +00:00
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#a6cde6d5b592476aded69ee10b5adc912">chibios_rt::BaseThread::Resume()</a>.</p>
2010-08-10 03:11:02 +00:00
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_ga2c1ce2be73cd177af7e577b282232a7d_cgraph.png" border="0" usemap="#group__threads_ga2c1ce2be73cd177af7e577b282232a7d_cgraph" alt=""/></div>
<map name="group__threads_ga2c1ce2be73cd177af7e577b282232a7d_cgraph" id="group__threads_ga2c1ce2be73cd177af7e577b282232a7d_cgraph">
<area shape="rect" id="node3" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95" title="Wakes up a thread." alt="" coords="144,31,243,57"/> <area shape="rect" id="node5" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="295,5,375,32"/> <area shape="rect" id="node7" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="292,56,377,83"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="ga7ea7371fa41598ebd523622587ce3f22"></a><!-- doxytag: member="chthreads.h::chThdTerminate" ref="ga7ea7371fa41598ebd523622587ce3f22" args="(Thread *tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chThdTerminate </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td>
<td class="paramname"> <em>tp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Requests a thread termination. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>The thread is not terminated but a termination request is added to its <code>p_flags</code> field. The thread can read this status by invoking <code><a class="el" href="group__threads.html#ga5591a9f97ff77b40bd5fc29f16f12a6b" title="Verifies if the current thread has a termination request pending.">chThdShouldTerminate()</a></code> and then terminate cleanly.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>pointer to the thread </td></tr>
</table>
</dd>
</dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00329">329</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-22 05:53:37 +00:00
<p>References <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, and <a class="el" href="struct_thread.html#a1e044ddc7521288d6fb473756a214d23">Thread::p_flags</a>.</p>
2010-08-10 03:11:02 +00:00
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#a9391836cb66a13932044703d1833ae64">chibios_rt::BaseThread::Terminate()</a>.</p>
</div>
</div>
<a class="anchor" id="ga8b10a49e2ec522a5ddecabdc453afcab"></a><!-- doxytag: member="chthreads.h::chThdSleep" ref="ga8b10a49e2ec522a5ddecabdc453afcab" args="(systime_t time)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chThdSleep </td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#gae3e32a98d431a02106616da3071832dd">systime_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>time</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Suspends the invoking thread for the specified time. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>time</em>&nbsp;</td><td>the delay in system ticks, the special values are handled as follow:</p>
<ul>
<li><em>TIME_INFINITE</em> the thread enters an infinite sleep state.</li>
<li><em>TIME_IMMEDIATE</em> this value is accepted but interpreted as a normal time specification not as an immediate timeout specification.</li>
</ul>
</td></tr>
</table>
</dd>
</dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00348">348</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__threads.html#ga851dc0c4ac72885bf09feebdef4673ac">chThdSleepS</a>, and <a class="el" href="group__scheduler.html#gae1568cf3090c973c3bc47f86ae2f5afb">TIME_INFINITE</a>.</p>
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#a44de1239fc6517ddf735405dd7fc8463">chibios_rt::BaseThread::Sleep()</a>.</p>
</div>
</div>
<a class="anchor" id="ga9e6e2f8d46d415e8f0862daf0be1d984"></a><!-- doxytag: member="chthreads.h::chThdSleepUntil" ref="ga9e6e2f8d46d415e8f0862daf0be1d984" args="(systime_t time)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chThdSleepUntil </td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#gae3e32a98d431a02106616da3071832dd">systime_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>time</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Suspends the invoking thread until the system time arrives to the specified value. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>time</em>&nbsp;</td><td>absolute system time </td></tr>
</table>
</dd>
</dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00363">363</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__threads.html#ga851dc0c4ac72885bf09feebdef4673ac">chThdSleepS</a>, and <a class="el" href="group__time.html#ga137c8f67c450f34416a786d169be90e2">chTimeNow</a>.</p>
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#a0589beba9bb4c959b3f49a82b24562eb">chibios_rt::BaseThread::SleepUntil()</a>.</p>
</div>
</div>
<a class="anchor" id="gacb0a8f22a8358487eaebab3c84b1c4a1"></a><!-- doxytag: member="chthreads.h::chThdYield" ref="gacb0a8f22a8358487eaebab3c84b1c4a1" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chThdYield </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Yields the time slot. </p>
<p>Yields the CPU control to the next thread in the ready list with equal priority, if any. </p>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00376">376</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__scheduler.html#ga8fd763c1a004a010fc13575578edefbd">chSchDoYieldS</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
</div>
</div>
<a class="anchor" id="ga24ab3a3a4d70214ee360867a1c3c75ac"></a><!-- doxytag: member="chthreads.h::chThdExit" ref="ga24ab3a3a4d70214ee360867a1c3c75ac" args="(msg_t msg)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chThdExit </td>
<td>(</td>
2010-11-22 05:53:37 +00:00
<td class="paramtype"><a class="el" href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3">msg_t</a>&nbsp;</td>
2010-08-10 03:11:02 +00:00
<td class="paramname"> <em>msg</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Terminates the current thread by specifying an exit status code. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
2010-11-22 05:53:37 +00:00
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>msg</em>&nbsp;</td><td>thread exit code. The code can be retrieved by using <code><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409" title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait()</a></code>. </td></tr>
2010-08-10 03:11:02 +00:00
</table>
</dd>
</dl>
2010-11-22 05:53:37 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00389">389</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-30 04:54:43 +00:00
<p>References <a class="el" href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986">chSchGoSleepS()</a>, <a class="el" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298">chSchReadyI()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="struct_thread.html#addbf4614b204bdc2a3480c434cf7baaf">Thread::exitcode</a>, <a class="el" href="group__internals.html#gad9aa523aebdaeefa3cc4a311bc210e8a">list_remove()</a>, <a class="el" href="group__internals.html#ga8f6bea56a53acc44758fe61c98d68a4e">notempty</a>, <a class="el" href="struct_thread.html#a1e044ddc7521288d6fb473756a214d23">Thread::p_flags</a>, <a class="el" href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a">Thread::p_u</a>, <a class="el" href="struct_thread.html#ad1088bc1f9970cc102dc28000134e9ab">Thread::p_waiting</a>, <a class="el" href="group__registry.html#ga472c6eb9a86e5963f452aa78719c92da">REG_REMOVE</a>, <a class="el" href="group__threads.html#ga03fc66bb40f45829816cd4e8353fead2">THD_MEM_MODE_MASK</a>, <a class="el" href="group__threads.html#ga222e36a338ac4048b1da998f112771ea">THD_MEM_MODE_STATIC</a>, <a class="el" href="group__threads.html#ga10583a3a3fb4c62693bb08796f8d13ae">THD_STATE_FINAL</a>, and <a class="el" href="group__config.html#ga5137c8f67dd4fa75e99824a95a3fa746">THREAD_EXT_EXIT</a>.</p>
2010-08-10 03:11:02 +00:00
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#abc119aef948c9050d2e18a5a2686d88d">chibios_rt::BaseThread::Exit()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_ga24ab3a3a4d70214ee360867a1c3c75ac_cgraph.png" border="0" usemap="#group__threads_ga24ab3a3a4d70214ee360867a1c3c75ac_cgraph" alt=""/></div>
<map name="group__threads_ga24ab3a3a4d70214ee360867a1c3c75ac_cgraph" id="group__threads_ga24ab3a3a4d70214ee360867a1c3c75ac_cgraph">
<area shape="rect" id="node3" href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986" title="Puts the current thread to sleep into the specified state." alt="" coords="123,31,224,57"/> <area shape="rect" id="node9" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="131,81,216,108"/> <area shape="rect" id="node11" href="group__internals.html#gad9aa523aebdaeefa3cc4a311bc210e8a" title="Pops a Thread from the top of a stack list and returns it." alt="" coords="135,132,212,159"/> <area shape="rect" id="node5" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="273,5,353,32"/> <area shape="rect" id="node7" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a" title="Removes the first&#45;out Thread from a queue and returns it." alt="" coords="273,56,353,83"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="gabefc5734beaf29ae0bcd52cd41744930"></a><!-- doxytag: member="chthreads.h::chThdAddRef" ref="gabefc5734beaf29ae0bcd52cd41744930" args="(Thread *tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_thread.html">Thread</a> * chThdAddRef </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td>
<td class="paramname"> <em>tp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Adds a reference to a thread object. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>pointer to the thread </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The same thread pointer passed as parameter representing the new reference. </dd></dl>
2010-11-30 04:54:43 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00418">418</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, and <a class="el" href="struct_thread.html#af86d1da435197d113bc42fe8139a21c5">Thread::p_refs</a>.</p>
</div>
</div>
<a class="anchor" id="gaa22f80040cf192015be4607f31a0ac80"></a><!-- doxytag: member="chthreads.h::chThdRelease" ref="gaa22f80040cf192015be4607f31a0ac80" args="(Thread *tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chThdRelease </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td>
<td class="paramname"> <em>tp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Releases a reference to a thread object. </p>
<p>If the references counter reaches zero <b>and</b> the thread is in the <code>THD_STATE_FINAL</code> state then the thread's memory is returned to the proper allocator. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>Static threads are not affected.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>pointer to the thread </td></tr>
</table>
</dd>
</dl>
2010-11-30 04:54:43 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00436">436</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
2010-11-30 04:54:43 +00:00
<p>References <a class="el" href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <a class="el" href="group__heaps.html#ga0fc553df0138f02e0b233be91e413c79">chHeapFree()</a>, <a class="el" href="group__pools.html#ga978f8d038e8e981bf9e5a104b81c6cb6">chPoolFree()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="struct_thread.html#a1e044ddc7521288d6fb473756a214d23">Thread::p_flags</a>, <a class="el" href="struct_thread.html#ae0e65912a0c02df5477a3a524cd41d97">Thread::p_mpool</a>, <a class="el" href="struct_thread.html#af86d1da435197d113bc42fe8139a21c5">Thread::p_refs</a>, <a class="el" href="struct_thread.html#a3c3e9d6abccb62c3a5fab6ef043a391f">Thread::p_state</a>, <a class="el" href="group__registry.html#ga472c6eb9a86e5963f452aa78719c92da">REG_REMOVE</a>, <a class="el" href="group__threads.html#ga706ca53f21d35623480e8e5a239c3fcb">THD_MEM_MODE_HEAP</a>, <a class="el" href="group__threads.html#ga03fc66bb40f45829816cd4e8353fead2">THD_MEM_MODE_MASK</a>, <a class="el" href="group__threads.html#ga70a7c2fa69d7ca90e6f191c2ebd8cc6f">THD_MEM_MODE_MEMPOOL</a>, and <a class="el" href="group__threads.html#ga10583a3a3fb4c62693bb08796f8d13ae">THD_STATE_FINAL</a>.</p>
2010-08-10 03:11:02 +00:00
<p>Referenced by <a class="el" href="group__registry.html#gaefff43a49fb7888a596319d67cf01dab">chRegNextThread()</a>, and <a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409">chThdWait()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_gaa22f80040cf192015be4607f31a0ac80_cgraph.png" border="0" usemap="#group__threads_gaa22f80040cf192015be4607f31a0ac80_cgraph" alt=""/></div>
<map name="group__threads_gaa22f80040cf192015be4607f31a0ac80_cgraph" id="group__threads_gaa22f80040cf192015be4607f31a0ac80_cgraph">
<area shape="rect" id="node3" href="group__heaps.html#ga0fc553df0138f02e0b233be91e413c79" title="Frees a previously allocated memory block." alt="" coords="145,5,225,32"/> <area shape="rect" id="node5" href="group__pools.html#ga978f8d038e8e981bf9e5a104b81c6cb6" title="Releases (or adds) an object into (to) a memory pool." alt="" coords="148,56,223,83"/> <area shape="rect" id="node7" href="group__pools.html#gab5c6c04fd14fbeee2183ca955371c515" title="Releases (or adds) an object into (to) a memory pool." alt="" coords="276,56,353,83"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
<a class="anchor" id="ga94a5727ecdbe0f738dfc8e1ede1c3409"></a><!-- doxytag: member="chthreads.h::chThdWait" ref="ga94a5727ecdbe0f738dfc8e1ede1c3409" args="(Thread *tp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
2010-11-22 05:53:37 +00:00
<td class="memname"><a class="el" href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3">msg_t</a> chThdWait </td>
2010-08-10 03:11:02 +00:00
<td>(</td>
<td class="paramtype"><a class="el" href="struct_thread.html">Thread</a> *&nbsp;</td>
<td class="paramname"> <em>tp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned. </p>
<p>This function waits for the specified thread to terminate then decrements its reference counter, if the counter reaches zero then the thread working area is returned to the proper allocator.<br/>
The memory used by the exited thread is handled in different ways depending on the API that spawned the thread:</p>
<ul>
2010-11-22 05:53:37 +00:00
<li>If the thread was spawned by <code><a class="el" href="group__threads.html#ga048e588238dd336c6059133b3d0c3435" title="Creates a new thread into a static memory area.">chThdCreateStatic()</a></code> or by <code>chThdInit()</code> then nothing happens and the thread working area is not released or modified in any way. This is the default, totally static, behavior.</li>
2010-08-10 03:11:02 +00:00
<li>If the thread was spawned by <code><a class="el" href="group__threads.html#ga50b84e3e82a4e09c1066e1d422e4c780" title="Creates a new thread allocating the memory from the heap.">chThdCreateFromHeap()</a></code> then the working area is returned to the system heap.</li>
2010-11-22 05:53:37 +00:00
<li>If the thread was spawned by <code><a class="el" href="group__threads.html#gad3ccc1a6f054c543258ed2fe97ed2f58" title="Creates a new thread allocating the memory from the specified memory pool.">chThdCreateFromMemoryPool()</a></code> then the working area is returned to the owning memory pool.</li>
2010-08-10 03:11:02 +00:00
</ul>
2010-11-22 05:53:37 +00:00
<p>Please read the <a class="el" href="article_lifecycle.html">Threads Lifecycle</a> article for more details. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>After invoking <code><a class="el" href="group__threads.html#ga94a5727ecdbe0f738dfc8e1ede1c3409" title="Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...">chThdWait()</a></code> the thread pointer becomes invalid and must not be used as parameter for further system calls. </dd>
2010-08-10 03:11:02 +00:00
<dd>
The function is available only if the <code>CH_USE_WAITEXIT</code> option is enabled in <code><a class="el" href="chconf_8h.html" title="Configuration file template.">chconf.h</a></code>. </dd>
<dd>
If <code>CH_USE_DYNAMIC</code> is not specified this function just waits for the thread termination, no memory allocators are involved.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>tp</em>&nbsp;</td><td>pointer to the thread </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The exit code from the terminated thread. </dd></dl>
2010-11-30 04:54:43 +00:00
<p>Definition at line <a class="el" href="chthreads_8c_source.html#l00499">499</a> of file <a class="el" href="chthreads_8c_source.html">chthreads.c</a>.</p>
2010-08-10 03:11:02 +00:00
<p>References <a class="el" href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986">chSchGoSleepS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <a class="el" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease()</a>, <a class="el" href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7">currp</a>, <a class="el" href="struct_thread.html#addbf4614b204bdc2a3480c434cf7baaf">Thread::exitcode</a>, <a class="el" href="group__internals.html#ga5818ce2d363d36402baece614b06e41b">list_insert()</a>, <a class="el" href="struct_thread.html#af86d1da435197d113bc42fe8139a21c5">Thread::p_refs</a>, <a class="el" href="struct_thread.html#a3c3e9d6abccb62c3a5fab6ef043a391f">Thread::p_state</a>, <a class="el" href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a">Thread::p_u</a>, <a class="el" href="struct_thread.html#ad1088bc1f9970cc102dc28000134e9ab">Thread::p_waiting</a>, <a class="el" href="group__threads.html#ga10583a3a3fb4c62693bb08796f8d13ae">THD_STATE_FINAL</a>, and <a class="el" href="group__threads.html#gaf726245829b74db3a77a5f4bcc17bf67">THD_STATE_WTEXIT</a>.</p>
<p>Referenced by <a class="el" href="classchibios__rt_1_1_base_thread.html#a8b4a3de70b98980e6836a48f3e97969c">chibios_rt::BaseThread::Wait()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
2010-11-22 05:53:37 +00:00
<div class="dyncontent">
<div class="center"><img src="group__threads_ga94a5727ecdbe0f738dfc8e1ede1c3409_cgraph.png" border="0" usemap="#group__threads_ga94a5727ecdbe0f738dfc8e1ede1c3409_cgraph" alt=""/></div>
<map name="group__threads_ga94a5727ecdbe0f738dfc8e1ede1c3409_cgraph" id="group__threads_ga94a5727ecdbe0f738dfc8e1ede1c3409_cgraph">
<area shape="rect" id="node3" href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986" title="Puts the current thread to sleep into the specified state." alt="" coords="128,56,229,83"/> <area shape="rect" id="node9" href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80" title="Releases a reference to a thread object." alt="" coords="133,107,224,133"/> <area shape="rect" id="node15" href="group__internals.html#ga5818ce2d363d36402baece614b06e41b" title="Pushes a Thread on top of a stack list." alt="" coords="145,157,212,184"/> <area shape="rect" id="node5" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="279,5,359,32"/> <area shape="rect" id="node7" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a" title="Removes the first&#45;out Thread from a queue and returns it." alt="" coords="279,56,359,83"/> <area shape="rect" id="node11" href="group__heaps.html#ga0fc553df0138f02e0b233be91e413c79" title="Frees a previously allocated memory block." alt="" coords="279,107,359,133"/> <area shape="rect" id="node13" href="group__pools.html#ga978f8d038e8e981bf9e5a104b81c6cb6" title="Releases (or adds) an object into (to) a memory pool." alt="" coords="281,157,356,184"/> </map>
2010-08-10 03:11:02 +00:00
</div>
</p>
</div>
</div>
</div>
<hr size="1"><address style="text-align: right;"><small>
2010-11-30 04:54:43 +00:00
Generated on Sun Nov 28 2010 14:09:56 for ChibiOS/RT by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.7.1</small></address>
2010-08-10 03:11:02 +00:00
</body>
</html>