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

📄 semclib.html

📁 vxworks相关论文
💻 HTML
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/semCLib.html - generated by refgen from semCLib.c --> <title> semCLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual :  Libraries</i></a></p></blockquote><h1>semCLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>semCLib</strong> - counting semaphore library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./semCLib.html#semCCreate">semCCreate</a></i>(&nbsp;)</b>  -  create and initialize a counting semaphore<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides the interface to VxWorks countingsemaphores.  Counting semaphores are useful for guarding multipleinstances of a resource.<p>A counting semaphore may be viewed as a cell in memory whose contentskeep track of a count.  When a task takes a counting semaphore, using<b><i><a href="./semLib.html#semTake">semTake</a></i>(&nbsp;)</b>, subsequent action depends on the state of the count:<dl><dt>(1)<dd>If the count is non-zero, it is decremented and the calling taskcontinues executing.<p><dt>(2)<dd>If the count is zero, the task will be blocked, pending the availabilityof the semaphore.  If a timeout is specified and the timeout expires, thepended task will be removed from the queue of pended tasks and enter theready state with an ERROR status.  A pended task is ineligible for CPUallocation.  Any number of tasks may be pended simultaneously on the samecounting semaphore. </dl><p>When a task gives a semaphore, using <b><i><a href="./semLib.html#semGive">semGive</a></i>(&nbsp;)</b>, the next available task inthe pend queue is unblocked.  If no task is pending on this semaphore, thesemaphore count is incremented.  Note that if a semaphore is given, and atask is unblocked that is of higher priority than the task that called<b><i><a href="./semLib.html#semGive">semGive</a></i>(&nbsp;)</b>, the unblocked task will preempt the calling task.<p>A <b><i><a href="./semLib.html#semFlush">semFlush</a></i>(&nbsp;)</b> on a counting semaphore will atomically unblock all pendedtasks in the semaphore queue.  So all tasks will be made ready before anytask actually executes.  The count of the semaphore will remain unchanged.<p></blockquote><h4>INTERRUPT USAGE</h4><blockquote><p>Counting semaphores may be given but not taken from interrupt level.<p></blockquote><h4>CAVEATS</h4><blockquote><p>There is no mechanism to give back or reclaim semaphores automatically whentasks are suspended or deleted.  Such a mechanism, though desirable, is notcurrently feasible.  Without explicit knowledge of the state of the guardedresource or region, reckless automatic reclamation of a semaphore couldleave the resource in a partial state.  Thus, if a task ceases executionunexpectedly, as with a bus error, currently owned semaphores will not begiven back, effectively leaving a resource permanently unavailable.  Themutual-exclusion semaphores provided by <b><a href="./semMLib.html#top">semMLib</a></b> offer protection fromunexpected task deletion.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>semLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./semCLib.html#top">semCLib</a></b>, <b><a href="./semLib.html#top">semLib</a></b>, <b><a href="./semBLib.html#top">semBLib</a></b>, <b><a href="./semMLib.html#top">semMLib</a></b>,  <i>VxWorks Programmer's Guide: Basic OS</i><hr><a name="semCCreate"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>semCCreate</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>semCCreate</i>(&nbsp;)</strong> - create and initialize a counting semaphore</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>SEM_ID semCCreate    (    int options,     /* semaphore option modes */    int initialCount /* initial count */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates and initializes a counting semaphore.  Thesemaphore is initialized to the specified initial count.<p>The <i>options</i> parameter specifies the queuing style for blocked tasks.Tasks may be queued on a priority basis or a first-in-first-out basis.These options are <b>SEM_Q_PRIORITY</b> (0x1) and <b>SEM_Q_FIFO</b> (0x0), respectively.<p></blockquote><h4>RETURNS</h4><blockquote><p>The semaphore ID, or NULL if memory cannot be allocated.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./semCLib.html#top">semCLib</a></b></body></html>

⌨️ 快捷键说明

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