1<!--$Id: mutex_alloc.so,v 10.3 2007/09/21 20:06:03 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB_ENV-&gt;mutex_alloc</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB_ENV-&gt;mutex_alloc</b>
14</td>
15<td align=right>
16<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a>
17<a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB_ENV-&gt;mutex_alloc(DB_ENV *dbenv, u_int32_t flags, db_mutex_t *mutexp);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DB_ENV-&gt;mutex_alloc</b>
29<p>The DB_ENV-&gt;mutex_alloc method allocates a mutex and returns a reference to
30it into the memory specified by <b>mutexp</b>.</p>
31<p>The DB_ENV-&gt;mutex_alloc method may not be called before the <a href="/api_c/env_open.html">DB_ENV-&gt;open</a> method is called.</p>
32<p>The DB_ENV-&gt;mutex_alloc method
33returns a non-zero error value on failure
34and 0 on success.
35</p>
36<b>Parameters</b> <br>
37 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or
38the following value:
39<br>
40<b><a name="DB_MUTEX_PROCESS_ONLY">DB_MUTEX_PROCESS_ONLY</a></b><ul compact><li>The mutex is associated with a single process.  The <a href="/api_c/env_failchk.html">DB_ENV-&gt;failchk</a> method
41will release mutexes held by any process which has exited.</ul>
42<b><a name="DB_MUTEX_SELF_BLOCK">DB_MUTEX_SELF_BLOCK</a></b><ul compact><li>The mutex must be self-blocking.  That is, if a thread of control locks
43the mutex and then attempts to lock the mutex again, the thread of
44control will block until another thread of control releases the original
45lock on the mutex, allowing the original thread of control to lock the
46mutex the second time.  Attempting to re-acquire a mutex for which the
47DB_MUTEX_SELF_BLOCK flag was not specified will result in
48undefined behavior.</ul>
49<br></ul>
50 <b>mutexp</b><ul compact><li>The <b>mutexp</b> parameter references memory into which
51 the mutex reference is copied.</ul> 
52<br>
53<br><b>Errors</b>
54<p>The DB_ENV-&gt;mutex_alloc method
55may fail and return one of the following non-zero errors:</p>
56<br>
57<b>EINVAL</b><ul compact><li>An
58invalid flag value or parameter was specified.</ul>
59<br>
60<hr size=1 noshade>
61<br><b>Class</b>
62<a href="/api_c/env_class.html">DB_ENV</a>
63<br><b>See Also</b>
64<a href="/api_c/env_list.html">Database Environments and Related Methods</a>
65</tt>
66<table width="100%"><tr><td><br></td><td align=right>
67<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a>
68</td></tr></table>
69<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
70</body>
71</html>
72