• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/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>Locking and non-Berkeley DB applications</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_am_conv.html" title="Berkeley DB Transactional Data Store locking conventions" />
12    <link rel="next" href="log.html" title="Chapter��16.�� The Logging Subsystem" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Locking and non-Berkeley DB applications</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="lock_am_conv.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="log.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_nondb"></a>Locking and non-Berkeley DB applications</h2>
35          </div>
36        </div>
37      </div>
38      <p>The Lock subsystem is useful outside the context of Berkeley DB.  It can be
39used to manage concurrent access to any collection of either ephemeral
40or persistent objects.  That is, the lock region can persist across
41invocations of an application, so it can be used to provide long-term
42locking (for example, conference room scheduling).</p>
43      <p>In order to use the locking subsystem in such a general way, the
44applications must adhere to a convention for identifying objects and
45lockers.  Consider a conference room scheduling problem, in which there
46are three conference rooms scheduled in half-hour intervals. The
47scheduling application must then select a way to identify each
48conference room/time slot combination.  In this case, we could describe
49the objects being locked as bytestrings consisting of the conference
50room name, the date when it is needed, and the beginning of the
51appropriate half-hour slot.</p>
52      <p>Lockers are 32-bit numbers, so we might choose to use the User ID of
53the individual running the scheduling program.  To schedule half-hour
54slots, all the application needs to do is issue a <a href="../api_reference/C/lockget.html" class="olink">DB_ENV-&gt;lock_get()</a> call
55for the appropriate locker/object pair.  To schedule a longer slot, the
56application needs to issue a <a href="../api_reference/C/lockvec.html" class="olink">DB_ENV-&gt;lock_vec()</a> call, with one
57<a href="../api_reference/C/lockget.html" class="olink">DB_ENV-&gt;lock_get()</a> operation per half-hour ��� up to the total length.  If
58the <a href="../api_reference/C/lockvec.html" class="olink">DB_ENV-&gt;lock_vec()</a> call fails, the application would have to release
59the parts of the time slot that were obtained.</p>
60      <p>To cancel a reservation, the application would make the appropriate
61<a href="../api_reference/C/lockput.html" class="olink">DB_ENV-&gt;lock_put()</a> calls.  To reschedule a reservation, the
62<a href="../api_reference/C/lockget.html" class="olink">DB_ENV-&gt;lock_get()</a> and <a href="../api_reference/C/lockput.html" class="olink">DB_ENV-&gt;lock_put()</a> calls could all be made inside of
63a single <a href="../api_reference/C/lockvec.html" class="olink">DB_ENV-&gt;lock_vec()</a> call. The output of <a href="../api_reference/C/lockstat.html" class="olink">DB_ENV-&gt;lock_stat()</a> could
64be post-processed into a human-readable schedule of conference room
65use.</p>
66    </div>
67    <div class="navfooter">
68      <hr />
69      <table width="100%" summary="Navigation footer">
70        <tr>
71          <td width="40%" align="left"><a accesskey="p" href="lock_am_conv.html">Prev</a>��</td>
72          <td width="20%" align="center">
73            <a accesskey="u" href="lock.html">Up</a>
74          </td>
75          <td width="40%" align="right">��<a accesskey="n" href="log.html">Next</a></td>
76        </tr>
77        <tr>
78          <td width="40%" align="left" valign="top">Berkeley DB Transactional Data Store locking conventions��</td>
79          <td width="20%" align="center">
80            <a accesskey="h" href="index.html">Home</a>
81          </td>
82          <td width="40%" align="right" valign="top">��Chapter��16.��
83		The Logging Subsystem
84        </td>
85        </tr>
86      </table>
87    </div>
88  </body>
89</html>
90