A lock which is administered by DLM consists of at least two parts:
The user-independent part that contains the general information and the administrative data for the lock. This exists only once per lock and applies to all users of the lock.
For each user who works with the lock, there is a user-dependent part which contains information which is specific to each user of the lock. A user-dependent DLM lock part is referred to as a lock request in the following.
All user-dependent lock parts, i.e. all lock requests, are linked to the user-independent part in such a way that together they indicate the status of the individual lock request. The possible statuses of a lock request are dependent on the mode in which the request was made.
Lock mode
The DLM provides six different lock modes:
NU
Null mode. A lock request allocated with this mode is compatible with all other
lock requests. However, it may not access the resources.CR
Concurrent-Read mode. The lock holder is granted unprotected read access
to the resource, i.e. other read or write accesses to this resource are permitted
at the same time. Other lock holders are permitted only in NU mode, CR mode,
CW mode, PR mode and PW mode.CW
Concurrent-Write mode. The lock holder is granted unprotected write access
to the resource, i.e. other read or write accesses to this resource are permitted
at the same time. Other lock holders are permitted only in NU mode, CW mode
or CR mode.PR
Protected-Read mode. The lock holder is granted protected read access to the
resource, i.e. no other read or write accesses to this resource are permitted at
the same time. Other lock holders are permitted only in NU mode, CR mode or
PR mode.PW
Protected-Write mode. The lock holder is granted protected write access to the
resource. Other lock holders are permitted only in CR mode and in NU mode.EX
Exclusive mode. The resource may only be accessed by the lock holder. No
other read or write accesses are permitted. Lock holders in NU mode are
compatible with the EX mode, but they may not access the resource.Compatibility of lock modes
Lock protection
Strongest currently
allocated lock modeRequested lock mode
NU
1CR
2CW
3PR
4PW
5EX
6Weak
NU 1
+
+
+
+
+
+
↑
Lock Protection
↓
CR 2
+
+
+
+
+
-
CW 3
+
+
+
-
-
-
PR 4
+
+
-
+
-
-
PW 5
+
+
-
-
-
-
Strong
EX 6
+
-
-
-
-
-
+
requested lock mode is compatible with the allocated lock mode
-
requested lock mode is incompatible with the allocated lock mode
Status of a lock request
A lock request may have one of the following statuses (as seen by the user):
GRANTED
The lock request is allocated for a lock if it is compatible with all
other already allocated locks. New lock requests are only allocated
if they are compatible or if the allocated lock request has been
released.CONVERTING
The lock request has already been allocated in one mode but this
mode now has to be changed. If this conversion leads to
incompatibilities with other allocated lock requests, it must be
postponed until the new lock request can be compatibly allocated.
The lock request to be converted remains in its original lock mode
until it can be converted (or until it times out or is cancelled).WAITING
The lock is waiting for its initial allocation. Allocation is performed
as soon as it is compatible with all the other lock requests that have
already been allocatedLock requests with the status CONVERTING are handled before any other new lock requests with the status WAITING.
If there is a lock request with the status WAITING which is incompatible with the currently allocated lock requests, it blocks all subsequent lock requests for this lock even if these are compatible (apart from locks in NU mode).
For questions of lock mode compatibility, see the table above.
Lock Value Block
The Lock Value Block (LVB) is a small address space which is directly allocated to the lock. It can be read or written depending on the mode in which the lock request is allocated and whether the lock request is receiving (strong lock mode) or releasing (weak lock mode) the lock. The LVB enables users of the lock to exchange information with one another.
The LVB consists of one 16-byte area (lock value) which can be described by the user with any information. The lock value which the user wishes to write or which is supplied to the user during a read request is located in the Lock Status Block.
The LVB exists for as long as any lock request exists for that lock. When the last (or only) lock request for the lock is released, the lock itself is canceled and the LVB discarded.
The Lock Value Block is accessed via the macros LKENQ, LKCVT and LKDEQ.
Accesses to the Lock Value Block
from the allocated
lock modeto the requested lock mode
NU
CR
CW
PR
PW
EX
NU
r
r
r
r
r
r
CR
-
r
r
r
r
r
CW
-
-
r
r
r
r
PR
-
-
-
r
r
r
PW
w
w
w
w
w
r
EX
w
w
w
w
w
w
-
The lock value is neither read nor written.
r (read)
The lock value is read.
The lock value can be read by the user when the lock request is
allocated. If the lock value of a lock is read for the first time, it contains
the initialization value (binary nulls).w (write)
The lock value is written.
The lock value can be written by the user when the lock is converted from
a stronger lock mode (e.g. PW or EX mode) to a weaker or equal lock
mode or while a lock in PW or EX mode is being released.If it was specified in the LKENQ macro that the LVB is to be read, the request is treated as if the lock were to be converted from NU mode to the specified lock mode.
The illustration below indicates the diagrammatic structure of the resulting lock.
Figure 22: Schematic diagram of a lock