mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 02:51:31 -08:00
208 lines
No EOL
15 KiB
HTML
208 lines
No EOL
15 KiB
HTML
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>9. MFS (Manual Fixed Small) — Memory Pool System 1.111.0 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/mps.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '1.111.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
|
<link rel="top" title="Memory Pool System 1.111.0 documentation" href="../index.html" />
|
|
<link rel="up" title="Pool reference" href="index.html" />
|
|
<link rel="next" title="10. MV (Manual Variable)" href="mv.html" />
|
|
<link rel="prev" title="8. LO (Leaf Object)" href="lo.html" />
|
|
</head>
|
|
<body>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="mv.html" title="10. MV (Manual Variable)"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="lo.html" title="8. LO (Leaf Object)"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="../index.html">Memory Pool System 1.111.0 documentation</a> »</li>
|
|
<li><a href="index.html" accesskey="U">Pool reference</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="mfs-manual-fixed-small">
|
|
<span id="pool-mfs"></span><span id="index-0"></span><h1>9. MFS (Manual Fixed Small)<a class="headerlink" href="#mfs-manual-fixed-small" title="Permalink to this headline">¶</a></h1>
|
|
<p><strong>MFS</strong> is an <a class="reference internal" href="../glossary/m.html#term-manual-memory-management"><em class="xref std std-term">manually managed</em></a>
|
|
<a class="reference internal" href="../glossary/p.html#term-pool-class"><em class="xref std std-term">pool class</em></a> for small objects of fixed size.</p>
|
|
<p>Unlike other manual pool classes, it is not subject to <a class="reference internal" href="../glossary/i.html#term-internal-fragmentation"><em class="xref std std-term">internal
|
|
fragmentation</em></a>.</p>
|
|
<p>The implementation is very simple: unlike other <a class="reference internal" href="../glossary/p.html#term-pool-class"><em class="xref std std-term">pool classes</em></a>
|
|
which store their control structures separately from the allocated
|
|
blocks, MFS maintains a stack of free blocks using a pointer in the
|
|
free block. <a class="reference internal" href="../topic/allocation.html#mps_alloc" title="mps_alloc"><tt class="xref c c-func docutils literal"><span class="pre">mps_alloc()</span></tt></a> pops this stack and <a class="reference internal" href="../topic/allocation.html#mps_free" title="mps_free"><tt class="xref c c-func docutils literal"><span class="pre">mps_free()</span></tt></a>
|
|
pushes it.</p>
|
|
<div class="section" id="mfs-properties">
|
|
<span id="index-1"></span><h2>9.1. MFS properties<a class="headerlink" href="#mfs-properties" title="Permalink to this headline">¶</a></h2>
|
|
<ul class="simple">
|
|
<li>Supports allocation via <a class="reference internal" href="../topic/allocation.html#mps_alloc" title="mps_alloc"><tt class="xref c c-func docutils literal"><span class="pre">mps_alloc()</span></tt></a> and deallocation via
|
|
<a class="reference internal" href="../topic/allocation.html#mps_free" title="mps_free"><tt class="xref c c-func docutils literal"><span class="pre">mps_free()</span></tt></a>.</li>
|
|
<li>Does not support allocation via <a class="reference internal" href="../glossary/a.html#term-allocation-point"><em class="xref std std-term">allocation points</em></a>.</li>
|
|
<li>Does not support <a class="reference internal" href="../glossary/a.html#term-allocation-frame"><em class="xref std std-term">allocation frames</em></a>.</li>
|
|
<li>Supports <a class="reference internal" href="../glossary/s.html#term-segregated-allocation-cache"><em class="xref std std-term">segregated allocation caches</em></a> (but using one would
|
|
be pointless, since all blocks are the same size).</li>
|
|
<li>There are no garbage collections in this pool.</li>
|
|
<li>Blocks may not contain <a class="reference internal" href="../glossary/r.html#term-reference"><em class="xref std std-term">references</em></a> to blocks in automatically
|
|
managed pools (unless these are registered as <a class="reference internal" href="../glossary/r.html#term-root"><em class="xref std std-term">roots</em></a>).</li>
|
|
<li>Allocations are fixed in size.</li>
|
|
<li>The <a class="reference internal" href="../glossary/a.html#term-alignment"><em class="xref std std-term">alignment</em></a> of blocks is not configurable: it is the
|
|
<a class="reference internal" href="../glossary/n.html#term-natural-alignment"><em class="xref std std-term">natural alignment</em></a> of the platform (see
|
|
<a class="reference internal" href="../topic/platform.html#MPS_PF_ALIGN" title="MPS_PF_ALIGN"><tt class="xref c c-macro docutils literal"><span class="pre">MPS_PF_ALIGN</span></tt></a>).</li>
|
|
<li>Blocks do not have <a class="reference internal" href="../glossary/d.html#term-dependent-object"><em class="xref std std-term">dependent objects</em></a>.</li>
|
|
<li>Blocks are not automatically <a class="reference internal" href="../glossary/r.html#term-reclaim"><em class="xref std std-term">reclaimed</em></a>.</li>
|
|
<li>Blocks are not <a class="reference internal" href="../glossary/s.html#term-scan"><em class="xref std std-term">scanned</em></a>.</li>
|
|
<li>Blocks are not protected by <a class="reference internal" href="../glossary/b.html#term-barrier-1"><em class="xref std std-term">barriers<sup>(1)</sup></em></a>.</li>
|
|
<li>Blocks do not <a class="reference internal" href="../glossary/m.html#term-moving-garbage-collector"><em class="xref std std-term">move</em></a>.</li>
|
|
<li>Blocks may not be registered for <a class="reference internal" href="../glossary/f.html#term-finalization"><em class="xref std std-term">finalization</em></a>.</li>
|
|
<li>Blocks must not belong to an <a class="reference internal" href="../glossary/o.html#term-object-format"><em class="xref std std-term">object format</em></a>.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="mfs-interface">
|
|
<span id="index-2"></span><h2>9.2. MFS interface<a class="headerlink" href="#mfs-interface" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include "mpscmfs.h"</span>
|
|
</pre></div>
|
|
</div>
|
|
<dl class="function">
|
|
<dt id="mps_class_mfs">
|
|
<a class="reference internal" href="../topic/pool.html#mps_class_t" title="mps_class_t">mps_class_t</a> <tt class="descname">mps_class_mfs</tt><big>(</big>void<big>)</big><a class="headerlink" href="#mps_class_mfs" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Return the <a class="reference internal" href="../glossary/p.html#term-pool-class"><em class="xref std std-term">pool class</em></a> for an MFS (Manual Fixed Small)
|
|
<a class="reference internal" href="../glossary/p.html#term-pool"><em class="xref std std-term">pool</em></a>.</p>
|
|
<p>When creating an MFS pool, <a class="reference internal" href="../topic/pool.html#mps_pool_create_k" title="mps_pool_create_k"><tt class="xref c c-func docutils literal"><span class="pre">mps_pool_create_k()</span></tt></a> requires
|
|
one <a class="reference internal" href="../glossary/k.html#term-keyword-argument"><em class="xref std std-term">keyword arguments</em></a>:</p>
|
|
<ul class="simple">
|
|
<li><tt class="xref c c-macro docutils literal"><span class="pre">MPS_KEY_MFS_UNIT_SIZE</span></tt> (type <tt class="xref c c-type docutils literal"><span class="pre">size_t</span></tt>) is the
|
|
<a class="reference internal" href="../glossary/s.html#term-size"><em class="xref std std-term">size</em></a> of blocks that will be allocated from this pool, in
|
|
<a class="reference internal" href="../glossary/b.html#term-byte-1"><em class="xref std std-term">bytes<sup>(1)</sup></em></a>. It must be at least one <a class="reference internal" href="../glossary/w.html#term-word"><em class="xref std std-term">word</em></a>.</li>
|
|
</ul>
|
|
<p>In addition, <a class="reference internal" href="../topic/pool.html#mps_pool_create_k" title="mps_pool_create_k"><tt class="xref c c-func docutils literal"><span class="pre">mps_pool_create_k()</span></tt></a> may take:</p>
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="../design/poolmvff.html#MPS_KEY_EXTEND_BY" title="MPS_KEY_EXTEND_BY"><tt class="xref c c-macro docutils literal"><span class="pre">MPS_KEY_EXTEND_BY</span></tt></a> (type <tt class="xref c c-type docutils literal"><span class="pre">size_t</span></tt>, default 65536) is the
|
|
<a class="reference internal" href="../glossary/s.html#term-size"><em class="xref std std-term">size</em></a> of segment that the pool will request from the
|
|
<a class="reference internal" href="../glossary/a.html#term-arena"><em class="xref std std-term">arena</em></a>. It must be at least as big as the unit size
|
|
specified by the <tt class="xref c c-macro docutils literal"><span class="pre">MPS_KEY_MFS_UNIT_SIZE</span></tt> keyword
|
|
argument. If this is not a multiple of the unit size, there will
|
|
be wasted space in each segment.</li>
|
|
</ul>
|
|
<p>For example:</p>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="n">MPS_ARGS_BEGIN</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="p">{</span>
|
|
<span class="n">MPS_ARGS_ADD</span><span class="p">(</span><span class="n">ARGS</span><span class="p">,</span> <span class="n">MPS_KEY_MFS_UNIT_SIZE</span><span class="p">,</span> <span class="mi">1024</span><span class="p">);</span>
|
|
<span class="n">MPS_ARGS_ADD</span><span class="p">(</span><span class="n">ARGS</span><span class="p">,</span> <span class="n">MPS_KEY_EXTEND_BY</span><span class="p">,</span> <span class="mi">1024</span> <span class="o">*</span> <span class="mi">1024</span><span class="p">);</span>
|
|
<span class="n">MPS_ARGS_DONE</span><span class="p">(</span><span class="n">args</span><span class="p">);</span>
|
|
<span class="n">res</span> <span class="o">=</span> <span class="n">mps_pool_create_k</span><span class="p">(</span><span class="o">&</span><span class="n">pool</span><span class="p">,</span> <span class="n">arena</span><span class="p">,</span> <span class="n">mps_class_mfs</span><span class="p">(),</span> <span class="n">args</span><span class="p">);</span>
|
|
<span class="p">}</span> <span class="n">MPS_ARGS_END</span><span class="p">(</span><span class="n">args</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<div class="admonition-deprecated admonition">
|
|
<p class="first admonition-title">Deprecated</p>
|
|
<p>starting with version 1.112.</p>
|
|
<p>When using <a class="reference internal" href="../topic/pool.html#mps_pool_create" title="mps_pool_create"><tt class="xref c c-func docutils literal"><span class="pre">mps_pool_create()</span></tt></a>, pass the segment size and
|
|
unit size like this:</p>
|
|
<div class="last highlight-c"><div class="highlight"><pre><span class="n">mps_res_t</span> <span class="n">mps_pool_create</span><span class="p">(</span><span class="n">mps_pool_t</span> <span class="o">*</span><span class="n">pool_o</span><span class="p">,</span> <span class="n">mps_arena_t</span> <span class="n">arena</span><span class="p">,</span>
|
|
<span class="n">mps_class_t</span> <span class="n">mps_class_mfs</span><span class="p">(),</span>
|
|
<span class="n">mps_size_t</span> <span class="n">extend_size</span><span class="p">,</span>
|
|
<span class="n">mps_size_t</span> <span class="n">unit_size</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<p class="logo"><a href="../index.html">
|
|
<img class="logo" src="../_static/logo.png" alt="Logo"/>
|
|
</a></p>
|
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">9. MFS (Manual Fixed Small)</a><ul>
|
|
<li><a class="reference internal" href="#mfs-properties">9.1. MFS properties</a></li>
|
|
<li><a class="reference internal" href="#mfs-interface">9.2. MFS interface</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="lo.html"
|
|
title="previous chapter">8. LO (Leaf Object)</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="mv.html"
|
|
title="next chapter">10. MV (Manual Variable)</a></p><h4>Downloads</h4>
|
|
|
|
<p class="topless">
|
|
<a href="http://www.ravenbrook.com/project/mps/release/1.111.0/">MPS Kit release 1.111.0</a><br>
|
|
<a href="http://www.ravenbrook.com/project/mps/release/">All MPS Kit releases</a>
|
|
</p>
|
|
|
|
<h4>Issues</h4>
|
|
|
|
<p class="topless">
|
|
<a href="http://www.ravenbrook.com/project/mps/issue/?action=list&view=status%3dopen&display=Job:Priority:Title&sort=Priority">Known issues</a><br>
|
|
<a href="http://www.ravenbrook.com/project/mps/issue/?action=fixed&release_fixed=1.111.0">Issues fixed in release 1.111.0</a>
|
|
</p><h4>Contact us</h4>
|
|
|
|
<p class="topless"><a href="mailto:mps-questions@ravenbrook.com">mps-questions@ravenbrook.com</a></p>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="mv.html" title="10. MV (Manual Variable)"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="lo.html" title="8. LO (Leaf Object)"
|
|
>previous</a> |</li>
|
|
<li><a href="../index.html">Memory Pool System 1.111.0 documentation</a> »</li>
|
|
<li><a href="index.html" >Pool reference</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer">
|
|
© <a href="../copyright.html">Copyright</a> 2013, Ravenbrook Limited.
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
|
</div>
|
|
</body>
|
|
</html> |