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

📄 mempartlib.html

📁 vxworks相关论文
💻 HTML
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/memPartLib.html - generated by refgen from memPartLib.c --> <title> memPartLib </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>memPartLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>memPartLib</strong> - core memory partition manager </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./memPartLib.html#memPartCreate">memPartCreate</a></i>(&nbsp;)</b>  -  create a memory partition<br><b><i><a href="./memPartLib.html#memPartAddToPool">memPartAddToPool</a></i>(&nbsp;)</b>  -  add memory to a memory partition<br><b><i><a href="./memPartLib.html#memPartAlignedAlloc">memPartAlignedAlloc</a></i>(&nbsp;)</b>  -  allocate aligned memory from a partition<br><b><i><a href="./memPartLib.html#memPartAlloc">memPartAlloc</a></i>(&nbsp;)</b>  -  allocate a block of memory from a partition<br><b><i><a href="./memPartLib.html#memPartFree">memPartFree</a></i>(&nbsp;)</b>  -  free a block of memory in a partition<br><b><i><a href="./memPartLib.html#memAddToPool">memAddToPool</a></i>(&nbsp;)</b>  -  add memory to the system memory partition<br><b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b>  -  allocate a block of memory from the system memory partition (ANSI)<br><b><i><a href="./memPartLib.html#free">free</a></i>(&nbsp;)</b>  -  free a block of memory (ANSI)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides core facilities for managing the allocation ofblocks of memory from ranges of memory called memory partitions.  Thelibrary was designed to provide a compact implementation; full-featuredfunctionality is available with <b><a href="./memLib.html#top">memLib</a></b>, which provides enhanced memorymanagement features built as an extension of memPartLib.  (For moreinformation about enhanced memory partition management options, see themanual entry for memLib.)  This library consists of two sets of routines.The first set, <b><i>memPart...</i>(&nbsp;)</b>, comprises a general facility for the creationand management of memory partitions, and for the allocation and deallocationof blocks from those partitions.  The second set provides a traditionalANSI-compatible <b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b>/<b><i><a href="./memPartLib.html#free">free</a></i>(&nbsp;)</b> interface to the system memory partition.<p>The system memory partition is created when the kernel is initialized by<b><i><a href="./kernelLib.html#kernelInit">kernelInit</a></i>(&nbsp;)</b>, which is called by the root task, <b><i><a href="./usrConfig.html#usrRoot">usrRoot</a></i>(&nbsp;)</b>, in<b>usrConfig.c</b>.  The ID of the system memory partition is stored in theglobal variable <b>memSysPartId</b>; its declaration is included in <b>memLib.h</b>.<p>The allocation of memory, using <b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b> in the typical case and<b><i><a href="./memPartLib.html#memPartAlloc">memPartAlloc</a></i>(&nbsp;)</b> for a specific memory partition, is done with a first-fitalgorithm.  Adjacent blocks of memory are coalesced when they are freedwith <b><i><a href="./memPartLib.html#memPartFree">memPartFree</a></i>(&nbsp;)</b> and <b><i><a href="./memPartLib.html#free">free</a></i>(&nbsp;)</b>.  There is also a routine provided for allocatingmemory aligned to a specified boundary from a specific memory partition,<b><i><a href="./memPartLib.html#memPartAlignedAlloc">memPartAlignedAlloc</a></i>(&nbsp;)</b>.<p></blockquote><h4>CAVEATS</h4><blockquote><p>Architectures have various alignment constraints.  To provide optimalperformance, <b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b> returns a pointer to a buffer having the appropriatealignment for the architecture in use.  The portion of the allocatedbuffer reserved for system bookkeeping, known as the overhead, may varydepending on the architecture.<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> 16 </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>memLib.h</b>, <b>stdlib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./memLib.html#top">memLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b><p><hr><a name="memPartCreate"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>memPartCreate</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>memPartCreate</i>(&nbsp;)</strong> - create a memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>PART_ID memPartCreate    (    char *   pPool,   /* pointer to memory area */    unsigned poolSize /* size in bytes */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a new memory partition containing a specifiedmemory pool.  It returns a partition ID, which can then be passed toother routines to manage the partition (i.e., to allocate and freememory blocks in the partition).  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>(&nbsp;)</b>).<p></blockquote><h4>RETURNS</h4><blockquote><p><p>The partition ID, or NULL if there is insufficient memory in the systemmemory partition for a new partition descriptor.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b><hr><a name="memPartAddToPool"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>memPartAddToPool</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>memPartAddToPool</i>(&nbsp;)</strong> - add memory to a memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memPartAddToPool    (    PART_ID  partId,  /* partition to initialize */    char *   pPool,   /* pointer to memory block */    unsigned poolSize /* block size in bytes */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds memory to a specified memory partition already createdwith <b><i><a href="./memPartLib.html#memPartCreate">memPartCreate</a></i>(&nbsp;)</b>.  The memory added need not be contiguous withmemory previously assigned to the partition.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_smObjLib_NOT_INITIALIZED, S_memLib_INVALID_NBYTES<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b>, <b><i><a href="./memPartLib.html#memPartCreate">memPartCreate</a></i>(&nbsp;)</b><hr><a name="memPartAlignedAlloc"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>memPartAlignedAlloc</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>memPartAlignedAlloc</i>(&nbsp;)</strong> - allocate aligned memory from a partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void *memPartAlignedAlloc    (    PART_ID  partId,   /* memory partition to allocate from */    unsigned nBytes,   /* number of bytes to allocate */    unsigned alignment /* boundary to align to */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates a buffer of size <i>nBytes</i> from a specifiedpartition.  Additionally, it insures 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 could not beallocated.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b><hr><a name="memPartAlloc"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>memPartAlloc</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>memPartAlloc</i>(&nbsp;)</strong> - allocate a block of memory from a partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void *memPartAlloc    (    PART_ID  partId, /* memory partition to allocate from */    unsigned nBytes  /* number of bytes to allocate */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates a block of memory from a specified partition. The size of the block will be equal to or greater than <i>nBytes</i>.  The partition must already be created with <b><i><a href="./memPartLib.html#memPartCreate">memPartCreate</a></i>(&nbsp;)</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A pointer to a block, or NULL if the call fails.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_smObjLib_NOT_INITIALIZED<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b>, <b><i><a href="./memPartLib.html#memPartCreate">memPartCreate</a></i>(&nbsp;)</b><hr><a name="memPartFree"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>memPartFree</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>memPartFree</i>(&nbsp;)</strong> - free a block of memory in a partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memPartFree    (    PART_ID partId, /* memory partition to add block to */    char *  pBlock  /* pointer to block of memory to free */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine returns to a partition's free memory list a block of memory previously allocated with <b><i><a href="./memPartLib.html#memPartAlloc">memPartAlloc</a></i>(&nbsp;)</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the block is invalid.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_smObjLib_NOT_INITIALIZED<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b>, <b><i><a href="./memPartLib.html#memPartAlloc">memPartAlloc</a></i>(&nbsp;)</b><hr><a name="memAddToPool"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>memAddToPool</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>memAddToPool</i>(&nbsp;)</strong> - add memory to the system memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void memAddToPool    (    char *   pPool,   /* pointer to memory block */    unsigned poolSize /* block size in bytes */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds memory to the system memory partition, after the initialallocation of memory to the system memory partition.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><i><a href="./memPartLib.html#memPartAddToPool">memPartAddToPool</a></i>(&nbsp;)</b><hr><a name="malloc"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>malloc</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>malloc</i>(&nbsp;)</strong> - allocate a block of memory from the system memory partition (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void *malloc    (    size_t nBytes /* number of bytes to allocate */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates a block of memory from the free list.  The size ofthe block will be equal to or greater than <i>nBytes</i>.<p></blockquote><h4>RETURNS</h4><blockquote><p>A pointer to the allocated block of memory, or a null pointer ifthere is an error.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <i>American National Standard for Information Systems - </i><i>Programming Language - C, ANSI X3.159-1989: General Utilities (<b>stdlib.h</b>) </i><hr><a name="free"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>free</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>free</i>(&nbsp;)</strong> - free a block of memory (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void free    (    void * ptr /* pointer to block of memory to free */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine returns to the free memory pool a block of memory previouslyallocated with <b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b> or <b><i><a href="./memLib.html#calloc">calloc</a></i>(&nbsp;)</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><i><a href="./memPartLib.html#malloc">malloc</a></i>(&nbsp;)</b>, <b><i><a href="./memLib.html#calloc">calloc</a></i>(&nbsp;)</b>,  <i>American National Standard for Information Systems - </i><i>Programming Language - C, ANSI X3.159-1989: General Utilities (<b>stdlib.h</b>) </i></body></html>

⌨️ 快捷键说明

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