<p>Threads Registry related APIs and services.</p>
<h2>Operation mode</h2>
<p>The Threads Registry is a double linked list that holds all the active threads in the system.<br/>
Operations defined for the registry:</p>
<ul>
<li><b>First</b>, returns the first, in creation order, active thread in the system.</li>
<li><b>Next</b>, returns the next, in creation order, active thread in the system.</li>
</ul>
<p>The registry is meant to be mainly a debug feature, as example, using the registry a debugger can enumerate the active threads in any given moment or the shell can print the active threads and their state.<br/>
Another possible use is for centralized threads memory management, terminating threads can pulse an event source and an event handler can perform a scansion of the registry in order to recover the memory.<br/>
In order to use the threads registry the <code>CH_USE_REGISTRY</code> option must be enabled in <code><aclass="el"href="chconf_8h.html"title="Configuration file template.">chconf.h</a></code>. </p>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Removes a thread from the registry list. <ahref="#ga472c6eb9a86e5963f452aa78719c92da"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Adds a thread to the registry list. <ahref="#ga365d4805b1329b068d9211b680f43388"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the first thread in the system. <ahref="#ga55c0a485b40cf4acbfce0dd333f28513"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the thread next to the specified one. <ahref="#gaefff43a49fb7888a596319d67cf01dab"></a><br/></td></tr>
<dlclass="note"><dt><b>Note:</b></dt><dd>This macro is not meant for use in application code.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>tp</em> </td><td>thread to remove from the registry </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chregistry_8h_source.html#l00046">46</a> of file <aclass="el"href="chregistry_8h_source.html">chregistry.h</a>.</p>
<p>Referenced by <aclass="el"href="group__threads.html#ga24ab3a3a4d70214ee360867a1c3c75ac">chThdExit()</a>.</p>
(tp)->p_newer = (<aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *)&<aclass="code"href="group__scheduler.html#ga752cd9dbf0dc458b8b532182836ca38d"title="Ready list header.">rlist</a>; \
(tp)->p_older = <aclass="code"href="group__scheduler.html#ga752cd9dbf0dc458b8b532182836ca38d"title="Ready list header.">rlist</a>.<aclass="code"href="struct_ready_list.html#a5b122d594ffb1f9e400ef9ee69b7aa12"title="Older registry element.">r_older</a>; \
<dlclass="note"><dt><b>Note:</b></dt><dd>This macro is not meant for use in application code.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>tp</em> </td><td>thread to add to the registry </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chregistry_8h_source.html#l00057">57</a> of file <aclass="el"href="chregistry_8h_source.html">chregistry.h</a>.</p>
<p>Referenced by <aclass="el"href="group__threads.html#ga4f6ae58bb3cedfc03aacde6d49e49d35">init_thread()</a>.</p>
<p>Returns the most ancient thread in the system, usually this is the main thread unless it terminated. </p>
<dlclass="note"><dt><b>Note:</b></dt><dd>A reference is added to the returned thread in order to make sure it status is not lost. </dd>
<dd>
This function cannot return <code>NULL</code> because there is always at least one thread in the system.</dd></dl>
<dlclass="return"><dt><b>Returns:</b></dt><dd>A reference to the first thread. </dd></dl>
<p>Definition at line <aclass="el"href="chregistry_8c_source.html#l00070">70</a> of file <aclass="el"href="chregistry_8c_source.html">chregistry.c</a>.</p>
<p>References <aclass="el"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <aclass="el"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <aclass="el"href="struct_thread.html#af86d1da435197d113bc42fe8139a21c5">Thread::p_refs</a>, <aclass="el"href="struct_ready_list.html#adaf2a3d936298fdee21396af9cf640c9">ReadyList::r_newer</a>, and <aclass="el"href="group__scheduler.html#ga752cd9dbf0dc458b8b532182836ca38d">rlist</a>.</p>
<p>Returns the thread next to the specified one. </p>
<p>The reference counter of the specified thread is decremented and the reference counter of the returned thread is incremented.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>tp</em> </td><td>pointer to the thread </td></tr>
</table>
</dd>
</dl>
<dlclass="return"><dt><b>Returns:</b></dt><dd>A reference to the next thread. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>NULL</em> </td><td>if there is no next thread. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chregistry_8c_source.html#l00091">91</a> of file <aclass="el"href="chregistry_8c_source.html">chregistry.c</a>.</p>
<p>References <aclass="el"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <aclass="el"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <aclass="el"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <aclass="el"href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80">chThdRelease()</a>, <aclass="el"href="struct_thread.html#a735bed4a4185b8fd502c01d7ad491710">Thread::p_newer</a>, <aclass="el"href="struct_thread.html#af86d1da435197d113bc42fe8139a21c5">Thread::p_refs</a>, and <aclass="el"href="group__scheduler.html#ga752cd9dbf0dc458b8b532182836ca38d">rlist</a>.</p>
<areashape="rect"id="node3"href="group__threads.html#gaa22f80040cf192015be4607f31a0ac80"title="Releases a reference to a thread object."alt=""coords="163,31,253,57"/><areashape="rect"id="node5"href="group__heaps.html#ga0fc553df0138f02e0b233be91e413c79"title="Frees a previously allocated memory block."alt=""coords="303,5,383,32"/><areashape="rect"id="node7"href="group__pools.html#ga978f8d038e8e981bf9e5a104b81c6cb6"title="Releases (or adds) an object into (to) a memory pool."alt=""coords="305,56,380,83"/></map>
Generated on Sun Oct 24 2010 09:40:46 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>