• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/docs/programmer_reference/
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>Standard lock modes</title>
7    <link rel="stylesheet" href="gettingStarted.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 Programmer's Reference Guide" />
10    <link rel="up" href="lock.html" title="Chapter 15.  The Locking Subsystem" />
11    <link rel="prev" href="lock_max.html" title="Configuring locking: sizing the system" />
12    <link rel="next" href="lock_dead.html" title="Deadlock detection" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Standard lock modes</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="lock_max.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 15. 
23		The Locking Subsystem
24        </th>
25          <td width="20%" align="right"> <a accesskey="n" href="lock_dead.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="lock_stdmode"></a>Standard lock modes</h2>
35          </div>
36        </div>
37      </div>
38      <p>The Berkeley DB locking protocol is described by a conflict matrix.  A
39conflict matrix is an NxN array in which N is the number of different
40lock modes supported, and the (i, j)th entry of the array indicates
41whether a lock of mode i conflicts with a lock of mode j.  In addition,
42Berkeley DB defines the type <span class="bold"><strong>db_lockmode_t</strong></span>, which is the type of a
43lock mode within a conflict matrix.</p>
44      <p>The following is an example of a conflict matrix.  The actual conflict
45matrix used by Berkeley DB to support the underlying access methods is more
46complicated, but this matrix shows the lock mode relationships available
47to applications using the Berkeley DB Locking subsystem interfaces directly.</p>
48      <div class="variablelist">
49        <dl>
50          <dt>
51            <span class="term">DB_LOCK_NG</span>
52          </dt>
53          <dd>not granted (always 0)</dd>
54          <dt>
55            <span class="term">DB_LOCK_READ</span>
56          </dt>
57          <dd>read (shared)</dd>
58          <dt>
59            <span class="term">DB_LOCK_WRITE</span>
60          </dt>
61          <dd>write (exclusive)</dd>
62          <dt>
63            <span class="term">DB_LOCK_IWRITE</span>
64          </dt>
65          <dd>intention to write (shared)</dd>
66          <dt>
67            <span class="term">DB_LOCK_IREAD</span>
68          </dt>
69          <dd>intention to read (shared)</dd>
70          <dt>
71            <span class="term">DB_LOCK_IWR</span>
72          </dt>
73          <dd>intention to read and write (shared)</dd>
74        </dl>
75      </div>
76      <p>In a conflict matrix, the rows indicate the lock that is held, and the
77columns indicate the lock that is requested.  A 1 represents a conflict
78(that is, do not grant the lock if the indicated lock is held), and a
790 indicates that it is OK to grant the lock.</p>
80      <pre class="programlisting">		Notheld	Read    Write	IWrite	IRead	IRW
81Notheld		0	0	0	0	0	0
82Read*		0	0	1	1	0	1
83Write**		0	1	1	1	1	1
84Intent Write	0	1	1	0	0	0
85Intent Read	0	0	1	0	0	0
86Intent RW	0	1	1	0	0	0</pre>
87      <div class="variablelist">
88        <dl>
89          <dt>
90            <span class="term">*</span>
91          </dt>
92          <dd>In this case, suppose that there is a read lock held on an object.  A new
93request for a read lock would be granted, but a request for a write lock
94would not.</dd>
95          <dt>
96            <span class="term">**</span>
97          </dt>
98          <dd>In this case, suppose that there is a write lock held on an object.  A
99new request for either a read or write lock would be denied.</dd>
100        </dl>
101      </div>
102    </div>
103    <div class="navfooter">
104      <hr />
105      <table width="100%" summary="Navigation footer">
106        <tr>
107          <td width="40%" align="left"><a accesskey="p" href="lock_max.html">Prev</a> </td>
108          <td width="20%" align="center">
109            <a accesskey="u" href="lock.html">Up</a>
110          </td>
111          <td width="40%" align="right"> <a accesskey="n" href="lock_dead.html">Next</a></td>
112        </tr>
113        <tr>
114          <td width="40%" align="left" valign="top">Configuring locking: sizing the system </td>
115          <td width="20%" align="center">
116            <a accesskey="h" href="index.html">Home</a>
117          </td>
118          <td width="40%" align="right" valign="top"> Deadlock detection</td>
119        </tr>
120      </table>
121    </div>
122  </body>
123</html>
124