📄 smmemlib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/smMemLib.html - generated by refgen from smMemLib.c --> <title> smMemLib </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>smMemLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>smMemLib</strong> - shared memory management library (VxMP Option) </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./smMemLib.html#memPartSmCreate">memPartSmCreate</a>( )</b> - create a shared memory partition (VxMP Option)<br><b><a href="./smMemLib.html#smMemAddToPool">smMemAddToPool</a>( )</b> - add memory to shared memory system partition (VxMP Option)<br><b><a href="./smMemLib.html#smMemOptionsSet">smMemOptionsSet</a>( )</b> - set debug options for shared memory system partition (VxMP Option)<br><b><a href="./smMemLib.html#smMemMalloc">smMemMalloc</a>( )</b> - allocate block of memory from shared memory system partition (VxMP Option)<br><b><a href="./smMemLib.html#smMemCalloc">smMemCalloc</a>( )</b> - allocate memory for array from shared memory system partition (VxMP Option)<br><b><a href="./smMemLib.html#smMemRealloc">smMemRealloc</a>( )</b> - reallocate block of memory from shared memory system partition (VxMP Option)<br><b><a href="./smMemLib.html#smMemFree">smMemFree</a>( )</b> - free a shared memory system partition block of memory (VxMP Option)<br><b><a href="./smMemLib.html#smMemFindMax">smMemFindMax</a>( )</b> - find largest free block in shared memory system partition (VxMP Option)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides facilities for managing the allocation of blocks ofshared memory from ranges of memory called shared memory partitions. Theroutine <b><a href="./smMemLib.html#memPartSmCreate">memPartSmCreate</a>( )</b> is used to create shared memory partitions inthe shared memory pool. The created partition can be manipulated usingthe generic memory partition calls, <b><a href="./memPartLib.html#memPartAlloc">memPartAlloc</a>( )</b>, <b><a href="./memPartLib.html#memPartFree">memPartFree</a>( )</b>, etc.(for a complete list of these routines, see the manual entry for<b><a href="./memPartLib.html#top">memPartLib</a></b>). The maximum number of partitions that can be created isdetermined by the configuration parameter <b>SM_OBJ_MAX_MEM_PART</b> .<p>The <b>smMem...( )</b> routines provide an easy-to-use interface to the sharedmemory system partition. The shared memory system partition is created when the shared memory object facility is initialized.<p>Shared memory management information and statistics display routines areprovided by <b><a href="./smMemShow.html#top">smMemShow</a></b>.<p>The allocation of memory, using <b><a href="./memPartLib.html#memPartAlloc">memPartAlloc</a>( )</b> in the general case and <b><a href="./smMemLib.html#smMemMalloc">smMemMalloc</a>( )</b> for the shared memory system partition, is done with a first-fit algorithm. Adjacent blocks of memory are coalesced when freedusing <b><a href="./memPartLib.html#memPartFree">memPartFree</a>( )</b> and <b><a href="./smMemLib.html#smMemFree">smMemFree</a>( )</b>.<p>There is a 28-byte overhead per allocated block (architecture dependent),and allocated blocks are aligned on a 16-byte boundary.<p>All memory used by the shared memory facility must be in the same address space, that is, it must be reachable from all the CPUs with the same offset as the one used for the shared memory anchor.<p></blockquote><h4>CONFIGURATION</h4><blockquote><p>Before routines in this library can be called, the shared memory objectsfacility must be initialized by a call to <b>usrSmObjInit( )</b>, which is found in <b>target/config/comps/src/usrSmObj.c</b>. This is done automaticallyby VxWorks when the <b>INCLUDE_SM_OBJ</b> component is included.<p></blockquote><h4>ERROR OPTIONS</h4><blockquote><p>Various debug options can be selected for each partition using<b><a href="./memLib.html#memPartOptionsSet">memPartOptionsSet</a>( )</b> and <b><a href="./smMemLib.html#smMemOptionsSet">smMemOptionsSet</a>( )</b>. Two kinds of errors aredetected: attempts to allocate more memory than is available, and badblocks found when memory is freed. In both cases, options can be selectedfor system actions to take place when the error is detected: (1) returnthe error status, (2) log an error message and return the error status, or(3) log an error message and suspend the calling task.<p>One of the following options can be specified to determinethe action to be taken when there is an attempt to allocate morememory than is available in the partition:<p><dl><dt><b>MEM_ALLOC_ERROR_RETURN</b><dd>just return the error status to the calling task.<dt><b>MEM_ALLOC_ERROR_LOG_MSG</b><dd>log an error message and return the status to the calling task.<dt><b>MEM_ALLOC_ERROR_LOG_AND_SUSPEND</b><dd>log an error message and suspend the calling task.</dl>The following option is specified by default to check everyblock freed to the partition. If this option is specified, <b><a href="./memPartLib.html#memPartFree">memPartFree</a>( )</b>and <b><a href="./smMemLib.html#smMemFree">smMemFree</a>( )</b> will make a consistency check of various pointers and valuesin the header of the block being freed.<p><dl><dt><b>MEM_BLOCK_CHECK</b><dd>check each block freed.</dl>One of the following options can be specified to determine the action tobe taken when a bad block is detected when freed. These options applyonly if the <b>MEM_BLOCK_CHECK</b> option is selected.<p><dl><dt><b>MEM_BLOCK_ERROR_RETURN</b><dd>just return the status to the calling task.<dt><b>MEM_BLOCK_ERROR_LOG_MSG</b><dd>log an error message and return the status to the calling task.<dt><b>MEM_BLOCK_ERROR_LOG_AND_SUSPEND</b><dd>log an error message and suspend the calling task.</dl>The default options when a shared partition is created are<b>MEM_ALLOC_ERROR_LOG_MSG</b>, <b>MEM_BLOCK_CHECK</b>, <b>MEM_BLOCK_ERROR_RETURN</b>.<p>When setting options for a partition with <b><a href="./memLib.html#memPartOptionsSet">memPartOptionsSet</a>( )</b> or<b><a href="./smMemLib.html#smMemOptionsSet">smMemOptionsSet</a>( )</b>, use the logical OR operator between each specifiedoption to construct the <i>options</i> parameter. For example:<p><pre> memPartOptionsSet (myPartId, MEM_ALLOC_ERROR_LOG_MSG | MEM_BLOCK_CHECK | MEM_BLOCK_ERROR_LOG_MSG);</pre></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>smMemLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smMemShow.html#top">smMemShow</a></b>, <b><a href="./memLib.html#top">memLib</a></b>, <b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./smObjLib.html#top">smObjLib</a></b>, <b>usrSmObjInit( )</b>,<i>VxWorks Programmer's Guide: Shared Memory Objects</i><p><hr><a name="memPartSmCreate"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>memPartSmCreate( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>memPartSmCreate( )</strong> - create a shared memory partition (VxMP Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>PART_ID memPartSmCreate ( char * pPool, /* global address of shared memory area */ unsigned poolSize /* size in bytes */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a shared memory partition that can be used by taskson all CPUs in the system. It returns a partition ID which can then bepassed to generic <b><a href="./memPartLib.html#top">memPartLib</a></b> routines to manage the partition (i.e., toallocate and free memory blocks in the partition).<p><i>pPool</i> is the global address of shared memory dedicated to thepartition. The memory area pointed to by <i>pPool</i> must be in the sameaddress space as the shared memory anchor and shared memory pool.<p><i>poolSize</i> is the size in bytes of shared memory dedicated to the partition.<p>Before this routine can be called, the shared memory objects facility mustbe initialized (see <b><a href="./smMemLib.html#top">smMemLib</a></b>).<p></blockquote><h4>NOTE</h4><blockquote><p>The descriptor for the new partition is allocated out of an internaldedicated shared memory partition. The maximum number of partitions that canbe created is <b>SM_OBJ_MAX_MEM_PART</b> .<p>Memory pool size is rounded down to a 16-byte boundary.<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><p>The partition ID, or NULL if there is insufficient memory in the dedicatedpartition for a new partition descriptor.<p></blockquote><h4>ERRNO</h4><blockquote><p><p> <b>S_memLib_NOT_ENOUGH_MEMORY</b><br> <b>S_smObjLib_LOCK_TIMEOUT</b> <p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./smMemLib.html#top">smMemLib</a></b>, <b><a href="./memLib.html#top">memLib</a></b><hr><a name="smMemAddToPool"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>smMemAddToPool( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>smMemAddToPool( )</strong> - add memory to shared memory system partition (VxMP Option)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS smMemAddToPool ( char * pPool, /* pointer to memory pool */ unsigned poolSize /* block size in bytes */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds memory to the shared memory system partition after theinitial allocation of memory. The memory added need not be contiguouswith memory previously assigned, but it must be in the same addressspace.<p><i>pPool</i> is the global address of shared memory added to the partition.The memory area pointed to by <i>pPool</i> must be in the same address spaceas the shared memory anchor and shared memory pool.<p><i>poolSize</i> is the size in bytes of shared memory added to the partition.<p></blockquote><h4>AVAILABILITY</h4><blockquote><p>This routine is distributed as a component of the unbundled shared memoryobjects support option, VxMP.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -