📄 compat-uitron-memory-pool-mgmt-functions.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE> Memory pool Management Functions</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="礗TRON API"HREF="compat-uitron-microitron-api.html"><LINKREL="PREVIOUS"TITLE="Interrupt management functions"HREF="compat-uitron-interrupt-management-functions.html"><LINKREL="NEXT"TITLE="Time Management Functions"HREF="compat-uitron-time-mgmt-functions.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="compat-uitron-interrupt-management-functions.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 32. µITRON API</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="compat-uitron-time-mgmt-functions.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="COMPAT-UITRON-MEMORY-POOL-MGMT-FUNCTIONS">Memory pool Management Functions</H1><P>These functions are fully supported in this release: </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">get_blf</TT>( VP *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_blf,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">pget_blf</TT>( VP *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_blf,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">tget_blf</TT>( VP *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_blf,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid,</I></SPAN> TMO <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tmout</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">rel_blf</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid,</I></SPAN> VP <SPANCLASS="emphasis"><ICLASS="EMPHASIS">blf</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">ref_mpf</TT>( T_RMPF *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">pk_rmpf,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">get_blk</TT>( VP *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_blk,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid,</I></SPAN> INT <SPANCLASS="emphasis"><ICLASS="EMPHASIS">blksz</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">pget_blk</TT>( VP *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_blk,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid,</I></SPAN> INT <SPANCLASS="emphasis"><ICLASS="EMPHASIS">blksz</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">tget_blk</TT>( VP *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">p_blk,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid,</I></SPAN> INT <SPANCLASS="emphasis"><ICLASS="EMPHASIS">blksz,</I></SPAN> TMO <SPANCLASS="emphasis"><ICLASS="EMPHASIS">tmout</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">rel_blk</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid,</I></SPAN> VP <SPANCLASS="emphasis"><ICLASS="EMPHASIS">blk</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">ref_mpl</TT>( T_RMPL *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">pk_rmpl,</I></SPAN> ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid )</I></SPAN></PRE></TD></TR></TABLE><P>Note that of the memory provided for a particular pool tomanage in the static initialization of the memory pool objects,some memory will be used to manage the pool itself. Therefore thenumber of blocks * the blocksize will be less than the totalmemory size. </P><P>The following functions are supported in this release, whenenabled with <TTCLASS="LITERAL">CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE</TT>or <TTCLASS="LITERAL">CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE</TT>as appropriate, with some restrictions: </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">cre_mpl</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid,</I></SPAN> T_CMPL *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">pk_cmpl</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">del_mpl</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mplid</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">cre_mpf</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid,</I></SPAN> T_CMPF *<SPANCLASS="emphasis"><ICLASS="EMPHASIS">pk_cmpf</I></SPAN> )</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">ER <TTCLASS="FUNCTION">del_mpf</TT>( ID <SPANCLASS="emphasis"><ICLASS="EMPHASIS">mpfid</I></SPAN> )</PRE></TD></TR></TABLE><P>Because of the static initialization facilities provided forsystem objects, a memory pool is allocated a region of memory tomanage statically in the configuration. So while memory pools canbe created and deleted, the same area of memory is used for thatmemory pool (memory pool ID number) each time. The requested variable poolsize (pk_cmpl->mplsz) or the number of fixed-sizeblocks (pk_cmpf->mpfcnt) times the block size(pk_cmpf->blfsz) are checked for fitting withinthe statically allocated memory area, so if a create call succeeds,the resulting pool will be at least as large as that requested.For this reason <TTCLASS="FUNCTION">del_mpl()</TT> and <TTCLASS="FUNCTION">del_mpf()</TT> donot in any sense free the memory that was managed by the deletedpool for use by other pools; it may only be managed by a pool ofthe same object id. </P><P>For both fixed and variable memory pools, the queueing orderwhen waiting on a synchronization object depends on the underlyingkernel configuration. The multi-level queue scheduler is requiredfor strict µITRON conformance andit queues tasks in FIFO order, so requests to create an object withpriority queueing of tasks (pk_cxxx->xxxatr = TA_TPRI)are rejected with E_RSATR. Additional undefined bits inthe attributes fields must be zero. </P><P>In general, extended information (pk_cxxx->exinf)is ignored. </P><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN13913">Error checking</H2><P>The following conditions are only checked for, and only returnerrors if <TTCLASS="LITERAL">CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS</TT>is enabled:</P><P></P><UL><LI><P>invalid object id; less than 1 or greater than <TTCLASS="LITERAL">CYGNUM_UITRON_MEMPOOLVAR/MEMPOOLFIXED</TT>as appropriate returns E_ID</P></LI><LI><P>dispatching is enabled in any call which can sleep, orE_CTX</P></LI><LI><P>tmout must be positive, otherwise E_PAR</P></LI><LI><P>pk_cxxx pointers in <TTCLASS="FUNCTION">cre_xxx()</TT> must be valid pointers, or E_PAR</P></LI><LI><P>return value pointer in <TTCLASS="FUNCTION">ref_xxx()</TT> is a valid pointer, or E_PAR</P></LI><LI><P>return value pointers in get block routines is a validpointer, or E_PAR</P></LI><LI><P>blocksize request in get variable block routines is greaterthan zero, or E_PAR</P></LI></UL><P>The following conditions are checked for, and can return errorcodes, regardless of the setting of <TTCLASS="LITERAL">CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS</TT>:</P><P></P><UL><LI><P>When create and delete functions <TTCLASS="FUNCTION">cre_xxx()</TT> and <TTCLASS="FUNCTION">del_xxx()</TT> are supported, all calls which use a valid object ID number checkthat the object exists. If not, E_NOEXS is returned.</P></LI><LI><P>When create functions <TTCLASS="FUNCTION">cre_xxx()</TT> are supported, if the object already exists, then E_OBJ</P></LI><LI><P>In any call which can sleep, such as <TTCLASS="FUNCTION">get_blk()</TT>: return codes E_TMOUT, E_RLWAI, E_DLTor of course E_OK are returned depending on the reasonfor terminating the sleep</P></LI><LI><P>In polling functions such as <TTCLASS="FUNCTION">pget_blk()</TT>return codes E_TMOUT or E_OK are returned dependingon the state of the synchronization object</P></LI><LI><P>In creation functions, the attributes must be compatiblewith the selected underlying kernel configuration: in <TTCLASS="FUNCTION">cre_mpl()</TT> <TTCLASS="LITERAL">pk_cmpl->mplatr</TT> must be equal to <TTCLASS="LITERAL">TA_TFIFO</TT> else E_RSATR.</P></LI><LI><P>In <TTCLASS="FUNCTION">cre_mpf()</TT> <TTCLASS="LITERAL">pk_cmpf->mpfatr</TT> must be equal to <TTCLASS="LITERAL">TA_TFIFO</TT> else E_RSATR.</P></LI><LI><P>In creation functions, the requested size of the memorypool must not be larger than that statically configured for thepool else E_RSATR; see the configuration option“Option: Static initializers”. In <TTCLASS="FUNCTION">cre_mpl()</TT> <TTCLASS="LITERAL">pk_cmpl->mplsz</TT> is the field of interest</P></LI><LI><P>In <TTCLASS="FUNCTION">cre_mpf()</TT> the product of <TTCLASS="LITERAL">pk_cmpf->blfsz</TT> and <TTCLASS="LITERAL">pk_cmpf->mpfcnt</TT> must be smaller than the memory statically configured for the poolelse E_RSATR</P></LI><LI><P>In functions which return memory to the pool <TTCLASS="FUNCTION">rel_blk()</TT> and <TTCLASS="FUNCTION">rel_blf()</TT>, if the free fails, for example because the memory did not comefrom that pool originally, then E_PAR is returned</P></LI></UL></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="compat-uitron-interrupt-management-functions.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="compat-uitron-time-mgmt-functions.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Interrupt management functions</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="compat-uitron-microitron-api.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Time Management Functions</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -