<ahref="chmtx_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00072"></a>00072 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00085"></a>00085 <aclass="code"href="group__internals.html#ga6d19d0f3ff1fa599b6d9783dec180451"title="Threads queue initialization.">queue_init</a>(&mp-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>);
<aname="l00086"></a>00086 mp-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> = NULL;
<aname="l00094"></a><aclass="code"href="group__mutexes.html#gafa06b82e3496c44eb7bf31d9f1b655ba">00094</a><spanclass="keywordtype">void</span><aclass="code"href="group__mutexes.html#gafa06b82e3496c44eb7bf31d9f1b655ba"title="Locks the specified mutex.">chMtxLock</a>(<aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *mp) {
<aname="l00095"></a>00095
<aname="l00096"></a>00096 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00097"></a>00097
<aname="l00098"></a>00098 <aclass="code"href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5"title="Locks the specified mutex.">chMtxLockS</a>(mp);
<aname="l00099"></a>00099
<aname="l00100"></a>00100 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00126"></a>00126 <spanclass="keywordflow">case</span><aclass="code"href="group__threads.html#gac18de5096ff3c841e69672cab0868cdf"title="Thread state: Waiting on a mutex.">THD_STATE_WTMTX</a>:
<aname="l00127"></a>00127 <spanclass="comment">/* Re-enqueues the mutex owner with its new priority.*/</span>
<aname="l00128"></a>00128 <aclass="code"href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2"title="Inserts a thread into a priority ordered queue.">prio_insert</a>(<aclass="code"href="group__internals.html#gafff11bcd31d7dc3d1a0a6c66f3fc6ec9"title="Removes a Thread from a queue and returns it.">dequeue</a>(tp), (<aclass="code"href="struct_threads_queue.html"title="Generic threads bidirectional linked list header and element.">ThreadsQueue</a> *)tp-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#a4f016b01444741e6f9b420436b748862"title="Pointer to a generic &quot;wait&quot; object.">wtobjp</a>);
<aname="l00129"></a>00129 tp = ((<aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *)tp-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#a4f016b01444741e6f9b420436b748862"title="Pointer to a generic &quot;wait&quot; object.">wtobjp</a>)->m_owner;
<aname="l00136"></a>00136 <spanclass="preprocessor"></span><spanclass="keywordflow">case</span><aclass="code"href="group__threads.html#gad0b81cae859c0a6bc6a0d2036aa8e272"title="Thread state: Waiting on a semaphore.">THD_STATE_WTSEM</a>:
<aname="l00141"></a>00141 <spanclass="preprocessor"></span><spanclass="comment">/* Re-enqueues tp with its new priority on the queue.*/</span>
<aname="l00142"></a>00142 <aclass="code"href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2"title="Inserts a thread into a priority ordered queue.">prio_insert</a>(<aclass="code"href="group__internals.html#gafff11bcd31d7dc3d1a0a6c66f3fc6ec9"title="Removes a Thread from a queue and returns it.">dequeue</a>(tp), (<aclass="code"href="struct_threads_queue.html"title="Generic threads bidirectional linked list header and element.">ThreadsQueue</a> *)tp-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#a4f016b01444741e6f9b420436b748862"title="Pointer to a generic &quot;wait&quot; object.">wtobjp</a>);
<aname="l00145"></a>00145 <spanclass="preprocessor"></span><spanclass="keywordflow">case</span><aclass="code"href="group__threads.html#ga1f7b83c73a5b850a3f33bddbdb024fb3"title="Thread state: Ready to run, waiting on the ready list.">THD_STATE_READY</a>:
<aname="l00146"></a>00146 <spanclass="comment">/* Re-enqueues tp with its new priority on the ready list.*/</span>
<aname="l00147"></a>00147 <aclass="code"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List.">chSchReadyI</a>(<aclass="code"href="group__internals.html#gafff11bcd31d7dc3d1a0a6c66f3fc6ec9"title="Removes a Thread from a queue and returns it.">dequeue</a>(tp));
<aname="l00151"></a>00151 <spanclass="comment">/* Sleep on the mutex.*/</span>
<aname="l00152"></a>00152 <aclass="code"href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2"title="Inserts a thread into a priority ordered queue.">prio_insert</a>(ctp, &mp-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>);
<aname="l00153"></a>00153 ctp-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#a4f016b01444741e6f9b420436b748862"title="Pointer to a generic &quot;wait&quot; object.">wtobjp</a> = mp;
<aname="l00154"></a>00154 <aclass="code"href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986"title="Puts the current thread to sleep into the specified state.">chSchGoSleepS</a>(<aclass="code"href="group__threads.html#gac18de5096ff3c841e69672cab0868cdf"title="Thread state: Waiting on a mutex.">THD_STATE_WTMTX</a>);
<aname="l00155"></a>00155 <spanclass="comment">/* It is assumed that the thread performing the unlock operation assigns</span>
<aname="l00156"></a>00156 <spanclass="comment"> the mutex to this thread.*/</span>
<aname="l00158"></a>00158 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> == mp, <spanclass="stringliteral">"chMtxLockS(), #2"</span>, <spanclass="stringliteral">"not owned"</span>);
<aname="l00161"></a>00161 <spanclass="comment">/* It was not owned, inserted in the owned mutexes list.*/</span>
<aname="l00162"></a>00162 mp-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> = ctp;
<aname="l00163"></a>00163 mp-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a> = ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00164"></a>00164 ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = mp;
<aname="l00178"></a><aclass="code"href="group__mutexes.html#gaada14e216460dc55e1816234168cf95c">00178</a><aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a><aclass="code"href="group__mutexes.html#gaada14e216460dc55e1816234168cf95c"title="Tries to lock a mutex.">chMtxTryLock</a>(<aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *mp) {
<aname="l00179"></a>00179 <aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a> b;
<aname="l00180"></a>00180
<aname="l00181"></a>00181 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00182"></a>00182
<aname="l00183"></a>00183 b = <aclass="code"href="group__mutexes.html#gadbf0bd4a36b1f7e33ee41939df32ab78"title="Tries to lock a mutex.">chMtxTryLockS</a>(mp);
<aname="l00184"></a>00184
<aname="l00185"></a>00185 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00199"></a><aclass="code"href="group__mutexes.html#gadbf0bd4a36b1f7e33ee41939df32ab78">00199</a><aclass="code"href="group__types.html#ga7556af1cb61728b53228fa3af1c851de"title="Boolean, recommended the fastest signed.">bool_t</a><aclass="code"href="group__mutexes.html#gadbf0bd4a36b1f7e33ee41939df32ab78"title="Tries to lock a mutex.">chMtxTryLockS</a>(<aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *mp) {
<aname="l00206"></a>00206 mp-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a> = <aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>->p_mtxlist;
<aname="l00216"></a><aclass="code"href="group__mutexes.html#gae9ae07165126c9f6c0ce0b17bdb53669">00216</a><aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *<aclass="code"href="group__mutexes.html#gae9ae07165126c9f6c0ce0b17bdb53669"title="Unlocks the next owned mutex in reverse lock order.">chMtxUnlock</a>(<spanclass="keywordtype">void</span>) {
<aname="l00220"></a>00220 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00221"></a>00221 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> != NULL,
<aname="l00223"></a>00223 <spanclass="stringliteral">"owned mutexes list empty"</span>);
<aname="l00224"></a>00224 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> == ctp,
<aname="l00227"></a>00227 <spanclass="comment">/* Removes the top Mutex from the Threads's owned mutexes list and matk it</span>
<aname="l00228"></a>00228 <spanclass="comment"> as not owned.*/</span>
<aname="l00229"></a>00229 ump = ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00230"></a>00230 ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = ump-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a>;
<aname="l00231"></a>00231 <spanclass="comment">/* If a thread is waiting on the mutex then the fun part begins.*/</span>
<aname="l00232"></a>00232 <spanclass="keywordflow">if</span> (<aclass="code"href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63"title="Returns TRUE if the mutex queue contains at least a waiting thread.">chMtxQueueNotEmptyS</a>(ump)) {
<aname="l00233"></a>00233 <aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *tp;
<aname="l00234"></a>00234
<aname="l00235"></a>00235 <spanclass="comment">/* Recalculates the optimal thread priority by scanning the owned</span>
<aname="l00237"></a>00237 <aclass="code"href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee"title="Priority, use the fastest unsigned type.">tprio_t</a> newprio = ctp-><aclass="code"href="struct_thread.html#a38de11dd7f8cdcfbc45b2c467f400fe8"title="Thread&#39;s own, non-inherited, priority.">p_realprio</a>;
<aname="l00238"></a>00238 mp = ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00240"></a>00240 <spanclass="comment">/* If the highest priority thread waiting in the mutexes list has a</span>
<aname="l00241"></a>00241 <spanclass="comment"> greater priority than the current thread base priority then the final</span>
<aname="l00242"></a>00242 <spanclass="comment"> priority will have at least that priority.*/</span>
<aname="l00243"></a>00243 <spanclass="keywordflow">if</span> (<aclass="code"href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63"title="Returns TRUE if the mutex queue contains at least a waiting thread.">chMtxQueueNotEmptyS</a>(mp) && (mp-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>.<aclass="code"href="struct_threads_queue.html#af4a099c245d7ceecdf2f9755d05d0ed0">p_next</a>-><aclass="code"href="struct_thread.html#ae60cc22956f4c19965cb94045333aa9c"title="Thread priority.">p_prio</a>> newprio))
<aname="l00244"></a>00244 newprio = mp-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>.<aclass="code"href="struct_threads_queue.html#af4a099c245d7ceecdf2f9755d05d0ed0">p_next</a>-><aclass="code"href="struct_thread.html#ae60cc22956f4c19965cb94045333aa9c"title="Thread priority.">p_prio</a>;
<aname="l00245"></a>00245 mp = mp-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a>;
<aname="l00246"></a>00246 }
<aname="l00247"></a>00247 <spanclass="comment">/* Assigns to the current thread the highest priority among all the</span>
<aname="l00250"></a>00250 <spanclass="comment">/* Awakens the highest priority thread waiting for the unlocked mutex and</span>
<aname="l00251"></a>00251 <spanclass="comment"> assigns the mutex to it.*/</span>
<aname="l00252"></a>00252 tp = <aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&ump-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>);
<aname="l00253"></a>00253 ump-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> = tp;
<aname="l00254"></a>00254 ump-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a> = tp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00255"></a>00255 tp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = ump;
<aname="l00256"></a>00256 <aclass="code"href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95"title="Wakes up a thread.">chSchWakeupS</a>(tp, <aclass="code"href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61"title="Default thread wakeup low level message.">RDY_OK</a>);
<aname="l00270"></a><aclass="code"href="group__mutexes.html#ga705fa60fb8aa28a6632f693e83f78c96">00270</a><aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *<aclass="code"href="group__mutexes.html#ga705fa60fb8aa28a6632f693e83f78c96"title="Unlocks the next owned mutex in reverse lock order.">chMtxUnlockS</a>(<spanclass="keywordtype">void</span>) {
<aname="l00274"></a>00274 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> != NULL,
<aname="l00276"></a>00276 <spanclass="stringliteral">"owned mutexes list empty"</span>);
<aname="l00277"></a>00277 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> == ctp,
<aname="l00283"></a>00283 ump = ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00284"></a>00284 ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = ump-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a>;
<aname="l00285"></a>00285 <spanclass="comment">/* If a thread is waiting on the mutex then the fun part begins.*/</span>
<aname="l00286"></a>00286 <spanclass="keywordflow">if</span> (<aclass="code"href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63"title="Returns TRUE if the mutex queue contains at least a waiting thread.">chMtxQueueNotEmptyS</a>(ump)) {
<aname="l00287"></a>00287 <aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *tp;
<aname="l00288"></a>00288
<aname="l00289"></a>00289 <spanclass="comment">/* Recalculates the optimal thread priority by scanning the owned</span>
<aname="l00291"></a>00291 <aclass="code"href="group__types.html#ga5f2488ba73e5969cbc0f7033735374ee"title="Priority, use the fastest unsigned type.">tprio_t</a> newprio = ctp-><aclass="code"href="struct_thread.html#a38de11dd7f8cdcfbc45b2c467f400fe8"title="Thread&#39;s own, non-inherited, priority.">p_realprio</a>;
<aname="l00292"></a>00292 mp = ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00294"></a>00294 <spanclass="comment">/* If the highest priority thread waiting in the mutexes list has a</span>
<aname="l00295"></a>00295 <spanclass="comment"> greater priority than the current thread base priority then the final</span>
<aname="l00296"></a>00296 <spanclass="comment"> priority will have at least that priority.*/</span>
<aname="l00297"></a>00297 <spanclass="keywordflow">if</span> (<aclass="code"href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63"title="Returns TRUE if the mutex queue contains at least a waiting thread.">chMtxQueueNotEmptyS</a>(mp) && (mp-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>.<aclass="code"href="struct_threads_queue.html#af4a099c245d7ceecdf2f9755d05d0ed0">p_next</a>-><aclass="code"href="struct_thread.html#ae60cc22956f4c19965cb94045333aa9c"title="Thread priority.">p_prio</a>> newprio))
<aname="l00298"></a>00298 newprio = mp-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>.<aclass="code"href="struct_threads_queue.html#af4a099c245d7ceecdf2f9755d05d0ed0">p_next</a>-><aclass="code"href="struct_thread.html#ae60cc22956f4c19965cb94045333aa9c"title="Thread priority.">p_prio</a>;
<aname="l00299"></a>00299 mp = mp-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a>;
<aname="l00302"></a>00302 <spanclass="comment">/* Awakens the highest priority thread waiting for the unlocked mutex and</span>
<aname="l00303"></a>00303 <spanclass="comment"> assigns the mutex to it.*/</span>
<aname="l00304"></a>00304 tp = <aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&ump-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>);
<aname="l00305"></a>00305 ump-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> = tp;
<aname="l00306"></a>00306 ump-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a> = tp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00307"></a>00307 tp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = ump;
<aname="l00308"></a>00308 <aclass="code"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List.">chSchReadyI</a>(tp);
<aname="l00322"></a><aclass="code"href="group__mutexes.html#ga853b4ced43d22fb5d82678dd2f0aba75">00322</a><spanclass="keywordtype">void</span><aclass="code"href="group__mutexes.html#ga853b4ced43d22fb5d82678dd2f0aba75"title="Unlocks all the mutexes owned by the invoking thread.">chMtxUnlockAll</a>(<spanclass="keywordtype">void</span>) {
<aname="l00325"></a>00325 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00326"></a>00326 <spanclass="keywordflow">if</span> (ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> != NULL) {
<aname="l00328"></a>00328 <aclass="code"href="struct_mutex.html"title="Mutex structure.">Mutex</a> *ump = ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00329"></a>00329 ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = ump-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a>;
<aname="l00330"></a>00330 <spanclass="keywordflow">if</span> (<aclass="code"href="group__mutexes.html#ga322ebcfba68cf5b66b9c315638e3ae63"title="Returns TRUE if the mutex queue contains at least a waiting thread.">chMtxQueueNotEmptyS</a>(ump)) {
<aname="l00331"></a>00331 <aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *tp = <aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&ump-><aclass="code"href="struct_mutex.html#ad3efd6941b40b1415b5fe40e804d4b6f"title="Queue of the threads sleeping on this Mutex.">m_queue</a>);
<aname="l00332"></a>00332 ump-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> = tp;
<aname="l00333"></a>00333 ump-><aclass="code"href="struct_mutex.html#aa2113b554e5f0deefbc20dbadfd3d1dd"title="Next Mutex into an owner-list or NULL.">m_next</a> = tp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a>;
<aname="l00334"></a>00334 tp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> = ump;
<aname="l00335"></a>00335 <aclass="code"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List.">chSchReadyI</a>(tp);
<aname="l00338"></a>00338 ump-><aclass="code"href="struct_mutex.html#ad83ff6b7d8b483f91a080ae8c53a4941"title="Owner Thread pointer or NULL.">m_owner</a> = NULL;
<aname="l00339"></a>00339 } <spanclass="keywordflow">while</span> (ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> != NULL);
<aname="l00341"></a>00341 <aclass="code"href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20"title="Performs a reschedule if a higher priority thread is runnable.">chSchRescheduleS</a>();
<aname="l00342"></a>00342 }
<aname="l00343"></a>00343 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
Generated on Sun Nov 28 2010 14:09:48 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>