]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/mpool.3
Put SEE ALSO section into alphabetical order.
[thirdparty/man-pages.git] / man3 / mpool.3
1 .\" Copyright (c) 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
33 .\"
34 .TH MPOOL 3 1993-06-04 "" "Linux Programmer's Manual"
35 .UC 7
36 .SH NAME
37 mpool \- shared memory buffer pool
38 .SH SYNOPSIS
39 .nf
40 .B #include <db.h>
41 .B #include <mpool.h>
42 .sp
43 .BI "MPOOL *mpool_open(DBT *" key ", int " fd ", pgno_t " pagesize \
44 ", pgno_t " maxcache );
45 .sp
46 .BI "void mpool_filter(MPOOL *" mp ", void (*pgin)(void *, pgno_t, void *),"
47 .BI " void (*" pgout ")(void *, pgno_t, void *),"
48 .BI " void *" pgcookie );
49 .sp
50 .BI "void *mpool_new(MPOOL *" mp ", pgno_t *" pgnoaddr );
51 .sp
52 .BI "void *mpool_get(MPOOL *" mp ", pgno_t " pgno ", unsigned int " flags );
53 .sp
54 .BI "int mpool_put(MPOOL *" mp ", void *" pgaddr ", unsigned int " flags );
55 .sp
56 .BI "int mpool_sync(MPOOL *" mp );
57 .sp
58 .BI "int mpool_close(MPOOL *" mp );
59 .fi
60 .SH DESCRIPTION
61 .I Mpool
62 is the library interface intended to provide page oriented buffer management
63 of files.
64 The buffers may be shared between processes.
65 .PP
66 The function
67 .BR mpool_open ()
68 initializes a memory pool.
69 The
70 .I key
71 argument is the byte string used to negotiate between multiple
72 processes wishing to share buffers.
73 If the file buffers are mapped in shared memory, all processes using
74 the same key will share the buffers.
75 If
76 .I key
77 is NULL, the buffers are mapped into private memory.
78 The
79 .I fd
80 argument is a file descriptor for the underlying file, which must be seekable.
81 If
82 .I key
83 is non-NULL and matches a file already being mapped, the
84 .I fd
85 argument is ignored.
86 .PP
87 The
88 .I pagesize
89 argument is the size, in bytes, of the pages into which the file is broken up.
90 The
91 .I maxcache
92 argument is the maximum number of pages from the underlying file to cache
93 at any one time.
94 This value is not relative to the number of processes which share a file's
95 buffers, but will be the largest value specified by any of the processes
96 sharing the file.
97 .PP
98 The
99 .BR mpool_filter ()
100 function is intended to make transparent input and output processing of the
101 pages possible.
102 If the
103 .I pgin
104 function is specified, it is called each time a buffer is read into the memory
105 pool from the backing file.
106 If the
107 .I pgout
108 function is specified, it is called each time a buffer is written into the
109 backing file.
110 Both functions are called with the
111 .I pgcookie
112 pointer, the page number and a pointer to the page to being read or written.
113 .PP
114 The function
115 .BR mpool_new ()
116 takes an
117 .I MPOOL
118 pointer and an address as arguments.
119 If a new page can be allocated, a pointer to the page is returned and
120 the page number is stored into the
121 .I pgnoaddr
122 address.
123 Otherwise, NULL is returned and
124 .I errno
125 is set.
126 .PP
127 The function
128 .BR mpool_get ()
129 takes an
130 .I MPOOL
131 pointer and a page number as arguments.
132 If the page exists, a pointer to the page is returned.
133 Otherwise, NULL is returned and
134 .I errno
135 is set.
136 The
137 .I flags
138 argument is not currently used.
139 .PP
140 The function
141 .BR mpool_put ()
142 unpins the page referenced by
143 .IR pgaddr .
144 .I pgaddr
145 must be an address previously returned by
146 .BR mpool_get ()
147 or
148 .BR mpool_new ().
149 The flag value is specified by
150 .IR or 'ing
151 any of the following values:
152 .TP
153 .B MPOOL_DIRTY
154 The page has been modified and needs to be written to the backing file.
155 .PP
156 .BR mpool_put ()
157 returns 0 on success and \-1 if an error occurs.
158 .PP
159 The function
160 .BR mpool_sync ()
161 writes all modified pages associated with the
162 .I MPOOL
163 pointer to the
164 backing file.
165 .BR mpool_sync ()
166 returns 0 on success and \-1 if an error occurs.
167 .PP
168 The
169 .BR mpool_close ()
170 function free's up any allocated memory associated with the memory pool
171 cookie.
172 Modified pages are
173 .B not
174 written to the backing file.
175 .BR mpool_close ()
176 returns 0 on success and \-1 if an error occurs.
177 .SH ERRORS
178 The
179 .BR mpool_open ()
180 function may fail and set
181 .I errno
182 for any of the errors specified for the library routine
183 .BR malloc (3).
184 .PP
185 The
186 .BR mpool_get ()
187 function may fail and set
188 .I errno
189 for the following:
190 .TP 15
191 .B EINVAL
192 The requested record doesn't exist.
193 .PP
194 The
195 .BR mpool_new ()
196 and
197 .BR mpool_get ()
198 functions may fail and set
199 .I errno
200 for any of the errors specified for the library routines
201 .BR read (2),
202 .BR write (2),
203 and
204 .BR malloc (3).
205 .PP
206 The
207 .BR mpool_sync ()
208 function may fail and set
209 .I errno
210 for any of the errors specified for the library routine
211 .BR write (2).
212 .PP
213 The
214 .BR mpool_close ()
215 function may fail and set
216 .I errno
217 for any of the errors specified for the library routine
218 .BR free (3).
219 .SH "CONFORMING TO"
220 Not in POSIX.1-2001.
221 Present on the BSDs.
222 .SH "SEE ALSO"
223 .BR btree (3),
224 .BR dbopen (3),
225 .BR hash (3),
226 .BR recno (3)