add db.1.85
[nvi.git] / db.1.85 / man / mpool.3
blobc17606ebc9b9f6d44bf790b0708bb31dc0ca1cae
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 "June 4, 1993"
35 .UC 7
36 .SH NAME
37 mpool \- shared memory buffer pool
38 .SH SYNOPSIS
39 .nf
40 .ft B
41 #include <db.h>
42 #include <mpool.h>
44 MPOOL *
45 mpool_open (DBT *key, int fd, pgno_t pagesize, pgno_t maxcache);
47 void
48 mpool_filter (MPOOL *mp, void (*pgin)(void *, pgno_t, void *),
49 .ti +5
50 void (*pgout)(void *, pgno_t, void *), void *pgcookie);
52 void *
53 mpool_new (MPOOL *mp, pgno_t *pgnoaddr);
55 void *
56 mpool_get (MPOOL *mp, pgno_t pgno, u_int flags);
58 int
59 mpool_put (MPOOL *mp, void *pgaddr, u_int flags);
61 int
62 mpool_sync (MPOOL *mp);
64 int
65 mpool_close (MPOOL *mp);
66 .ft R
67 .fi
68 .SH DESCRIPTION
69 .IR Mpool
70 is the library interface intended to provide page oriented buffer management
71 of files.
72 The buffers may be shared between processes.
73 .PP
74 The function
75 .I mpool_open
76 initializes a memory pool.
77 The
78 .I key
79 argument is the byte string used to negotiate between multiple
80 processes wishing to share buffers.
81 If the file buffers are mapped in shared memory, all processes using
82 the same key will share the buffers.
84 .I key
85 is NULL, the buffers are mapped into private memory.
86 The
87 .I fd
88 argument is a file descriptor for the underlying file, which must be seekable.
90 .I key
91 is non-NULL and matches a file already being mapped, the
92 .I fd
93 argument is ignored.
94 .PP
95 The
96 .I pagesize
97 argument is the size, in bytes, of the pages into which the file is broken up.
98 The
99 .I maxcache
100 argument is the maximum number of pages from the underlying file to cache
101 at any one time.
102 This value is not relative to the number of processes which share a file's
103 buffers, but will be the largest value specified by any of the processes
104 sharing the file.
107 .I mpool_filter
108 function is intended to make transparent input and output processing of the
109 pages possible.
110 If the
111 .I pgin
112 function is specified, it is called each time a buffer is read into the memory
113 pool from the backing file.
114 If the
115 .I pgout
116 function is specified, it is called each time a buffer is written into the
117 backing file.
118 Both functions are are called with the
119 .I pgcookie
120 pointer, the page number and a pointer to the page to being read or written.
122 The function
123 .I mpool_new
124 takes an MPOOL pointer and an address as arguments.
125 If a new page can be allocated, a pointer to the page is returned and
126 the page number is stored into the
127 .I pgnoaddr
128 address.
129 Otherwise, NULL is returned and errno is set.
131 The function
132 .I mpool_get
133 takes a MPOOL pointer and a page number as arguments.
134 If the page exists, a pointer to the page is returned.
135 Otherwise, NULL is returned and errno is set.
136 The flags parameter is not currently used.
138 The function
139 .I mpool_put
140 unpins the page referenced by
141 .IR pgaddr .
142 .I Pgaddr
143 must be an address previously returned by
144 .I mpool_get
146 .IR mpool_new .
147 The flag value is specified by
148 .IR or 'ing
149 any of the following values:
151 MPOOL_DIRTY
152 The page has been modified and needs to be written to the backing file.
154 .I Mpool_put
155 returns 0 on success and -1 if an error occurs.
157 The function
158 .I mpool_sync
159 writes all modified pages associated with the MPOOL pointer to the
160 backing file.
161 .I Mpool_sync
162 returns 0 on success and -1 if an error occurs.
165 .I mpool_close
166 function free's up any allocated memory associated with the memory pool
167 cookie.
168 Modified pages are
169 .B not
170 written to the backing file.
171 .I Mpool_close
172 returns 0 on success and -1 if an error occurs.
173 .SH ERRORS
175 .I mpool_open
176 function may fail and set
177 .I errno
178 for any of the errors specified for the library routine
179 .IR malloc (3).
182 .I mpool_get
183 function may fail and set
184 .I errno
185 for the following:
186 .TP 15
187 [EINVAL]
188 The requested record doesn't exist.
191 .I mpool_new
193 .I mpool_get
194 functions may fail and set
195 .I errno
196 for any of the errors specified for the library routines
197 .IR read (2) ,
198 .IR write (2) ,
200 .IR malloc (3).
203 .I mpool_sync
204 function may fail and set
205 .I errno
206 for any of the errors specified for the library routine
207 .IR write (2).
210 .I mpool_close
211 function may fail and set
212 .I errno
213 for any of the errors specified for the library routine
214 .IR free (3).
215 .SH "SEE ALSO"
216 .IR dbopen (3),
217 .IR btree (3),
218 .IR hash (3),
219 .IR recno (3)