?? group__semaphore.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>YAVRTOS: Semaphores</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.4 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul></div><h1>Semaphores</h1><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">uint8_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__semaphore.html#g45243d3de7a253445deeb57ee4c8cc96">wait_for_min_value</a> (<a class="el" href="structsemaphore__t.html">semaphore_t</a> *s, int16_t value)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Wait for a semaphore to reach at least a particular value. <a href="#g45243d3de7a253445deeb57ee4c8cc96"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">uint8_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__semaphore.html#g291edcd883e2d0bc17f85419e21069ff">wait_for_increment_of</a> (<a class="el" href="structsemaphore__t.html">semaphore_t</a> *p, uint16_t amount)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Wait for a semaphore to increment its value by a certain amount. <a href="#g291edcd883e2d0bc17f85419e21069ff"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">int16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__semaphore.html#g3c18e0f867a2f36f1510aebf5ad4c0e2">get_semaphore_value</a> (<a class="el" href="structsemaphore__t.html">semaphore_t</a> *s)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Get the current value of a semaphore. <a href="#g3c18e0f867a2f36f1510aebf5ad4c0e2"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__semaphore.html#g3cd218588dccb32b5b9072c7a75fb008">increment_semaphore_by</a> (<a class="el" href="structsemaphore__t.html">semaphore_t</a> *s, uint16_t amount)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Increment the value of a semaphore by the given amount. <a href="#g3cd218588dccb32b5b9072c7a75fb008"></a><br></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>A semaphore contains a number that tasks can suspend themselves against, waiting for the number to reach at least a certain value before the task is schedulable again.<p>To update a semaphore's value, use <a class="el" href="group__semaphore.html#g3cd218588dccb32b5b9072c7a75fb008" title="Increment the value of a semaphore by the given amount.">increment_semaphore_by()</a><p>To read a semaphore's value, use <a class="el" href="group__semaphore.html#g3c18e0f867a2f36f1510aebf5ad4c0e2" title="Get the current value of a semaphore.">get_semaphore_value()</a><p>To lock on a semaphore, use <a class="el" href="group__semaphore.html#g45243d3de7a253445deeb57ee4c8cc96" title="Wait for a semaphore to reach at least a particular value.">wait_for_min_value()</a> or <a class="el" href="group__semaphore.html#g291edcd883e2d0bc17f85419e21069ff" title="Wait for a semaphore to increment its value by a certain amount.">wait_for_increment_of()</a><p>See <a class="el" href="usage-sema.html">using semaphores</a> for information on how to use semaphores <hr><h2>Function Documentation</h2><a class="anchor" name="g3c18e0f867a2f36f1510aebf5ad4c0e2"></a><!-- doxytag: member="task.h::get_semaphore_value" ref="g3c18e0f867a2f36f1510aebf5ad4c0e2" args="(semaphore_t *s)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">int16_t get_semaphore_value </td> <td>(</td> <td class="paramtype"><a class="el" href="structsemaphore__t.html">semaphore_t</a> * </td> <td class="paramname"> <em>s</em> </td> <td> ) </td> <td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Get the current value of a semaphore. <p>This function may be called anywhere </div></div><p><a class="anchor" name="g3cd218588dccb32b5b9072c7a75fb008"></a><!-- doxytag: member="task.h::increment_semaphore_by" ref="g3cd218588dccb32b5b9072c7a75fb008" args="(semaphore_t *s, uint16_t amount)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">void increment_semaphore_by </td> <td>(</td> <td class="paramtype"><a class="el" href="structsemaphore__t.html">semaphore_t</a> * </td> <td class="paramname"> <em>s</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">uint16_t </td> <td class="paramname"> <em>amount</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Increment the value of a semaphore by the given amount. <p>The arguments are <ul><li><code>s</code> - the semaphore to increment </li><li><code>amount</code> - the amount by which the semaphore should be incremented. Note that semaphore values are actually signed 16-bit numbers, so the maximum value for this argument is about 32,000</li></ul>This may be called by any task, by an ISR, or even before the task system is running.<p>When called from a task, this function may end up yielding control to a higher-priority task that is waiting on the semaphore. </div></div><p><a class="anchor" name="g291edcd883e2d0bc17f85419e21069ff"></a><!-- doxytag: member="task.h::wait_for_increment_of" ref="g291edcd883e2d0bc17f85419e21069ff" args="(semaphore_t *p, uint16_t amount)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">uint8_t wait_for_increment_of </td> <td>(</td> <td class="paramtype"><a class="el" href="structsemaphore__t.html">semaphore_t</a> * </td> <td class="paramname"> <em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">uint16_t </td> <td class="paramname"> <em>amount</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Wait for a semaphore to increment its value by a certain amount. <p>The arguments are <ul><li><code>p</code> - the semaphore to wait on </li><li><code>amount</code> - the amount by which the semaphore should increment before returning. Note that semaphore values are actually signed 16-bit numbers, so the maximum value for this argument is about 32,000</li></ul>Since the calling task could be suspended, this can only be called by a task with a non-zero priority </div></div><p><a class="anchor" name="g45243d3de7a253445deeb57ee4c8cc96"></a><!-- doxytag: member="task.h::wait_for_min_value" ref="g45243d3de7a253445deeb57ee4c8cc96" args="(semaphore_t *s, int16_t value)" --><div class="memitem"><div class="memproto"> <table class="memname"> <tr> <td class="memname">uint8_t wait_for_min_value </td> <td>(</td> <td class="paramtype"><a class="el" href="structsemaphore__t.html">semaphore_t</a> * </td> <td class="paramname"> <em>s</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int16_t </td> <td class="paramname"> <em>value</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"></td> </tr> </table></div><div class="memdoc"><p>Wait for a semaphore to reach at least a particular value. <p>Since the calling task could be suspended, this can only be called by a task with a non-zero priority </div></div><p><hr><p align="center"><font size="-1">YAVRTOS and YAVRTOS documentation Copyright © 2007-2008 Chris O'Byrne. Email - chris <at> obyrne <dot> com</font></p></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -