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_stat()</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="mutexset_tas_spins.html" title="DB_ENV->mutex_set_tas_spins()" /> 12 <link rel="next" href="mutexstat_print.html" title="DB_ENV->mutex_stat_print()" /> 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_stat()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="mutexset_tas_spins.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="mutexstat_print.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="mutexstat"></a>DB_ENV->mutex_stat()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->mutex_stat(DB_ENV *env, DB_MUTEX_STAT **statp, u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DB_ENV->mutex_stat()</code> method returns the mutex subsystem 44 statistics. 45 </p> 46 <p> 47 The <code class="methodname">DB_ENV->mutex_stat()</code> method creates a statistical structure of 48 type <code class="literal">DB_MUTEX_STAT</code> and copies a pointer to it into a user-specified 49 memory location. 50 </p> 51 <p> 52 Statistical structures are stored in allocated memory. If 53 application-specific allocation routines have been declared (see 54 <a class="xref" href="envset_alloc.html" title="DB_ENV->set_alloc()">DB_ENV->set_alloc()</a> 55 for more information), they are used to allocate the memory; 56 otherwise, the standard C library <span class="bold"><strong>malloc</strong></span>(3) is used. The caller is responsible 57 for deallocating the memory. To deallocate the memory, free the 58 memory reference; references inside the returned memory need not be 59 individually freed. 60 </p> 61 <p> 62 The following <code class="literal">DB_MUTEX_STAT</code> fields will be filled in: 63 </p> 64 <div class="itemizedlist"> 65 <ul type="disc"> 66 <li> 67 <p> 68 <span class="bold"><strong>u_int32_t st_mutex_align;</strong></span> 69 </p> 70 <p> 71 The mutex alignment, in bytes. 72 </p> 73 </li> 74 <li> 75 <p> 76 <span class="bold"><strong>u_int32_t st_mutex_tas_spins;</strong></span> 77 </p> 78 <p> 79 The number of times test-and-set mutexes will spin without blocking. 80 </p> 81 </li> 82 <li> 83 <p> 84 <span class="bold"><strong>int st_mutex_cnt;</strong></span> 85 </p> 86 <p> 87 The total number of mutexes configured. 88 </p> 89 </li> 90 <li> 91 <p> 92 <span class="bold"><strong>u_int32_t st_mutex_free;</strong></span> 93 </p> 94 <p> 95 The number of mutexes currently available. 96 </p> 97 </li> 98 <li> 99 <p> 100 <span class="bold"><strong>u_int32_t st_mutex_inuse;</strong></span> 101 </p> 102 <p> 103 The number of mutexes currently in use. 104 </p> 105 </li> 106 <li> 107 <p> 108 <span class="bold"><strong>u_int32_t st_mutex_inuse_max;</strong></span> 109 </p> 110 <p> 111 The maximum number of mutexes ever in use. 112 </p> 113 </li> 114 <li> 115 <p> 116 <span class="bold"><strong>roff_t st_regsize;</strong></span> 117 </p> 118 <p> 119 The size of the mutex region, in bytes. 120 </p> 121 </li> 122 <li> 123 <p> 124 <span class="bold"><strong>uintmax_t st_region_wait;</strong></span> 125 </p> 126 <p> 127 The number of times that a thread of control was forced to wait before 128 obtaining the mutex region mutex. 129 </p> 130 </li> 131 <li> 132 <p> 133 <span class="bold"><strong>uintmax_t st_region_nowait;</strong></span> 134 </p> 135 <p> 136 The number of times that a thread of control was able to obtain the 137 mutex region mutex without waiting. 138 </p> 139 </li> 140 </ul> 141 </div> 142 <p> 143 The <code class="methodname">DB_ENV->mutex_stat()</code> method may not be called before the 144 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is called. 145 </p> 146 <p> 147 The <code class="methodname">DB_ENV->mutex_stat()</code> <span> 148 <span> 149 method returns a non-zero error value on failure and 0 on success. 150 </span> 151 152 </span> 153 </p> 154 <div class="sect2" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h3 class="title"><a id="id1695542"></a>Parameters</h3> 159 </div> 160 </div> 161 </div> 162 <div class="sect3" lang="en" xml:lang="en"> 163 <div class="titlepage"> 164 <div> 165 <div> 166 <h4 class="title"><a id="id1695640"></a>flags</h4> 167 </div> 168 </div> 169 </div> 170 <p> 171 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 172 or the following value: 173 </p> 174 <div class="itemizedlist"> 175 <ul type="disc"> 176 <li> 177 <p> 178 <code class="literal">DB_STAT_CLEAR</code> 179 </p> 180 <p> 181 Reset statistics after returning their values. 182 </p> 183 </li> 184 </ul> 185 </div> 186 </div> 187 <div class="sect3" lang="en" xml:lang="en"> 188 <div class="titlepage"> 189 <div> 190 <div> 191 <h4 class="title"><a id="id1695714"></a>statp</h4> 192 </div> 193 </div> 194 </div> 195 <p> 196 The <span class="bold"><strong>statp</strong></span> parameter references memory 197 into which a pointer to the allocated statistics structure is copied. 198 </p> 199 </div> 200 </div> 201 <div class="sect2" lang="en" xml:lang="en"> 202 <div class="titlepage"> 203 <div> 204 <div> 205 <h3 class="title"><a id="id1695853"></a>Errors</h3> 206 </div> 207 </div> 208 </div> 209 <p> 210 The <code class="methodname">DB_ENV->mutex_stat()</code> <span> 211 <span> 212 method may fail and return one of the following non-zero errors: 213 </span> 214 215 </span> 216 </p> 217 <div class="sect3" lang="en" xml:lang="en"> 218 <div class="titlepage"> 219 <div> 220 <div> 221 <h4 class="title"><a id="id1695488"></a>EINVAL</h4> 222 </div> 223 </div> 224 </div> 225 <p> 226 An invalid flag value or parameter was specified. 227 </p> 228 </div> 229 </div> 230 <div class="sect2" lang="en" xml:lang="en"> 231 <div class="titlepage"> 232 <div> 233 <div> 234 <h3 class="title"><a id="id1695737"></a>Class</h3> 235 </div> 236 </div> 237 </div> 238 <p> 239 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 240 </p> 241 </div> 242 <div class="sect2" lang="en" xml:lang="en"> 243 <div class="titlepage"> 244 <div> 245 <div> 246 <h3 class="title"><a id="id1695602"></a>See Also</h3> 247 </div> 248 </div> 249 </div> 250 <p> 251 <a class="xref" href="mutex.html#mutexlist" title="Mutex Methods">Mutex Methods</a> 252 </p> 253 </div> 254 </div> 255 <div class="navfooter"> 256 <hr /> 257 <table width="100%" summary="Navigation footer"> 258 <tr> 259 <td width="40%" align="left"><a accesskey="p" href="mutexset_tas_spins.html">Prev</a>��</td> 260 <td width="20%" align="center"> 261 <a accesskey="u" href="mutex.html">Up</a> 262 </td> 263 <td width="40%" align="right">��<a accesskey="n" href="mutexstat_print.html">Next</a></td> 264 </tr> 265 <tr> 266 <td width="40%" align="left" valign="top">DB_ENV->mutex_set_tas_spins()��</td> 267 <td width="20%" align="center"> 268 <a accesskey="h" href="index.html">Home</a> 269 </td> 270 <td width="40%" align="right" valign="top">��DB_ENV->mutex_stat_print()</td> 271 </tr> 272 </table> 273 </div> 274 </body> 275</html> 276