TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)

Chapter 4 119
Using the Database
Using the Locking Facility
Figure 4-3. Lock Descriptor List
Conditional and Unconditional Locking
You can request conditional or unconditional locking. If you request unconditional locking,
TurboIMAGE/XL returns control to your calling program only after the specified entity has
been locked. If you request conditional locking, TurboIMAGE/XL returns immediately. In
this case, the condition code must be examined to determine whether or not the requested
locks have been applied. If multiple lock descriptors are specified, the status area indicates
the numbers that have been applied. The calling program should call DBUNLOCK if only a
subset of the requested locks succeeded.
Access Modes and Locking
It is anticipated that access mode 1 will typically be used by applications implementing a
locking scheme. In this mode, TurboIMAGE/XL enforces the following rules:
To modify (DBPUT, DBDELETE, or DBUPDATE) a data entry, you must first issue a
successful lock covering the affected data entry. It can be a data entry, data set, or
database lock.
To add to or delete from (DBPUT or DBDELETE) a manual master data set, you must first
successfully lock the data set or database. To update (DBUPDATE) a master data set,
data entry level locks are sufficient.
If your application opens the database in access mode 2, it is recommended that you use
locking to coordinate updates with other users.
TurboIMAGE/XL does not prevent any process from reading data even though another
process holds a lock on it. If you want to ensure that no modifications are in progress while
you are reading from the database, you should place an appropriate lock on the data before
starting. Therefore, you may want to use locking in access modes 2, 4, 5, and 6 to
coordinate the reading and modifying sequences and ensure that they do not occur
concurrently.
Because access mode 3 and 7 users have exclusive control of the database and access mode
8 users allow concurrent reading only, locking need not be used in these modes.