<ahref="chmsg_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00051"></a>00051 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00070"></a><aclass="code"href="group__messages.html#ga29a48a438e97dc47cb798a84e13764cb">00070</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__messages.html#ga29a48a438e97dc47cb798a84e13764cb"title="Sends a message to the specified thread.">chMsgSend</a>(<aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *tp, <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg) {
<aname="l00080"></a>00080 <aclass="code"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List.">chSchReadyI</a>(tp);
<aname="l00081"></a>00081 <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#gaff813590802bfd53cbf0560b680b89f5"title="Thread state: Waiting in chMsgSend().">THD_STATE_SNDMSG</a>);
<aname="l00097"></a><aclass="code"href="group__messages.html#gae68fefbf9d0404bbf56ae354961fae41">00097</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__messages.html#gae68fefbf9d0404bbf56ae354961fae41"title="Suspends the thread and waits for an incoming message.">chMsgWait</a>(<spanclass="keywordtype">void</span>) {
<aname="l00098"></a>00098 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00099"></a>00099
<aname="l00100"></a>00100 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00101"></a>00101 <spanclass="keywordflow">if</span> (!<aclass="code"href="group__messages.html#ga4e0eafdfd51c042d765e2949e6171093"title="Evaluates to TRUE if the thread has pending messages.">chMsgIsPendingI</a>(<aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>))
<aname="l00102"></a>00102 <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#gaf46c55b4468f0dad5cd0b3ef73e1be26"title="Thread state: Waiting in chMsgWait().">THD_STATE_WTMSG</a>);
<aname="l00104"></a>00104 <spanclass="preprocessor"></span> msg = <aclass="code"href="group__messages.html#ga3ed579be01280d265d0a7c02e0c7c1d8"title="Returns the first message in the queue.">chMsgGetI</a>((<spanclass="keyword">volatile</span><aclass="code"href="struct_thread.html"title="Structure representing a thread.">Thread</a> *)<aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>); <spanclass="comment">/* Temporary hack.*/</span>
<aname="l00106"></a>00106 <spanclass="preprocessor"></span> msg = <aclass="code"href="group__messages.html#ga3ed579be01280d265d0a7c02e0c7c1d8"title="Returns the first message in the queue.">chMsgGetI</a>(currp);
<aname="l00125"></a><aclass="code"href="group__messages.html#ga65dda189b03b238412301ce5d80bfcf4">00125</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__messages.html#ga65dda189b03b238412301ce5d80bfcf4"title="Returns the next message in the queue.">chMsgGet</a>(<spanclass="keywordtype">void</span>) {
<aname="l00126"></a>00126 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00127"></a>00127
<aname="l00128"></a>00128 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00129"></a>00129 msg = <aclass="code"href="group__messages.html#ga4e0eafdfd51c042d765e2949e6171093"title="Evaluates to TRUE if the thread has pending messages.">chMsgIsPendingI</a>(<aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>) ? <aclass="code"href="group__messages.html#ga3ed579be01280d265d0a7c02e0c7c1d8"title="Returns the first message in the queue.">chMsgGetI</a>(<aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>) : (msg_t)NULL;
<aname="l00145"></a><aclass="code"href="group__messages.html#ga19a54b3b4b0e3677c47d650a3be3c7aa">00145</a><spanclass="keywordtype">void</span><aclass="code"href="group__messages.html#ga19a54b3b4b0e3677c47d650a3be3c7aa"title="Releases the thread waiting on top of the messages queue.">chMsgRelease</a>(<aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg) {
<aname="l00146"></a>00146
<aname="l00147"></a>00147 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00148"></a>00148 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(<aclass="code"href="group__messages.html#ga4e0eafdfd51c042d765e2949e6171093"title="Evaluates to TRUE if the thread has pending messages.">chMsgIsPendingI</a>(<aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>),
<aname="l00151"></a>00151 <aclass="code"href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95"title="Wakes up a thread.">chSchWakeupS</a>(<aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&<aclass="code"href="group__scheduler.html#ga1a5fddde56420e8accd0c09c1abb32a7"title="Current thread pointer access macro.">currp</a>->p_msgqueue), msg);
<aname="l00152"></a>00152 <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>