1 |
742 |
jeremybenn |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2 |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
3 |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Chapter 21. The bitmap_allocator</title><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"/><meta name="keywords" content=" ISO C++ , allocator "/><meta name="keywords" content=" ISO C++ , library "/><meta name="keywords" content=" ISO C++ , runtime , library "/><link rel="home" href="../index.html" title="The GNU C++ Library"/><link rel="up" href="extensions.html" title="Part III. Extensions"/><link rel="prev" href="bk01pt03ch20s05.html" title="Multiple Thread Example"/><link rel="next" href="bk01pt03ch21s02.html" title="Implementation"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 21. The bitmap_allocator</th></tr><tr><td align="left"><a accesskey="p" href="bk01pt03ch20s05.html">Prev</a> </td><th width="60%" align="center">Part III.
|
4 |
|
|
Extensions
|
5 |
|
|
|
6 |
|
|
</th><td align="right"> <a accesskey="n" href="bk01pt03ch21s02.html">Next</a></td></tr></table><hr/></div><div class="chapter" title="Chapter 21. The bitmap_allocator"><div class="titlepage"><div><div><h2 class="title"><a id="manual.ext.allocator.bitmap"/>Chapter 21. The bitmap_allocator</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl><dt><span class="section"><a href="bitmap_allocator.html#allocator.bitmap.design">Design</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html">Implementation</a></span></dt><dd><dl><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.free_list_store">Free List Store</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.super_block">Super Block</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.super_block_data">Super Block Data Layout</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.max_wasted">Maximum Wasted Percentage</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.allocate"><code class="function">allocate</code></a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.deallocate"><code class="function">deallocate</code></a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.questions">Questions</a></span></dt><dd><dl><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.question.1">1</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.question.2">2</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.question.3">3</a></span></dt></dl></dd><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.locality">Locality</a></span></dt><dt><span class="section"><a href="bk01pt03ch21s02.html#bitmap.impl.grow_policy">Overhead and Grow Policy</a></span></dt></dl></dd></dl></div><p>
|
7 |
|
|
</p><div class="section" title="Design"><div class="titlepage"><div><div><h2 class="title"><a id="allocator.bitmap.design"/>Design</h2></div></div></div><p>
|
8 |
|
|
As this name suggests, this allocator uses a bit-map to keep track
|
9 |
|
|
of the used and unused memory locations for its book-keeping
|
10 |
|
|
purposes.
|
11 |
|
|
</p><p>
|
12 |
|
|
This allocator will make use of 1 single bit to keep track of
|
13 |
|
|
whether it has been allocated or not. A bit 1 indicates free,
|
14 |
|
|
while 0 indicates allocated. This has been done so that you can
|
15 |
|
|
easily check a collection of bits for a free block. This kind of
|
16 |
|
|
Bitmapped strategy works best for single object allocations, and
|
17 |
|
|
with the STL type parameterized allocators, we do not need to
|
18 |
|
|
choose any size for the block which will be represented by a
|
19 |
|
|
single bit. This will be the size of the parameter around which
|
20 |
|
|
the allocator has been parameterized. Thus, close to optimal
|
21 |
|
|
performance will result. Hence, this should be used for node based
|
22 |
|
|
containers which call the allocate function with an argument of 1.
|
23 |
|
|
</p><p>
|
24 |
|
|
The bitmapped allocator's internal pool is exponentially growing.
|
25 |
|
|
Meaning that internally, the blocks acquired from the Free List
|
26 |
|
|
Store will double every time the bitmapped allocator runs out of
|
27 |
|
|
memory.
|
28 |
|
|
</p><p>
|
29 |
|
|
The macro <code class="literal">__GTHREADS</code> decides whether to use
|
30 |
|
|
Mutex Protection around every allocation/deallocation. The state
|
31 |
|
|
of the macro is picked up automatically from the gthr abstraction
|
32 |
|
|
layer.
|
33 |
|
|
</p></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td align="left"><a accesskey="p" href="bk01pt03ch20s05.html">Prev</a> </td><td align="center"><a accesskey="u" href="extensions.html">Up</a></td><td align="right"> <a accesskey="n" href="bk01pt03ch21s02.html">Next</a></td></tr><tr><td align="left" valign="top">Multiple Thread Example </td><td align="center"><a accesskey="h" href="../index.html">Home</a></td><td align="right" valign="top"> Implementation</td></tr></table></div></body></html>
|