Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) SPT_LOCKREC(2)
Considerations
Record locking versus file locking
A call to SPT_LOCKFILE() is not equivalent to locking all records in a file;
that is, locking all records still allows insertion of new records, but file locking
does not. File locks and record locks are queued in the order in which they are
issued.
Nowait and SPT_LOCKREC()
If the SPT_LOCKREC() function is used to initiate an operation with a file
opened for nowait I/O, it must complete with a corresponding call to the Guar-
dian AWAITIO procedure.
Default locking mode
If the record is already locked by another user when SPT_LOCKREC() is
called, the process requesting the lock is suspended and queued in a locking
queue behind other users also requesting to lock or read the record.
When the record becomes unlocked, the user at the head of the locking queue is
granted access to the record. If the user at the head of the locking queue is
requesting a lock, it is granted the lock and resumes execution. If the user at the
head of the locking queue is requesting a read operation, the read operation con-
tinues to completion.
Alternate locking mode
If the record is already locked by another user when SPT_LOCKREC() is
called, the lock request is rejected, and the call to SPT_LOCKREC() completes
immediately with Guardian file-system error 73 (record is locked). The
alternate locking mode is specified by calling the SPT_SETMODE() procedure
and specifying function 4.
Attempting to read a locked record in default locking mode
If the default locking mode is in effect when SPT_READX() or
SPT_READUPDATEX( ) is called for a record that is locked by another user,
the caller to SPT_READX( ) or SPT_READUPDATEX() is suspended and
queued in the locking queue behind other users attempting to lock or read the
record. (Another user means another open filenum if the file is not audited, or
another TRANSID if the file is audited.)
For nonaudited files, a deadlock condition (a permanent suspension of your
application) occurs if SPT_READX() or SPT_READUPDATEX() is called by
the process that has a record locked with a file number other than that supplied in
the SPT_READX() or SPT_READUPDATEX() call. For an explanation of
multiple opens by the same process, see the SPT_FILE_OPEN_(2) reference
page either online or in the Open System Services System Calls Reference
Manual.
Selecting the locking mode with SPT_SETMODE()
The locking mode is specified by the calling SETMODE procedure with function
4.
A count of the locks in effect is not maintained. Multiple locks can be unlocked
with one call to SPT_UNLOCKFILE().
527186-023 Hewlett-Packard Company 7287