Enscribe Programmer's Guide

For example, assume that there exists an empty key-sequenced file with a defined key length of
four and that generic locking is enabled with a generic lock key length of two. If process #1 inserts
a record with the key AAaa, it thereby owns a generic lock for the byte-string AA. If process #2
at that time attempts to insert a record with the key AAcc, the attempt is rejected with a CCL and
an error code 73.
Interaction Between File Locks and Record Locks
This discussion applies only if the default locking mode is in effect.
File locks take precedence over record locks. If you lock a file and then attempt to lock individual
records within that file, the record lock requests are ignored and have no effect.
For each file having one or more pending file lock requests, the requests are queued. In addition,
read calls that attempt to access a locked file are queued with the pending file lock requests. When
the current lock is released, the system grants whatever request is currently at the head of the file
lock queue. If the request is a file lock request, the lock is granted; if the request is a read request,
the read operation is performed.
Similarly, for a record having one or more pending record lock requests, the requests are queued.
In addition, read calls that attempt to access a locked record are queued with the pending record
lock requests. When the current lock is released, the system grants whatever request is currently
at the head of the queue for that record. If the request is a record lock request or a
READUPDATELOCK/FILE_READUPDATELOCK64_ request, the lock is granted; if the request is a
read request, the read operation is performed.
Lock requests do not wait behind other locks held by the same file number or transid. If a file
number or transid holds record locks and later requests a file lock (and no other file number or
transid has any locks pending against that file or any of its records), the record locks are relinquished
and replaced by the file lock.
Lock Limits
The disk process enforces lock limits that are specified through SYSGEN. For nonaudited files, the
default limit is 5000 locks per volume for each file number; for audited files, the default limit is
5000 locks of all kinds per volume for each transid. For partitioned files, these criteria translate
into a default of 5000 locks per partition.
The limits do not imply that you can always get the maximum number of locks. For example, there
might not be enough physical memory space or internal buffer space available to get another lock.
If the limit has been reached and you ask for an additional lock, the lock request is rejected with
an error 35 (unable to obtain I/O process control block). The disk process returns different error
codes for two other specific causes: error 37 (I/O process is unable to lock physical memory)
when there is not enough physical memory available and error 33 (I/O process unable to obtain
I/O segment space) when a buffer is full or too fragmented.
When a process reads a file that was opened with sequential block buffering, the disk process
ignores record locks (although it does honor file locks). The FUP COPY command, for example,
uses sequential block buffering and can therefore read locked records.
Deadlock
One problem that can occur when multiple processes require multiple record locks or file locks is
a deadlock condition. An example of deadlock is:
Process BProcess A
LOCKREC: record 2LOCKREC: record 1
..
154 File and Record Locking