1
<!--$Id: memp_register.so,v 10.24 2001/04/02 20:10:07 bostic Exp $-->
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
6
<title>Berkeley DB: memp_register</title>
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
11
<a name="2"><!--meow--></a>
12
<table width="100%"><tr valign=top>
14
<h1>memp_register</h1>
17
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
25
memp_register(DB_ENV *env, int ftype,
26
int (*pgin_fcn)(DB_ENV *, db_pgno_t pgno, void *pgaddr, DBT *pgcookie),
27
int (*pgout_fcn)(DB_ENV *, db_pgno_t pgno, void *pgaddr, DBT *pgcookie));
30
<p>The memp_register function registers page-in and page-out
31
functions for files of type <b>ftype</b> in the specified pool.
32
<p>If the <b>pgin_fcn</b> function is non-NULL, it is called each time
33
a page is read into the memory pool from a file of type <b>ftype</b>, or
34
a page is created for a file of type <b>ftype</b> (see the
35
DB_MPOOL_CREATE flag for the <a href="../api_c/memp_fget.html">memp_fget</a> function).
36
<p>If the <b>pgout_fcn</b> function is non-NULL, it is called each time
37
a page is written to a file of type <b>ftype</b>.
38
<p>Both the <b>pgin_fcn</b> and <b>pgout_fcn</b> functions are called with
39
a reference to the current environment, the page number, a pointer to the
40
page being read or written, and any argument <b>pgcookie</b> that was
41
specified to the <a href="../api_c/memp_fopen.html">memp_fopen</a> function when the file was opened.
42
The <b>pgin_fcn</b> and <b>pgout_fcn</b> functions should return 0 on
43
success, and an applicable non-zero <b>errno</b> value on failure, in
44
which case the shared memory pool interface routine (and, by extension,
45
any Berkeley DB library function) calling it will also fail, returning that
47
<p>The purpose of the memp_register function is to support processing
48
when pages are entered into, or flushed from, the pool. A file type must
49
be specified to make it possible for unrelated threads or processes that
50
are sharing a pool, to evict each other's pages from the pool. During
51
initialization, applications should call memp_register for each
52
type of file requiring input or output processing that will be sharing
53
the underlying pool. (No registry is necessary for the standard Berkeley DB
54
access method types because <a href="../api_c/db_open.html">DB->open</a> registers them separately.)
55
<p>If a thread or process does not call memp_register for a file
56
type, it is impossible for it to evict pages for any file requiring input
57
or output processing from the pool. For this reason,
58
memp_register should always be called by each application sharing
59
a pool for each type of file included in the pool, regardless of whether
60
or not the application itself uses files of that type.
61
<p>There are no standard values for <b>ftype</b>, <b>pgin_fcn</b>,
62
<b>pgout_fcn</b>, and <b>pgcookie</b>, except that the <b>ftype</b>
63
value for a file must be a non-zero positive number because negative
64
numbers are reserved for internal use by the Berkeley DB library. For this
65
reason, applications sharing a pool must coordinate their values among
67
<p>The memp_register function returns a non-zero error value on failure and 0 on success.
69
<p>The memp_register function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
70
If a catastrophic error has occurred, the memp_register function may fail and return
71
<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail
74
<a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>,
75
<a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>,
76
<a href="../api_c/memp_fclose.html">memp_fclose</a>,
77
<a href="../api_c/memp_fget.html">memp_fget</a>,
78
<a href="../api_c/memp_fopen.html">memp_fopen</a>,
79
<a href="../api_c/memp_fput.html">memp_fput</a>,
80
<a href="../api_c/memp_fset.html">memp_fset</a>,
81
<a href="../api_c/memp_fsync.html">memp_fsync</a>,
82
<a href="../api_c/memp_register.html">memp_register</a>,
83
<a href="../api_c/memp_stat.html">memp_stat</a>,
84
<a href="../api_c/memp_sync.html">memp_sync</a>,
86
<a href="../api_c/memp_trickle.html">memp_trickle</a>.
88
<table width="100%"><tr><td><br></td><td align=right>
89
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
91
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>