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>DbEnv::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 10. Mutex Methods" /> 11 <link rel="prev" href="mutexset_tas_spins.html" title="DbEnv::mutex_set_tas_spins()" /> 12 <link rel="next" href="mutexstat_print.html" title="DbEnv::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">DbEnv::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 10. 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>DbEnv::mutex_stat()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::mutex_stat(DB_MUTEX_STAT **statp, u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DbEnv::mutex_stat()</code> method returns the mutex subsystem 44 statistics. 45 </p> 46 <p> 47 The <code class="methodname">DbEnv::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="DbEnv::set_alloc()">DbEnv::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">DbEnv::mutex_stat()</code> method may not be called before the 144 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is called. 145 </p> 146 <p> 147 The <code class="methodname">DbEnv::mutex_stat()</code> <span> 148 149 <span> 150 method either returns a non-zero error value or throws an 151 exception that encapsulates a non-zero error value on 152 failure, and returns 0 on success. 153 </span> 154 </span> 155 </p> 156 <div class="sect2" lang="en" xml:lang="en"> 157 <div class="titlepage"> 158 <div> 159 <div> 160 <h3 class="title"><a id="id1700000"></a>Parameters</h3> 161 </div> 162 </div> 163 </div> 164 <div class="sect3" lang="en" xml:lang="en"> 165 <div class="titlepage"> 166 <div> 167 <div> 168 <h4 class="title"><a id="id1700081"></a>flags</h4> 169 </div> 170 </div> 171 </div> 172 <p> 173 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 174 or the following value: 175 </p> 176 <div class="itemizedlist"> 177 <ul type="disc"> 178 <li> 179 <p> 180 <code class="literal">DB_STAT_CLEAR</code> 181 </p> 182 <p> 183 Reset statistics after returning their values. 184 </p> 185 </li> 186 </ul> 187 </div> 188 </div> 189 <div class="sect3" lang="en" xml:lang="en"> 190 <div class="titlepage"> 191 <div> 192 <div> 193 <h4 class="title"><a id="id1700176"></a>statp</h4> 194 </div> 195 </div> 196 </div> 197 <p> 198 The <span class="bold"><strong>statp</strong></span> parameter references memory 199 into which a pointer to the allocated statistics structure is copied. 200 </p> 201 </div> 202 </div> 203 <div class="sect2" lang="en" xml:lang="en"> 204 <div class="titlepage"> 205 <div> 206 <div> 207 <h3 class="title"><a id="id1700313"></a>Errors</h3> 208 </div> 209 </div> 210 </div> 211 <p> 212 The <code class="methodname">DbEnv::mutex_stat()</code> <span> 213 214 <span> 215 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 216 exception, encapsulating one of the following non-zero errors, or return one 217 of the following non-zero errors: 218 </span> 219 </span> 220 </p> 221 <div class="sect3" lang="en" xml:lang="en"> 222 <div class="titlepage"> 223 <div> 224 <div> 225 <h4 class="title"><a id="id1700240"></a>EINVAL</h4> 226 </div> 227 </div> 228 </div> 229 <p> 230 An invalid flag value or parameter was specified. 231 </p> 232 </div> 233 </div> 234 <div class="sect2" lang="en" xml:lang="en"> 235 <div class="titlepage"> 236 <div> 237 <div> 238 <h3 class="title"><a id="id1699883"></a>Class</h3> 239 </div> 240 </div> 241 </div> 242 <p> 243 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 244 </p> 245 </div> 246 <div class="sect2" lang="en" xml:lang="en"> 247 <div class="titlepage"> 248 <div> 249 <div> 250 <h3 class="title"><a id="id1699855"></a>See Also</h3> 251 </div> 252 </div> 253 </div> 254 <p> 255 <a class="xref" href="mutex.html#mutexlist" title="Mutex Methods">Mutex Methods</a> 256 </p> 257 </div> 258 </div> 259 <div class="navfooter"> 260 <hr /> 261 <table width="100%" summary="Navigation footer"> 262 <tr> 263 <td width="40%" align="left"><a accesskey="p" href="mutexset_tas_spins.html">Prev</a> </td> 264 <td width="20%" align="center"> 265 <a accesskey="u" href="mutex.html">Up</a> 266 </td> 267 <td width="40%" align="right"> <a accesskey="n" href="mutexstat_print.html">Next</a></td> 268 </tr> 269 <tr> 270 <td width="40%" align="left" valign="top">DbEnv::mutex_set_tas_spins() </td> 271 <td width="20%" align="center"> 272 <a accesskey="h" href="index.html">Home</a> 273 </td> 274 <td width="40%" align="right" valign="top"> DbEnv::mutex_stat_print()</td> 275 </tr> 276 </table> 277 </div> 278 </body> 279</html> 280