mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-02 16:23:56 +08:00
howto.html, [...]: Fix markup, more <link> tags.
2004-02-25 Jonathan Wakely <redi@gcc.gnu.org> * docs/html/20_util/howto.html, docs/html/20_util/allocator.html, docs/html/ext/howto.html, docs/html/ext/mt_allocator.html: Fix markup, more <link> tags. From-SVN: r78495
This commit is contained in:
parent
1e2a4850db
commit
cec0e70b44
@ -1,3 +1,9 @@
|
|||||||
|
2004-02-25 Jonathan Wakely <redi@gcc.gnu.org>
|
||||||
|
|
||||||
|
* docs/html/20_util/howto.html, docs/html/20_util/allocator.html,
|
||||||
|
docs/html/ext/howto.html, docs/html/ext/mt_allocator.html:
|
||||||
|
Fix markup, more <link> tags.
|
||||||
|
|
||||||
2004-02-25 Carlo Wood <carlo@alinoe.com>
|
2004-02-25 Carlo Wood <carlo@alinoe.com>
|
||||||
|
|
||||||
* bits/demangle.h
|
* bits/demangle.h
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
<meta name="GENERATOR" content="emacs and ten fingers" />
|
<meta name="GENERATOR" content="emacs and ten fingers" />
|
||||||
<title>Allocators and allocation</title>
|
<title>Allocators and allocation</title>
|
||||||
<link rel="StyleSheet" href="../lib3styles.css" type="text/css" />
|
<link rel="StyleSheet" href="../lib3styles.css" type="text/css" />
|
||||||
|
<link rel="Start" href="../documentation.html" type="text/html"
|
||||||
|
title="GNU C++ Standard Library" />
|
||||||
|
<link rel="Bookmark" href="howto.html" type="text/html"
|
||||||
|
title="General Utilities" />
|
||||||
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -35,7 +39,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 class="left">
|
<h3 class="left">
|
||||||
<a name="standard requirements">Standard requirements</a>
|
<a name="standard_requirements">Standard requirements</a>
|
||||||
</h3>
|
</h3>
|
||||||
<p>The C++ standard only gives a few directives in this area:
|
<p>The C++ standard only gives a few directives in this area:
|
||||||
</p>
|
</p>
|
||||||
@ -74,7 +78,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 class="left">
|
<h3 class="left">
|
||||||
<a name="probs possibilities">Problems and Possibilities</a>
|
<a name="probs_possibilities">Problems and Possibilities</a>
|
||||||
</h3>
|
</h3>
|
||||||
<p>The easiest way of fulfilling the requirements is to call operator new
|
<p>The easiest way of fulfilling the requirements is to call operator new
|
||||||
each time a container needs memory, and to call operator delete each
|
each time a container needs memory, and to call operator delete each
|
||||||
@ -256,7 +260,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 class="left">
|
<h3 class="left">
|
||||||
<a name="ext allocators">Other allocators</a>
|
<a name="ext_allocators">Other allocators</a>
|
||||||
</h3>
|
</h3>
|
||||||
<p> Several other allocators are provided as part of this
|
<p> Several other allocators are provided as part of this
|
||||||
implementation. The location of the extension allocators and their
|
implementation. The location of the extension allocators and their
|
||||||
@ -381,7 +385,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<h3 class="left">
|
<h3 class="left">
|
||||||
<a name="using custom allocators">Using a specific allocator</a>
|
<a name="using_custom_allocators">Using a specific allocator</a>
|
||||||
</h3>
|
</h3>
|
||||||
<p>You can specify different memory management schemes on a
|
<p>You can specify different memory management schemes on a
|
||||||
per-container basis, by overriding the default
|
per-container basis, by overriding the default
|
||||||
@ -397,7 +401,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<h3 class="left">
|
<h3 class="left">
|
||||||
<a name="custom allocators">Writing custom allocators</a>
|
<a name="custom_allocators">Writing custom allocators</a>
|
||||||
</h3>
|
</h3>
|
||||||
<p> Writing a portable C++ allocator would dictate that the
|
<p> Writing a portable C++ allocator would dictate that the
|
||||||
interface would look much like the one specified for <code>
|
interface would look much like the one specified for <code>
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
title="Diagnostics" />
|
title="Diagnostics" />
|
||||||
<link rel="Next" href="../21_strings/howto.html" type="text/html"
|
<link rel="Next" href="../21_strings/howto.html" type="text/html"
|
||||||
title="Strings" />
|
title="Strings" />
|
||||||
|
<link rel="Bookmark" href="allocator.html" type="text/html"
|
||||||
|
title="Allocators and allocation" />
|
||||||
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
||||||
<link rel="Help" href="../faq/index.html" type="text/html" title="F.A.Q." />
|
<link rel="Help" href="../faq/index.html" type="text/html" title="F.A.Q." />
|
||||||
</head>
|
</head>
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
title="Input/Output" />
|
title="Input/Output" />
|
||||||
<link rel="Bookmark" href="sgiexts.html" type="text/html"
|
<link rel="Bookmark" href="sgiexts.html" type="text/html"
|
||||||
title="SGI extensions" />
|
title="SGI extensions" />
|
||||||
|
<link rel="Bookmark" href="mt_allocator.html" type="text/html"
|
||||||
|
title="__mt_alloc" />
|
||||||
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta name="AUTHOR" content="Stefan Olsson <stefan@xapa.se>" />
|
<meta name="AUTHOR" content="Stefan Olsson <stefan@xapa.se>" />
|
||||||
<meta name="KEYWORDS" content="c++, libstdc++, g++, allocator, memory" />
|
<meta name="KEYWORDS" content="c++, libstdc++, g++, allocator, memory" />
|
||||||
<meta name="DESCRIPTION" content="Allocators and allocation" />
|
<meta name="DESCRIPTION" content="Allocators and allocation" />
|
||||||
<meta name="GENERATOR" content="emacs and ten fingers" />
|
<meta name="GENERATOR" content="emacs and ten fingers" />
|
||||||
<title>A fixed-size, multi-thread optimized allocator</title>
|
<title>A fixed-size, multi-thread optimized allocator</title>
|
||||||
<link rel="StyleSheet" href="../lib3styles.css" type="text/css" />
|
<link rel="StyleSheet" href="../lib3styles.css" type="text/css" />
|
||||||
|
<link rel="Start" href="../documentation.html" type="text/html"
|
||||||
|
title="GNU C++ Standard Library" />
|
||||||
|
<link rel="Bookmark" href="howto.html" type="text/html" title="Extensions" />
|
||||||
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
<link rel="Copyright" href="../17_intro/license.html" type="text/html" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -61,8 +64,8 @@ are initialized to their default values at file scope, i.e.:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
template<typename _Tp> size_t
|
template<typename _Tp> size_t
|
||||||
__mt_alloc<_Tp>::_S_freelist_headroom = 10;
|
__mt_alloc<_Tp>::_S_freelist_headroom = 10;
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -100,7 +103,7 @@ The _S_init() function:
|
|||||||
as many bin_records in this array as the number of bins that we calculated
|
as many bin_records in this array as the number of bins that we calculated
|
||||||
earlier. I.e., if _S_max_bytes = 128 there will be 8 entries.
|
earlier. I.e., if _S_max_bytes = 128 there will be 8 entries.
|
||||||
Each bin_record is then initialized:
|
Each bin_record is then initialized:
|
||||||
- bin_record->first = An array of pointers to block_records. There will be
|
- bin_record->first = An array of pointers to block_records. There will be
|
||||||
as many block_records pointers as there are maximum number of threads
|
as many block_records pointers as there are maximum number of threads
|
||||||
(in a ST application there is only 1 thread, in a MT application there
|
(in a ST application there is only 1 thread, in a MT application there
|
||||||
are _S_max_threads).
|
are _S_max_threads).
|
||||||
@ -127,7 +130,7 @@ The _S_init() function:
|
|||||||
created thread and we pop the first entry from this list and saves the
|
created thread and we pop the first entry from this list and saves the
|
||||||
pointer to this record in the _S_thread_key variable. The next time
|
pointer to this record in the _S_thread_key variable. The next time
|
||||||
we will get the pointer to the thread_record back and we use the
|
we will get the pointer to the thread_record back and we use the
|
||||||
thread_record->thread_id as identification. I.e., the first thread that
|
thread_record->thread_id as identification. I.e., the first thread that
|
||||||
calls allocate will get the first record in this list and thus be thread
|
calls allocate will get the first record in this list and thus be thread
|
||||||
number 1 and will then find the pointer to its first free 32 byte block
|
number 1 and will then find the pointer to its first free 32 byte block
|
||||||
in _S_bin[ 5 ].first[ 1 ]
|
in _S_bin[ 5 ].first[ 1 ]
|
||||||
@ -140,12 +143,12 @@ The _S_init() function:
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
- Initialize the free and used counters of each bin_record:
|
- Initialize the free and used counters of each bin_record:
|
||||||
- bin_record->free = An array of size_t. This keeps track of the number
|
- bin_record->free = An array of size_t. This keeps track of the number
|
||||||
of blocks on a specific thread's freelist in each bin. I.e., if a thread
|
of blocks on a specific thread's freelist in each bin. I.e., if a thread
|
||||||
has 12 32-byte blocks on it's freelists and allocates one of these, this
|
has 12 32-byte blocks on it's freelists and allocates one of these, this
|
||||||
counter would be decreased to 11.
|
counter would be decreased to 11.
|
||||||
|
|
||||||
- bin_record->used = An array of size_t. This keeps track of the number
|
- bin_record->used = An array of size_t. This keeps track of the number
|
||||||
of blocks currently in use of this size by this thread. I.e., if a thread
|
of blocks currently in use of this size by this thread. I.e., if a thread
|
||||||
has made 678 requests (and no deallocations...) of 32-byte blocks this
|
has made 678 requests (and no deallocations...) of 32-byte blocks this
|
||||||
counter will read 678.
|
counter will read 678.
|
||||||
@ -155,7 +158,7 @@ The _S_init() function:
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
- Initialize the mutex of each bin_record:
|
- Initialize the mutex of each bin_record:
|
||||||
The bin_record->mutex is used to protect the global freelist. This concept
|
The bin_record->mutex is used to protect the global freelist. This concept
|
||||||
of a global freelist is explained in more detail in the section
|
of a global freelist is explained in more detail in the section
|
||||||
"A multi threaded example", but basically this mutex is locked whenever
|
"A multi threaded example", but basically this mutex is locked whenever
|
||||||
a block of memory is retrieved or returned to the global freelist for this
|
a block of memory is retrieved or returned to the global freelist for this
|
||||||
@ -194,7 +197,7 @@ This is the first two blocks in freelist for thread id 3 in bin 3 (8 bytes):
|
|||||||
| | |
|
| | |
|
||||||
+----------------+ |
|
+----------------+ |
|
||||||
+----------------+ |
|
+----------------+ |
|
||||||
| next* |<-+ (If next == NULL it's the last one on the list)
|
| next* |<-+ (If next == NULL it's the last one on the list)
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
@ -223,7 +226,7 @@ assigned this id since they span from 1 to _S_max_threads in a MT application).
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
When the application requests memory (calling allocate()) we first look at the
|
When the application requests memory (calling allocate()) we first look at the
|
||||||
requested size and if this is > _S_max_bytes we call new() directly and return.
|
requested size and if this is > _S_max_bytes we call new() directly and return.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If the requested size is within limits we start by finding out from which
|
If the requested size is within limits we start by finding out from which
|
||||||
@ -297,7 +300,7 @@ not when a deallocation occurs.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
When the application requests memory (calling allocate()) we first
|
When the application requests memory (calling allocate()) we first
|
||||||
look at the requested size and if this is > _S_max_bytes we call new()
|
look at the requested size and if this is > _S_max_bytes we call new()
|
||||||
directly and return.
|
directly and return.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user