1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DB_ENV->mutex_alloc()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="mutex.html" title="Chapter 9. Mutex Methods" /> 11 <link rel="prev" href="mutex.html" title="Chapter 9. Mutex Methods" /> 12 <link rel="next" href="mutexfree.html" title="DB_ENV->mutex_free()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->mutex_alloc()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="mutex.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 9. 23 Mutex Methods 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="mutexfree.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="mutexalloc"></a>DB_ENV->mutex_alloc()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->mutex_alloc(DB_ENV *dbenv, u_int32_t flags, db_mutex_t *mutexp); </pre> 42 <p> 43 The <code class="methodname">DB_ENV->mutex_alloc()</code> method allocates a mutex and returns a 44 reference to it into the memory specified by <span class="bold"><strong>mutexp</strong></span>. 45 </p> 46 <p> 47 The <code class="methodname">DB_ENV->mutex_alloc()</code> method may not be called before the 48 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is called. 49 </p> 50 <p> 51 The <code class="methodname">DB_ENV->mutex_alloc()</code> <span> 52 <span> 53 method returns a non-zero error value on failure and 0 on success. 54 </span> 55 56 </span> 57 </p> 58 <div class="sect2" lang="en" xml:lang="en"> 59 <div class="titlepage"> 60 <div> 61 <div> 62 <h3 class="title"><a id="id1693127"></a>Parameters</h3> 63 </div> 64 </div> 65 </div> 66 <div class="sect3" lang="en" xml:lang="en"> 67 <div class="titlepage"> 68 <div> 69 <div> 70 <h4 class="title"><a id="id1693330"></a>flags</h4> 71 </div> 72 </div> 73 </div> 74 <p> 75 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 76 or by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing 77 together one or more of the following values: 78 </p> 79 <div class="itemizedlist"> 80 <ul type="disc"> 81 <li> 82 <p><a id="alloc_DB_MUTEX_PROCESS_ONLY"></a> 83 <code class="literal">DB_MUTEX_PROCESS_ONLY</code> 84 </p> 85 <p> 86 The mutex is associated with a single process. The 87 <a class="xref" href="envfailchk.html" title="DB_ENV->failchk()">DB_ENV->failchk()</a> method will 88 release mutexes held by any process which has exited. 89 </p> 90 </li> 91 <li> 92 <p><a id="alloc_DB_MUTEX_SELF_BLOCK"></a> 93 <code class="literal">DB_MUTEX_SELF_BLOCK</code> 94 </p> 95 <p> 96 The mutex must be self-blocking. That is, if a thread of control 97 locks the mutex and then attempts to lock the mutex again, the thread 98 of control will block until another thread of control releases the 99 original lock on the mutex, allowing the original thread of control to 100 lock the mutex the second time. Attempting to re-acquire a mutex for 101 which the <code class="literal">DB_MUTEX_SELF_BLOCK</code> flag was not specified will result in 102 undefined behavior. 103 </p> 104 </li> 105 </ul> 106 </div> 107 </div> 108 <div class="sect3" lang="en" xml:lang="en"> 109 <div class="titlepage"> 110 <div> 111 <div> 112 <h4 class="title"><a id="id1693562"></a>mutexp</h4> 113 </div> 114 </div> 115 </div> 116 <p> 117 The <span class="bold"><strong>mutexp</strong></span> parameter references 118 memory into which the mutex reference is copied. 119 </p> 120 </div> 121 </div> 122 <div class="sect2" lang="en" xml:lang="en"> 123 <div class="titlepage"> 124 <div> 125 <div> 126 <h3 class="title"><a id="id1693128"></a>Errors</h3> 127 </div> 128 </div> 129 </div> 130 <p> 131 The <code class="methodname">DB_ENV->mutex_alloc()</code> <span> 132 <span> 133 method may fail and return one of the following non-zero errors: 134 </span> 135 136 </span> 137 </p> 138 <div class="sect3" lang="en" xml:lang="en"> 139 <div class="titlepage"> 140 <div> 141 <div> 142 <h4 class="title"><a id="id1693413"></a>EINVAL</h4> 143 </div> 144 </div> 145 </div> 146 <p> 147 An invalid flag value or parameter was specified. 148 </p> 149 </div> 150 </div> 151 <div class="sect2" lang="en" xml:lang="en"> 152 <div class="titlepage"> 153 <div> 154 <div> 155 <h3 class="title"><a id="id1693563"></a>Class</h3> 156 </div> 157 </div> 158 </div> 159 <p> 160 <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a> 161 </p> 162 </div> 163 <div class="sect2" lang="en" xml:lang="en"> 164 <div class="titlepage"> 165 <div> 166 <div> 167 <h3 class="title"><a id="id1693461"></a>See Also</h3> 168 </div> 169 </div> 170 </div> 171 <p> 172 <a class="xref" href="mutex.html#mutexlist" title="Mutex Methods">Mutex Methods</a> 173 </p> 174 </div> 175 </div> 176 <div class="navfooter"> 177 <hr /> 178 <table width="100%" summary="Navigation footer"> 179 <tr> 180 <td width="40%" align="left"><a accesskey="p" href="mutex.html">Prev</a> </td> 181 <td width="20%" align="center"> 182 <a accesskey="u" href="mutex.html">Up</a> 183 </td> 184 <td width="40%" align="right"> <a accesskey="n" href="mutexfree.html">Next</a></td> 185 </tr> 186 <tr> 187 <td width="40%" align="left" valign="top">Chapter 9. 188 Mutex Methods 189 </td> 190 <td width="20%" align="center"> 191 <a accesskey="h" href="index.html">Home</a> 192 </td> 193 <td width="40%" align="right" valign="top"> DB_ENV->mutex_free()</td> 194 </tr> 195 </table> 196 </div> 197 </body> 198</html> 199