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

📄 smnamelib.html

📁 Vxworks API操作系统和驱动程序设计API。压缩的HTML文件
💻 HTML
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/smNameLib.html - generated by refgen from smNameLib.c --> <title> smNameLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference :  OS Libraries</i></a></p></blockquote><h1>smNameLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>smNameLib</strong> - shared memory objects name database library (VxMP Option) </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./smNameLib.html#smNameAdd">smNameAdd</a>(&nbsp;)</b>  -  add a name to the shared memory name database (VxMP Option)<br><b><a href="./smNameLib.html#smNameFind">smNameFind</a>(&nbsp;)</b>  -  look up a shared memory object by name (VxMP Option)<br><b><a href="./smNameLib.html#smNameFindByValue">smNameFindByValue</a>(&nbsp;)</b>  -  look up a shared memory object by value (VxMP Option)<br><b><a href="./smNameLib.html#smNameRemove">smNameRemove</a>(&nbsp;)</b>  -  remove an object from the shared memory objects name database (VxMP Option)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides facilities for managing the shared memory objectsname database.  The shared memory objects name database associates a nameand object type with a value and makes that information available to all CPUs.  A name is an arbitrary, null-terminated string.  An object type is a small integer, and its value is a global (shared) ID ora global shared memory address.<p>Names are added to the shared memory name database with <b><a href="./smNameLib.html#smNameAdd">smNameAdd</a>(&nbsp;)</b>.  Theyare removed by <b><a href="./smNameLib.html#smNameRemove">smNameRemove</a>(&nbsp;)</b>.<p>Objects in the database can be accessed by either name or value.  Theroutine <b><a href="./smNameLib.html#smNameFind">smNameFind</a>(&nbsp;)</b> searches the shared memory name database for anobject of a specified name.  The routine <b><a href="./smNameLib.html#smNameFindByValue">smNameFindByValue</a>(&nbsp;)</b> searches theshared memory name database for an object of a specified identifier oraddress.<p>Name database contents can be viewed using <b><a href="./smNameShow.html#smNameShow">smNameShow</a>(&nbsp;)</b>.<p>The maximum number of names to be entered in the database is defined in theconfiguration parameter <b>SM_OBJ_MAX_NAME</b> .  This  value is used to determinethe size of a dedicated shared memory partition from which name databasefields are allocated. <p>The estimated memory size required for the name database can be calculated as follows:<p><pre>    name database pool size = SM_OBJ_MAX_NAME * 40 (bytes)</pre>The display facility for the shared memory objects name database is provided bythe <b><a href="./smNameShow.html#top">smNameShow</a></b> module.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>The following code fragment allows a task on one CPU to enter thename, associated ID, and type of a created shared semaphore intothe name database.  Note that CPU numbers can belong to any CPU using theshared memory objects facility.<p>On CPU 1 :<pre>    #include "vxWorks.h"    #include "semLib.h"    #include "smNameLib.h"    #include "semSmLib.h"    #include "stdio.h"    testSmSem1 (void)        {        SEM_ID smSemId;        /* create a shared semaphore */        if ((smSemId = semBSmCreate(SEM_Q_FIFO, SEM_EMPTY)) == NULL)            {            printf ("Shared semaphore creation error.");            return (ERROR);            }        /*          * make created semaphore Id available to all CPUs in          * the system by entering its name in shared name database.         */        if (smNameAdd ("smSem", smSemId, T_SM_SEM_B) != OK )            {            printf ("Cannot add smSem into shared database.");            return (ERROR);            }            ...        /* now use the semaphore */        semGive (smSemId);            ...         }</pre>On CPU 2 :<pre>    #include "vxWorks.h"    #include "semLib.h"    #include "smNameLib.h"    #include "stdio.h"    testSmSem2 (void)        {        SEM_ID smSemId;        int    objType;         /* place holder for smNameFind() object type */        /* get semaphore ID from name database */             smNameFind ("smSem", (void **) &amp;smSemId, &amp;objType, WAIT_FOREVER);            ...        /* now that we have the shared semaphore ID, take it */            semTake (smSemId, WAIT_FOREVER);            ...        }</pre></blockquote><h4>CONFIGURATION</h4><blockquote><p>Before routines in this library can be called, the shared memory objectfacility must be initialized by calling <b>usrSmObjInit(&nbsp;)</b>.This is done automatically during VxWorks initialization when the component<b>INCLUDE_SM_OBJ</b> is included.<p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This module is distributed as a component of the unbundled shared memoryobjects support option, VxMP.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>smNameLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smNameShow.html#top">smNameShow</a></b>, <b><a href="./smObjLib.html#top">smObjLib</a></b>, <b><a href="./smObjShow.html#top">smObjShow</a></b>, <b>usrSmObjInit(&nbsp;)</b>,<i>VxWorks Programmer's Guide: Shared Memory Objects</i><hr><a name="smNameAdd"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>smNameAdd(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>smNameAdd(&nbsp;)</strong> - add a name to the shared memory name database (VxMP Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS smNameAdd    (    char * name,              /* name string to enter in database */    void * value,             /* value associated with name */    int    type               /* type associated with name */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds a name of specified object type and value to the shared memory objects name database.<p>The <i>name</i> parameter is an arbitrary null-terminated string with a maximum of 20 characters, including EOS.<p>By convention, <i>type</i> values of less than 0x1000 are reserved by VxWorks;all other values are user definable.  The following types are predefinedin <b>smNameLib.h</b> :<p><table><tr valign=top><th align=left>Name         </th><th align=left> Value </th><th align=left> Type</tr><tr><td colspan="3"><hr></tr><tr valign=top><td align=left><b>T_SM_SEM_B</b>   </td><td align=left> =  0  </td><td align=left> shared binary semaphore</tr><tr valign=top><td align=left><b>T_SM_SEM_C</b>   </td><td align=left> =  1  </td><td align=left> shared counting semaphore </tr><tr valign=top><td align=left><b>T_SM_MSG_Q</b>   </td><td align=left> =  2  </td><td align=left> shared message queue </tr><tr valign=top><td align=left><b>T_SM_PART_ID</b> </td><td align=left> =  3  </td><td align=left> shared memory Partition </tr><tr valign=top><td align=left><b>T_SM_BLOCK</b>   </td><td align=left> =  4  </td><td align=left> shared memory allocated block </tr><tr valign=top><td align=left></tr></tr></table>A name can be entered only once in the database, but there can be morethan one name associated with an object ID. <p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled shared memoryobjects support option, VxMP.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if there is insufficient memory for <i>name</i> to be allocated, if <i>name</i> is already in the database, or if the database is already full.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>&nbsp;<b>S_smNameLib_NOT_INITIALIZED</b>&nbsp;&nbsp;<br>&nbsp;<b>S_smNameLib_NAME_TOO_LONG</b>&nbsp;&nbsp;<br>&nbsp;<b>S_smNameLib_NAME_ALREADY_EXIST</b>&nbsp;<br>&nbsp;<b>S_smNameLib_DATABASE_FULL</b>&nbsp;<br>&nbsp;<b>S_smObjLib_LOCK_TIMEOUT</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smNameLib.html#top">smNameLib</a></b>, <b><a href="./smNameShow.html#top">smNameShow</a></b><p><hr><a name="smNameFind"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>smNameFind(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>smNameFind(&nbsp;)</strong> - look up a shared memory object by name (VxMP Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS smNameFind    (    char *   name,            /* name to search for */    void * * pValue,          /* pointer where to return value */    int *    pType,           /* pointer where to return object type */    int      waitType         /* NO_WAIT or WAIT_FOREVER */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine searches the shared memory objects name database for an objectmatching a specified <i>name</i>.  If the object is found, its value and typeare copied to the addresses pointed to by <i>pValue</i> and <i>pType</i>.  The value of <i>waitType</i> can be one of the following:<dl><dt><b>NO_WAIT (0)</b><dd>The call returns immediately, even if <i>name</i> is not in the database.<dt><b>WAIT_FOREVER (-1)</b><dd>The call returns only when <i>name</i> is available in the database.  If <i>name</i>is not already in, the database is scanned periodically as the routinewaits for <i>name</i> to be entered.</dl></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled shared memoryobjects support option, VxMP.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the object is not found, if <i>name</i> is too long, orthe wait type is invalid.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>&nbsp;<b>S_smNameLib_NOT_INITIALIZED</b>&nbsp;&nbsp;<br>&nbsp;<b>S_smNameLib_NAME_TOO_LONG</b>&nbsp;<br>&nbsp;<b>S_smNameLib_NAME_NOT_FOUND</b>&nbsp;<br>&nbsp;<b>S_smNameLib_INVALID_WAIT_TYPE</b>&nbsp;<br>&nbsp;<b>S_smObjLib_LOCK_TIMEOUT</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smNameLib.html#top">smNameLib</a></b>, <b><a href="./smNameShow.html#top">smNameShow</a></b><hr><a name="smNameFindByValue"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>smNameFindByValue(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>smNameFindByValue(&nbsp;)</strong> - look up a shared memory object by value (VxMP Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS smNameFindByValue    (    void * value,             /* value to search for */    char * name,              /* pointer where to return name */    int *  pType,             /* pointer where to return object type */    int    waitType           /* NO_WAIT or WAIT_FOREVER */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine searches the shared memory name database for an object matchinga specified value.  If the object is found, its name and type are copiedto the addresses pointed to by <i>name</i> and <i>pType</i>.  The value of <i>waitType</i> can be one of the following:<p><dl><dt><b>NO_WAIT (0)</b><dd>The call returns immediately, even if the object value is not in the database.<dt><b>WAIT_FOREVER (-1)</b><dd>The call returns only when the object value is available in the database.</dl></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled shared memoryobjects support option, VxMP.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if <i>value</i> is not found or if the wait type is invalid.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>&nbsp;<b>S_smNameLib_NOT_INITIALIZED</b>&nbsp;<br>&nbsp;<b>S_smNameLib_VALUE_NOT_FOUND</b>&nbsp;<br>&nbsp;<b>S_smNameLib_INVALID_WAIT_TYPE</b>&nbsp;&nbsp;<br>&nbsp;<b>S_smObjLib_LOCK_TIMEOUT</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smNameLib.html#top">smNameLib</a></b>, <b><a href="./smNameShow.html#top">smNameShow</a></b><hr><a name="smNameRemove"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>smNameRemove(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>smNameRemove(&nbsp;)</strong> - remove an object from the shared memory objects name database (VxMP Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS smNameRemove    (    char * name               /* name of object to remove */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine removes an object called <i>name</i> from the shared memory objectsname database. <p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled shared memoryobjects support option, VxMP.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the object name is not in the database or if<i>name</i> is too long.<p></blockquote><h4>ERRNO</h4><blockquote><p><p>&nbsp;<b>S_smNameLib_NOT_INITIALIZED</b>&nbsp;&nbsp;<br>&nbsp;<b>S_smNameLib_NAME_TOO_LONG</b>&nbsp;<br>&nbsp;<b>S_smNameLib_NAME_NOT_FOUND</b>&nbsp;<br>&nbsp;<b>S_smObjLib_LOCK_TIMEOUT</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smNameLib.html#top">smNameLib</a></b>, <b><a href="./smNameShow.html#top">smNameShow</a></b></body></html>

⌨️ 快捷键说明

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