📄 vxwmempart.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/VXWMemPart.html - generated by refgen from /vobs/wpwr/docs/vxworks/ref/VXWMemPart.i --> <title> VXWMemPart </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Wind Foundation Classes</i></a></p></blockquote><h1>VXWMemPart</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>VXWMemPart</strong> - memory partition classes</p></blockquote><h4>METHODS</h4><blockquote><p><p><b><i><a href="./VXWMemPart.html#VXWMemPart::VXWMemPart">VXWMemPart::VXWMemPart</a></i>( )</b> - create a memory partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::addToPool">VXWMemPart::addToPool</a></i>( )</b> - add memory to a memory partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::alignedAlloc">VXWMemPart::alignedAlloc</a></i>( )</b> - allocate aligned memory from partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::alloc">VXWMemPart::alloc</a></i>( )</b> - allocate a block of memory from partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::findMax">VXWMemPart::findMax</a></i>( )</b> - find the size of the largest available free block<br><b><i><a href="./VXWMemPart.html#VXWMemPart::free">VXWMemPart::free</a></i>( )</b> - free a block of memory in partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::info">VXWMemPart::info</a></i>( )</b> - get partition information<br><b><i><a href="./VXWMemPart.html#VXWMemPart::options">VXWMemPart::options</a></i>( )</b> - set the debug options for memory partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::realloc">VXWMemPart::realloc</a></i>( )</b> - reallocate a block of memory in partition<br><b><i><a href="./VXWMemPart.html#VXWMemPart::show">VXWMemPart::show</a></i>( )</b> - show partition blocks and statistics<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>The <b><a href="./VXWMemPart.html#top">VXWMemPart</a></b> class provides core facilities for managing theallocation of blocks of memory from ranges of memory called memorypartitions.<p>The allocation of memory, using routines such as<b><i><a href="./VXWMemPart.html#VXWMemPart::alloc">VXWMemPart::alloc</a></i>( )</b>, is done with a first-fit algorithm. Adjacentblocks of memory are coalesced when they are freed with<b><i><a href="./VXWMemPart.html#VXWMemPart::free">VXWMemPart::free</a></i>( )</b>. There is also a routine provided forallocating memory aligned to a specified boundary from a specificmemory partition, <b><i><a href="./VXWMemPart.html#VXWMemPart::alignedAlloc">VXWMemPart::alignedAlloc</a></i>( )</b>.<p></blockquote><h4>CAVEATS</h4><blockquote><p>Architectures have various alignment constraints. To provideoptimal performance, <b><i><a href="./VXWMemPart.html#VXWMemPart::alloc">VXWMemPart::alloc</a></i>( )</b> returns a pointer to abuffer having the appropriate alignment for the architecture inuse. The portion of the allocated buffer reserved for systembookkeeping, known as the overhead, may vary depending on thearchitecture.<p><table><tr valign=top><th align=left>Architecture </th><th align=left> Boundary </th><th align=left> Overhead</tr><tr><td colspan="3"><hr></tr><tr valign=top><td align=left> 68K </td><td align=left> 4 </td><td align=left> 8</tr><tr valign=top><td align=left> SPARC </td><td align=left> 8 </td><td align=left> 12</tr><tr valign=top><td align=left> MIPS </td><td align=left> 8 </td><td align=left> 12</tr><tr valign=top><td align=left> i960 </td><td align=left> 16 </td><td align=left> 16</tr><tr valign=top><td align=left></tr></tr></table></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>vxwMemPartLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b>, VXWSem<p><p><hr><a name="VXWMemPart::VXWMemPart"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::VXWMemPart</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::VXWMemPart</i>( )</strong> - create a memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>VXWMemPart ( char * pool, unsigned poolSize )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This constructor creates a new memory partition containing a specifiedmemory pool. Partitions can be created to manageany number of separate memory pools.<p></blockquote><h4>NOTE</h4><blockquote><p>The descriptor for the new partition is allocated out of the system memorypartition (i.e., with <b><i><a href="./memPartLib.html#malloc">malloc</a></i>( )</b>).<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b><hr><a name="VXWMemPart::addToPool"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::addToPool</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::addToPool</i>( )</strong> - add memory to a memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS addToPool ( char * pool, unsigned poolSize )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds memory to its memory partition.The new memory added need not be contiguous withmemory previously assigned to the partition.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b><hr><a name="VXWMemPart::alignedAlloc"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::alignedAlloc</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::alignedAlloc</i>( )</strong> - allocate aligned memory from partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void * alignedAlloc ( unsigned nBytes, unsigned alignment )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates a buffer of size <i>nBytes</i> from itspartition. Additionally, it ensures that the allocated buffer begins on amemory address evenly divisible by <i>alignment</i>. The <i>alignment</i> parametermust be a power of 2.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A pointer to the newly allocated block, or NULL if the buffer cannot beallocated.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b><hr><a name="VXWMemPart::alloc"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::alloc</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::alloc</i>( )</strong> - allocate a block of memory from partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void * alloc ( unsigned nBytes )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates a block of memory from its partition. The size of the block allocated is equal to or greater than <i>nBytes</i>. <p></blockquote><h4>RETURNS</h4><blockquote><p><p>A pointer to a block, or NULL if the call fails.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><i><a href="./VXWMemPart.html#VXWMemPart::free">VXWMemPart::free</a></i>( )</b><hr><a name="VXWMemPart::findMax"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::findMax</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::findMax</i>( )</strong> - find the size of the largest available free block</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre> int findMax ()</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine searches for the largest block in the memory partition freelist and returns its size.<p></blockquote><h4>RETURNS</h4><blockquote><p>The size, in bytes, of the largest available block.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b><hr><a name="VXWMemPart::free"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::free</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::free</i>( )</strong> - free a block of memory in partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS free ( char * pBlock )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine returns to the partition's free memory list a block of memory previously allocated with <b><i><a href="./VXWMemPart.html#VXWMemPart::alloc">VXWMemPart::alloc</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the block is invalid.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><i><a href="./VXWMemPart.html#VXWMemPart::alloc">VXWMemPart::alloc</a></i>( )</b><hr><a name="VXWMemPart::info"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::info</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::info</i>( )</strong> - get partition information</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS info ( MEM_PART_STATS * pPartStats ) const</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine takes a pointer to a <b>MEM_PART_STATS</b> structure.All the parameters of the structure are filled in with the current partitioninformation.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK if the structure has valid data, otherwise ERROR.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><i><a href="./VXWMemPart.html#VXWMemPart::show">VXWMemPart::show</a></i>( )</b><hr><a name="VXWMemPart::options"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::options</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::options</i>( )</strong> - set the debug options for memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS options ( unsigned options )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sets the debug options for its memory partition.Two kinds of errors are detected: attempts to allocate more memorythan is available, and bad blocks found when memory is freed. In bothcases, the error status is returned. There are four error-handlingoptions that can be individually selected:<p><dl><dt><b>MEM_ALLOC_ERROR_LOG_FLAG</b><dd>Log a message when there is an error in allocating memory.<p><dt><b>MEM_ALLOC_ERROR_SUSPEND_FLAG</b><dd>Suspend the task when there is an error in allocating memory (unlessthe task was spawned with the <b>VX_UNBREAKABLE</b> option, in which case itcannot be suspended).<p><dt><b>MEM_BLOCK_ERROR_LOG_FLAG</b><dd>Log a message when there is an error in freeing memory.<p><dt><b>MEM_BLOCK_ERROR_SUSPEND_FLAG</b><dd> Suspend the task when there is an error in freeing memory (unlessthe task was spawned with the <b>VX_UNBREAKABLE</b> option, in which case itcannot be suspended). </dl><p>These options are discussed in detail in the library manual entry formemLib.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b><hr><a name="VXWMemPart::realloc"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::realloc</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::realloc</i>( )</strong> - reallocate a block of memory in partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void * realloc ( char * pBlock, int nBytes )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine changes the size of a specified block of memory and returns apointer to the new block. The contents that fit inside the new size (orold size if smaller) remain unchanged. The memory alignment of the newblock is not guaranteed to be the same as the original block.<p>If <i>pBlock</i> is NULL, this call is equivalent to <b><i><a href="./VXWMemPart.html#VXWMemPart::alloc">VXWMemPart::alloc</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A pointer to the new block of memory, or NULL if the call fails.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b><hr><a name="VXWMemPart::show"></a><p align=right><a href="rtnIndex.html"><i>Wind Foundation Classes : Methods</i></a></p></blockquote><h1><i>VXWMemPart::show</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>VXWMemPart::show</i>( )</strong> - show partition blocks and statistics</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS show ( int type = 0 ) const</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine displays statistics about the available and allocated memoryin its memory partition. It shows the number of bytes, the numberof blocks, and the average block size in both free and allocated memory,and also the maximum block size of free memory. It also shows the numberof blocks currently allocated and the average allocated block size.<p>In addition, if <i>type</i> is 1, the routine displays a list of all the blocksin the free list of the specified partition.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./VXWMemPart.html#top">VXWMemPart</a></b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -