gnuk/ChibiOS_2.0.2/docs/html/group__mutexes.html
2010-08-10 12:11:02 +09:00

508 lines
38 KiB
HTML

<!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: Mutexes</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">
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<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>
<div class="contents">
<h1>Mutexes<br/>
<small>
[<a class="el" href="group__synchronization.html">Synchronization</a>]</small>
</h1>
<p><div class="dynheader">
Collaboration diagram for Mutexes:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__mutexes.png" border="0" alt="" usemap="#group____mutexes_map"/>
<map name="group____mutexes_map" id="group____mutexes">
<area shape="rect" href="group__synchronization.html" title="Synchronization" alt="" coords="7,5,105,29"/>
</map></td></tr></table></center>
</div>
</p>
<hr/><a name="_details"></a><h2>Description</h2>
<p>Mutexes related APIs and services.</p>
<h2>Operation mode</h2>
<p>A mutex is a threads synchronization object that can be in two distinct states:</p>
<ul>
<li>Not owned.</li>
<li>Owned by a thread.</li>
</ul>
<p>Operations defined for mutexes:</p>
<ul>
<li><b>Lock</b>: The mutex is checked, if the mutex is not owned by some other thread then it is associated to the locking thread else the thread is queued on the mutex in a list ordered by priority.</li>
<li><b>Unlock</b>: The mutex is released by the owner and the highest priority thread waiting in the queue, if any, is resumed and made owner of the mutex.</li>
</ul>
<p>In order to use the Mutexes APIs the <code>CH_USE_MUTEXES</code> option must be enabled in <code><a class="el" href="chconf_8h.html" title="Configuration file template.">chconf.h</a></code>. </p>
<h2>Constraints</h2>
<p>In ChibiOS/RT the Unlock operations are always performed in lock-reverse order. The unlock API does not even have a parameter, the mutex to unlock is selected from an internal, per-thread, stack of owned mutexes. This both improves the performance and is required for an efficient implementation of the priority inheritance mechanism.</p>
<h2>The priority inversion problem</h2>
<p>The mutexes in ChibiOS/RT implements the <b>full</b> priority inheritance mechanism in order handle the priority inversion problem.<br/>
When a thread is queued on a mutex, any thread, directly or indirectly, holding the mutex gains the same priority of the waiting thread (if their priority was not already equal or higher). The mechanism works with any number of nested mutexes and any number of involved threads. The algorithm complexity (worst case) is N with N equal to the number of nested mutexes. </p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_mutex.html">Mutex</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a> structure. <a href="struct_mutex.html#_details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#ga01a9ed719f222e64589413d6eda7396e">_MUTEX_DATA</a>(name)&nbsp;&nbsp;&nbsp;{_THREADSQUEUE_DATA(name.m_queue), NULL, NULL}</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Data part of a static mutex initializer. <a href="#ga01a9ed719f222e64589413d6eda7396e"></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__mutexes.html#ga0461d963db5d730f1829eb783f6fdf94">MUTEX_DECL</a>(name)&nbsp;&nbsp;&nbsp;<a class="el" href="struct_mutex.html">Mutex</a> name = _MUTEX_DATA(name)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Static mutex initializer. <a href="#ga0461d963db5d730f1829eb783f6fdf94"></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__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63">chMtxQueueNotEmptyS</a>(mp)&nbsp;&nbsp;&nbsp;notempty(&amp;(mp)-&gt;m_queue)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns <code>TRUE</code> if the mutex queue contains at least a waiting thread. <a href="#ga322ebcfba68cf5b66b9c315638e3ae63"></a><br/></td></tr>
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct_mutex.html">Mutex</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#ga9b2dfabf6db35faa7fd04ea30834012d">Mutex</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a> structure. <a href="#ga9b2dfabf6db35faa7fd04ea30834012d"></a><br/></td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#gac55fe4d05aa6bbeb31594193d2e4d2b6">chMtxInit</a> (<a class="el" href="struct_mutex.html">Mutex</a> *mp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initializes s <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure. <a href="#gac55fe4d05aa6bbeb31594193d2e4d2b6"></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__mutexes.html#gafa06b82e3496c44eb7bf31d9f1b655ba">chMtxLock</a> (<a class="el" href="struct_mutex.html">Mutex</a> *mp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Locks the specified mutex. <a href="#gafa06b82e3496c44eb7bf31d9f1b655ba"></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__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS</a> (<a class="el" href="struct_mutex.html">Mutex</a> *mp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Locks the specified mutex. <a href="#ga2d6350c2d147d1165c359f30798205f5"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___s_t_m8___c_o_r_e.html#gaf900ae86327eeeb5750901c89f1f8912">bool_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#gaada14e216460dc55e1816234168cf95c">chMtxTryLock</a> (<a class="el" href="struct_mutex.html">Mutex</a> *mp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Tries to lock a mutex. <a href="#gaada14e216460dc55e1816234168cf95c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___s_t_m8___c_o_r_e.html#gaf900ae86327eeeb5750901c89f1f8912">bool_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#gadbf0bd4a36b1f7e33ee41939df32ab78">chMtxTryLockS</a> (<a class="el" href="struct_mutex.html">Mutex</a> *mp)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Tries to lock a mutex. <a href="#gadbf0bd4a36b1f7e33ee41939df32ab78"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#gae9ae07165126c9f6c0ce0b17bdb53669">chMtxUnlock</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Unlocks the next owned mutex in reverse lock order. <a href="#gae9ae07165126c9f6c0ce0b17bdb53669"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mutexes.html#ga705fa60fb8aa28a6632f693e83f78c96">chMtxUnlockS</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Unlocks the next owned mutex in reverse lock order. <a href="#ga705fa60fb8aa28a6632f693e83f78c96"></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__mutexes.html#ga853b4ced43d22fb5d82678dd2f0aba75">chMtxUnlockAll</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Unlocks all the mutexes owned by the invoking thread. <a href="#ga853b4ced43d22fb5d82678dd2f0aba75"></a><br/></td></tr>
</table>
<hr/><h2>Define Documentation</h2>
<a class="anchor" id="ga01a9ed719f222e64589413d6eda7396e"></a><!-- doxytag: member="chmtx.h::_MUTEX_DATA" ref="ga01a9ed719f222e64589413d6eda7396e" args="(name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define _MUTEX_DATA</td>
<td>(</td>
<td class="paramtype">name&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;{_THREADSQUEUE_DATA(name.m_queue), NULL, NULL}</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Data part of a static mutex initializer. </p>
<p>This macro should be used when statically initializing a mutex that is part of a bigger 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>name</em>&nbsp;</td><td>the name of the mutex variable </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8h_source.html#l00074">74</a> of file <a class="el" href="chmtx_8h_source.html">chmtx.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga0461d963db5d730f1829eb783f6fdf94"></a><!-- doxytag: member="chmtx.h::MUTEX_DECL" ref="ga0461d963db5d730f1829eb783f6fdf94" args="(name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MUTEX_DECL</td>
<td>(</td>
<td class="paramtype">name&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;<a class="el" href="struct_mutex.html">Mutex</a> name = _MUTEX_DATA(name)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Static mutex initializer. </p>
<p>Statically initialized mutexes require no explicit initialization using <code><a class="el" href="group__mutexes.html#gac55fe4d05aa6bbeb31594193d2e4d2b6" title="Initializes s Mutex structure.">chMtxInit()</a></code>.</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>name</em>&nbsp;</td><td>the name of the mutex variable </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8h_source.html#l00083">83</a> of file <a class="el" href="chmtx_8h_source.html">chmtx.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga322ebcfba68cf5b66b9c315638e3ae63"></a><!-- doxytag: member="chmtx.h::chMtxQueueNotEmptyS" ref="ga322ebcfba68cf5b66b9c315638e3ae63" args="(mp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define chMtxQueueNotEmptyS</td>
<td>(</td>
<td class="paramtype">mp&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;notempty(&amp;(mp)-&gt;m_queue)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns <code>TRUE</code> if the mutex queue contains at least a waiting thread. </p>
<p>Definition at line <a class="el" href="chmtx_8h_source.html#l00089">89</a> of file <a class="el" href="chmtx_8h_source.html">chmtx.h</a>.</p>
<p>Referenced by <a class="el" href="group__mutexes.html#gae9ae07165126c9f6c0ce0b17bdb53669">chMtxUnlock()</a>, <a class="el" href="group__mutexes.html#ga853b4ced43d22fb5d82678dd2f0aba75">chMtxUnlockAll()</a>, and <a class="el" href="group__mutexes.html#ga705fa60fb8aa28a6632f693e83f78c96">chMtxUnlockS()</a>.</p>
</div>
</div>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="ga9b2dfabf6db35faa7fd04ea30834012d"></a><!-- doxytag: member="chmtx.h::Mutex" ref="ga9b2dfabf6db35faa7fd04ea30834012d" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef struct <a class="el" href="struct_mutex.html">Mutex</a> <a class="el" href="struct_mutex.html">Mutex</a></td>
</tr>
</table>
</div>
<div class="memdoc">
<p><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a> structure. </p>
</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gac55fe4d05aa6bbeb31594193d2e4d2b6"></a><!-- doxytag: member="chmtx.h::chMtxInit" ref="gac55fe4d05aa6bbeb31594193d2e4d2b6" args="(Mutex *mp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chMtxInit </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td>
<td class="paramname"> <em>mp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Initializes s <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure. </p>
<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>mp</em>&nbsp;</td><td>pointer to a <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00081">81</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941">Mutex::m_owner</a>, <a class="el" href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f">Mutex::m_queue</a>, and <a class="el" href="group__internals.html#ga6d19d0f3ff1fa599b6d9783dec180451">queue_init</a>.</p>
<p>Referenced by <a class="el" href="group__heaps.html#ga7135c9ddbd1402a4a36ce44df948f4e4">chHeapInit()</a>, <a class="el" href="group__heaps.html#ga7e7a6625a49b6a560a47ae7575575264">heap_init()</a>, <a class="el" href="classchibios__rt_1_1_mutex.html#a00b2ff557451955a905ecdca2855389b">chibios_rt::Mutex::Mutex()</a>, and <a class="el" href="group___s_p_i.html#ga87a7bdc554b8e8fdfc77064e67689fcf">spiObjectInit()</a>.</p>
</div>
</div>
<a class="anchor" id="gafa06b82e3496c44eb7bf31d9f1b655ba"></a><!-- doxytag: member="chmtx.h::chMtxLock" ref="gafa06b82e3496c44eb7bf31d9f1b655ba" args="(Mutex *mp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chMtxLock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td>
<td class="paramname"> <em>mp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Locks the specified mutex. </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>mp</em>&nbsp;</td><td>pointer to the <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00094">94</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5">chMtxLockS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
<p>Referenced by <a class="el" href="classchibios__rt_1_1_mutex.html#a1726d7244983f7be74fcfa9cfb63745f">chibios_rt::Mutex::Lock()</a>, and <a class="el" href="group___s_p_i.html#ga803cec73f6dd8d3d1f18fb6a61b8255a">spiAcquireBus()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__mutexes_gafa06b82e3496c44eb7bf31d9f1b655ba_cgraph.png" border="0" usemap="#group__mutexes_gafa06b82e3496c44eb7bf31d9f1b655ba_cgraph_map" alt=""></div>
<map name="group__mutexes_gafa06b82e3496c44eb7bf31d9f1b655ba_cgraph_map" id="group__mutexes_gafa06b82e3496c44eb7bf31d9f1b655ba_cgraph">
<area shape="rect" href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5" title="Locks the specified mutex." alt="" coords="128,77,208,101"/>
<area shape="rect" href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986" title="Puts the current thread to sleep into the specified state." alt="" coords="257,5,356,29"/>
<area shape="rect" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="264,53,349,77"/>
<area shape="rect" href="group__internals.html#gafff11bcd31d7dc3d1a0a6c66f3fc6ec9" title="Removes a Thread from a queue and returns it." alt="" coords="275,101,339,125"/>
<area shape="rect" href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2" title="Inserts a thread into a priority ordered queue." alt="" coords="271,149,343,173"/>
</map>
</div>
</p>
</div>
</div>
<a class="anchor" id="ga2d6350c2d147d1165c359f30798205f5"></a><!-- doxytag: member="chmtx.h::chMtxLockS" ref="ga2d6350c2d147d1165c359f30798205f5" args="(Mutex *mp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chMtxLockS </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td>
<td class="paramname"> <em>mp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Locks the specified mutex. </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>mp</em>&nbsp;</td><td>pointer to the <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00108">108</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<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__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298">chSchReadyI()</a>, <a class="el" href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7">currp</a>, <a class="el" href="group__internals.html#gafff11bcd31d7dc3d1a0a6c66f3fc6ec9">dequeue()</a>, <a class="el" href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd">Mutex::m_next</a>, <a class="el" href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941">Mutex::m_owner</a>, <a class="el" href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f">Mutex::m_queue</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#a3c3e9d6abccb62c3a5fab6ef043a391f">Thread::p_state</a>, <a class="el" href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a">Thread::p_u</a>, <a class="el" href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2">prio_insert()</a>, <a class="el" href="group__threads.html#ga1f7b83c73a5b850a3f33bddbdb024fb3">THD_STATE_READY</a>, <a class="el" href="group__threads.html#gaff813590802bfd53cbf0560b680b89f5">THD_STATE_SNDMSG</a>, <a class="el" href="group__threads.html#ga286c5b1a6459d654d5794fc17e93c939">THD_STATE_WTCOND</a>, <a class="el" href="group__threads.html#gac18de5096ff3c841e69672cab0868cdf">THD_STATE_WTMTX</a>, <a class="el" href="group__threads.html#gad0b81cae859c0a6bc6a0d2036aa8e272">THD_STATE_WTSEM</a>, and <a class="el" href="struct_thread.html#a4f016b01444741e6f9b420436b748862">Thread::wtobjp</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#gafa06b82e3496c44eb7bf31d9f1b655ba">chMtxLock()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__mutexes_ga2d6350c2d147d1165c359f30798205f5_cgraph.png" border="0" usemap="#group__mutexes_ga2d6350c2d147d1165c359f30798205f5_cgraph_map" alt=""></div>
<map name="group__mutexes_ga2d6350c2d147d1165c359f30798205f5_cgraph_map" id="group__mutexes_ga2d6350c2d147d1165c359f30798205f5_cgraph">
<area shape="rect" href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986" title="Puts the current thread to sleep into the specified state." alt="" coords="135,29,233,53"/>
<area shape="rect" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="141,77,227,101"/>
<area shape="rect" href="group__internals.html#gafff11bcd31d7dc3d1a0a6c66f3fc6ec9" title="Removes a Thread from a queue and returns it." alt="" coords="152,125,216,149"/>
<area shape="rect" href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2" title="Inserts a thread into a priority ordered queue." alt="" coords="148,173,220,197"/>
<area shape="rect" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="283,5,363,29"/>
<area shape="rect" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a" title="Removes the first&#45;out Thread from a queue and returns it." alt="" coords="283,53,363,77"/>
</map>
</div>
</p>
</div>
</div>
<a class="anchor" id="gaada14e216460dc55e1816234168cf95c"></a><!-- doxytag: member="chmtx.h::chMtxTryLock" ref="gaada14e216460dc55e1816234168cf95c" args="(Mutex *mp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___s_t_m8___c_o_r_e.html#gaf900ae86327eeeb5750901c89f1f8912">bool_t</a> chMtxTryLock </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td>
<td class="paramname"> <em>mp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Tries to lock a mutex. </p>
<p>This function does not have any overhead related to the priority inheritance mechanism because it does not try to enter a sleep state on the mutex.</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>mp</em>&nbsp;</td><td>pointer to the <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure </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>if the mutex was successfully acquired </td></tr>
<tr><td valign="top"></td><td valign="top"><em>FALSE</em>&nbsp;</td><td>if the lock attempt failed. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00178">178</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__mutexes.html#gadbf0bd4a36b1f7e33ee41939df32ab78">chMtxTryLockS()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
<p>Referenced by <a class="el" href="classchibios__rt_1_1_mutex.html#a787ecfd207fd25760a3c07517b69c148">chibios_rt::Mutex::TryLock()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__mutexes_gaada14e216460dc55e1816234168cf95c_cgraph.png" border="0" usemap="#group__mutexes_gaada14e216460dc55e1816234168cf95c_cgraph_map" alt=""></div>
<map name="group__mutexes_gaada14e216460dc55e1816234168cf95c_cgraph_map" id="group__mutexes_gaada14e216460dc55e1816234168cf95c_cgraph">
<area shape="rect" href="group__mutexes.html#gadbf0bd4a36b1f7e33ee41939df32ab78" title="Tries to lock a mutex." alt="" coords="144,5,240,29"/>
</map>
</div>
</p>
</div>
</div>
<a class="anchor" id="gadbf0bd4a36b1f7e33ee41939df32ab78"></a><!-- doxytag: member="chmtx.h::chMtxTryLockS" ref="gadbf0bd4a36b1f7e33ee41939df32ab78" args="(Mutex *mp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group___s_t_m8___c_o_r_e.html#gaf900ae86327eeeb5750901c89f1f8912">bool_t</a> chMtxTryLockS </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_mutex.html">Mutex</a> *&nbsp;</td>
<td class="paramname"> <em>mp</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Tries to lock a mutex. </p>
<p>This function does not have any overhead related to the priority inheritance mechanism because it does not try to enter a sleep state on the mutex.</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>mp</em>&nbsp;</td><td>pointer to the <code><a class="el" href="struct_mutex.html" title="Mutex structure.">Mutex</a></code> structure </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>if the mutex was successfully acquired </td></tr>
<tr><td valign="top"></td><td valign="top"><em>FALSE</em>&nbsp;</td><td>if the lock attempt failed. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00199">199</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <a class="el" href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7">currp</a>, <a class="el" href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd">Mutex::m_next</a>, and <a class="el" href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941">Mutex::m_owner</a>.</p>
<p>Referenced by <a class="el" href="group__mutexes.html#gaada14e216460dc55e1816234168cf95c">chMtxTryLock()</a>.</p>
</div>
</div>
<a class="anchor" id="gae9ae07165126c9f6c0ce0b17bdb53669"></a><!-- doxytag: member="chmtx.h::chMtxUnlock" ref="gae9ae07165126c9f6c0ce0b17bdb53669" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_mutex.html">Mutex</a> * chMtxUnlock </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>Unlocks the next owned mutex in reverse lock order. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the unlocked mutex. </dd></dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00216">216</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <a class="el" href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63">chMtxQueueNotEmptyS</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__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7">currp</a>, <a class="el" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a">fifo_remove()</a>, <a class="el" href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd">Mutex::m_next</a>, <a class="el" href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941">Mutex::m_owner</a>, <a class="el" href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f">Mutex::m_queue</a>, <a class="el" href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017">Thread::p_mtxlist</a>, <a class="el" href="struct_threads_queue.html#af4a099c245d7ceecdf2f9755d05d0ed0">ThreadsQueue::p_next</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>, and <a class="el" href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61">RDY_OK</a>.</p>
<p>Referenced by <a class="el" href="group___s_p_i.html#ga1b04a2410ef4323ee4e37c63f320c18f">spiReleaseBus()</a>, and <a class="el" href="classchibios__rt_1_1_mutex.html#a03150e8fa423f7e042661d350d238b84">chibios_rt::Mutex::Unlock()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__mutexes_gae9ae07165126c9f6c0ce0b17bdb53669_cgraph.png" border="0" usemap="#group__mutexes_gae9ae07165126c9f6c0ce0b17bdb53669_cgraph_map" alt=""></div>
<map name="group__mutexes_gae9ae07165126c9f6c0ce0b17bdb53669_cgraph_map" id="group__mutexes_gae9ae07165126c9f6c0ce0b17bdb53669_cgraph">
<area shape="rect" href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95" title="Wakes up a thread." alt="" coords="136,29,235,53"/>
<area shape="rect" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a" title="Removes the first&#45;out Thread from a queue and returns it." alt="" coords="145,77,225,101"/>
<area shape="rect" href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7" title="Inserts in the circular debug trace buffer a context switch record." alt="" coords="285,5,365,29"/>
<area shape="rect" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="283,53,368,77"/>
</map>
</div>
</p>
</div>
</div>
<a class="anchor" id="ga705fa60fb8aa28a6632f693e83f78c96"></a><!-- doxytag: member="chmtx.h::chMtxUnlockS" ref="ga705fa60fb8aa28a6632f693e83f78c96" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="struct_mutex.html">Mutex</a> * chMtxUnlockS </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>Unlocks the next owned mutex in reverse lock order. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>This function does not reschedule internally.</dd></dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The pointer to the unlocked mutex. </dd></dl>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00270">270</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9">chDbgAssert</a>, <a class="el" href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63">chMtxQueueNotEmptyS</a>, <a class="el" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298">chSchReadyI()</a>, <a class="el" href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7">currp</a>, <a class="el" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a">fifo_remove()</a>, <a class="el" href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd">Mutex::m_next</a>, <a class="el" href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941">Mutex::m_owner</a>, <a class="el" href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f">Mutex::m_queue</a>, <a class="el" href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017">Thread::p_mtxlist</a>, <a class="el" href="struct_threads_queue.html#af4a099c245d7ceecdf2f9755d05d0ed0">ThreadsQueue::p_next</a>, <a class="el" href="struct_thread.html#ae60cc22956f4c19965cb94045333aa9c">Thread::p_prio</a>, and <a class="el" href="struct_thread.html#a38de11dd7f8cdcfbc45b2c467f400fe8">Thread::p_realprio</a>.</p>
<p>Referenced by <a class="el" href="group__condvars.html#gab6357d80b01ed8d225ef1e30a66248f9">chCondWaitS()</a>, and <a class="el" href="group__condvars.html#ga9cf6ebe4c9f28cb206fab14984a18d29">chCondWaitTimeoutS()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__mutexes_ga705fa60fb8aa28a6632f693e83f78c96_cgraph.png" border="0" usemap="#group__mutexes_ga705fa60fb8aa28a6632f693e83f78c96_cgraph_map" alt=""></div>
<map name="group__mutexes_ga705fa60fb8aa28a6632f693e83f78c96_cgraph_map" id="group__mutexes_ga705fa60fb8aa28a6632f693e83f78c96_cgraph">
<area shape="rect" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="144,5,229,29"/>
<area shape="rect" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a" title="Removes the first&#45;out Thread from a queue and returns it." alt="" coords="147,53,227,77"/>
</map>
</div>
</p>
</div>
</div>
<a class="anchor" id="ga853b4ced43d22fb5d82678dd2f0aba75"></a><!-- doxytag: member="chmtx.h::chMtxUnlockAll" ref="ga853b4ced43d22fb5d82678dd2f0aba75" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void chMtxUnlockAll </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>Unlocks all the mutexes owned by the invoking thread. </p>
<p>This function is <b>MUCH MORE</b> efficient than releasing the mutexes one by one and not just because the call overhead, this function does not have any overhead related to the priority inheritance mechanism. </p>
<p>Definition at line <a class="el" href="chmtx_8c_source.html#l00322">322</a> of file <a class="el" href="chmtx_8c_source.html">chmtx.c</a>.</p>
<p>References <a class="el" href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63">chMtxQueueNotEmptyS</a>, <a class="el" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298">chSchReadyI()</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__internals.html#ga042479f09357fc59befebf4dfe0e9f4a">fifo_remove()</a>, <a class="el" href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd">Mutex::m_next</a>, <a class="el" href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941">Mutex::m_owner</a>, <a class="el" href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f">Mutex::m_queue</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>, and <a class="el" href="struct_thread.html#a38de11dd7f8cdcfbc45b2c467f400fe8">Thread::p_realprio</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__mutexes_ga853b4ced43d22fb5d82678dd2f0aba75_cgraph.png" border="0" usemap="#group__mutexes_ga853b4ced43d22fb5d82678dd2f0aba75_cgraph_map" alt=""></div>
<map name="group__mutexes_ga853b4ced43d22fb5d82678dd2f0aba75_cgraph_map" id="group__mutexes_ga853b4ced43d22fb5d82678dd2f0aba75_cgraph">
<area shape="rect" href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298" title="Inserts a thread in the Ready List." alt="" coords="488,5,573,29"/>
<area shape="rect" href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20" title="Performs a reschedule if a higher priority thread is runnable." alt="" coords="151,29,265,53"/>
<area shape="rect" href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a" title="Removes the first&#45;out Thread from a queue and returns it." alt="" coords="491,53,571,77"/>
<area shape="rect" href="group__scheduler.html#ga0257cf203e72a766a52059750cb97e6e" title="Switches to the first thread on the runnable queue." alt="" coords="316,29,439,53"/>
</map>
</div>
</p>
</div>
</div>
</div>
<hr size="1"><address style="text-align: right;"><small>
Generated on Sun Jul 11 13:13:13 2010 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.6.3</small></address>
</body>
</html>