Skip to main content
Print

00043: An introduction to advisory locking

Title:

An introduction to advisory locking

Description:

Advisory locking is for those applications that use correct locking techniques to maintain databases. It is not sufficient to simply enable advisory locking and hope that the application correctly locks data files; it is necessary to test the application’s suitability when enabling advisory locking.

Advisory locking expects that any data read for modification is locked from another user’s access using the EXTRACT verb. In a non-advisory locking environment, the EXTRACT verb locks the read data from any other operation that would access the data. In the advisory locking environment, the data is locked from further locking in the assumption that the data would be locked before any modification.

In a non-advisory locking environment, an EXTRACT blocks the following operations: EXTRACT, READ, WRITE, and REMOVE. In an advisory locking environment, the EXTRACT blocks only EXTRACT and REMOVE; the WRITE may be blocked in some environments.

At a minimum, advisory locking allows you to enhance your application by allowing simple inquiries to data to “ignore” the locks placed on the data as long as the data isn’t being modified. This capability is used by BBx by setting the $000040$ bit in the OPTS vector. If this bit won’t stay set, then BBx cannot support advisory locking.

Advisory Locking at the System Level

In addition to allowing an application to read locked data, you may tell BBx that the locks on your system are truly advisory–this means that anyone may read locked data, as the operating system doesn’t compare reads against locks, but only compares the locks against one another. As this is a “feature” of operating systems, BBx doesn’t expect this capability but is willing to use it if told to do so. To tell BBx that the host operating system uses advisory locking, set the OPTS bit $000010$.

Multi-Processor and Multi-Threaded Environments

Modern BASIS products provide advanced support for multi-processor systems. While PRO/5 remains a single-threaded application, BBj is a fully multi-threaded application designed to take advantage of multiple processors and CPU cores. This architecture allows for a finer level of control over task allocation and improved scalability in high-concurrency environments.

Key Area Read Locking (PRO/5 Filesystem ONLY)

If your system supports multiple owners of a lock (using a non-exclusive or read-permitting form), you may inform BBx to use it in reading the key area of a file using the OPTS bit $000020$. This will permit more than one BBx process to read the key area of a file at a time. The offset of this advantage is that allowing multiple readers into the key area may end up preventing a single writer’s access to the key area. This can occur in times of high system load or, in some installations, enough of the time to cause objectionable performance for those tasks attempting to write or to remove keys from the file. 

Table of Contents
Scroll to Top