⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group__semaphore.html

📁 yavrtos,一款用于广泛用于AVR单片机的RTOS,文件里是这款OS的源码
💻 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&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>    <li><a href="pages.html"><span>Related&nbsp;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&nbsp;</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">&nbsp;</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&nbsp;</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">&nbsp;</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&nbsp;</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">&nbsp;</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&nbsp;</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">&nbsp;</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> *&nbsp;</td>          <td class="paramname"> <em>s</em>          </td>          <td>&nbsp;)&nbsp;</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> *&nbsp;</td>          <td class="paramname"> <em>s</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">uint16_t&nbsp;</td>          <td class="paramname"> <em>amount</em></td><td>&nbsp;</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> *&nbsp;</td>          <td class="paramname"> <em>p</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">uint16_t&nbsp;</td>          <td class="paramname"> <em>amount</em></td><td>&nbsp;</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> *&nbsp;</td>          <td class="paramname"> <em>s</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">int16_t&nbsp;</td>          <td class="paramname"> <em>value</em></td><td>&nbsp;</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 &copy; 2007-2008 Chris O'Byrne. Email - chris &lt;at&gt; obyrne &lt;dot&gt; com</font></p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -