Open System Services System Calls Reference Manual (G06.28+)

SPT_LOCKREC(2) OSS System Calls Reference Manual
Considerations
Record locking versus file locking
A call to SPT_LOCKFILE() is not equivalent to locking all records in a le;
that is, locking all records still allows insertion of new records, but le locking
does not. File locks and record locks are queued in the order they are issued.
Nowait and SPT_LOCKREC( )
If the SPT_LOCKREC() function is used to initiate an operation with a le
opened nowait, it must complete with a corresponding call to the Guardian
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 le-system error 73 (record is locked). The
alternate locking mode is specied 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 lenum if the le is not audited, or
another TRANSID if the le is audited.)
For nonaudited les, a deadlock condition (a permanent suspension of your
application) occurs if SPT_READX() or SPT_READUPDATEX() is called by
the process which has a record locked with a le number other than that supplied
in the SPT_READX() or SPT_READUPDATEX() call. (See the
SPT_FILE_OPEN_(2) reference page either online or in the Open System Ser-
vices System Calls Reference Manual for an explanation of multiple opens by
the same process.)
Selecting the locking mode with SPT_SETMODE()
The locking mode is specied by the SETMODE procedure with function of 4.
A count of the locks in effect is not maintained. Multiple locks can be unlocked
with one call to SPT_UNLOCKFILE().
Structured files
Calling LOCKREC after positioning on a nonunique key
If the call to SPT_LOCKREC( ) immediately follows a call to
KEYPOSITION where a nonunique alternate key is specied,
the call to SPT_LOCKREC() fails. A subsequent call to the
Guardian FILE_GETINFO_ or FILEINFO procedure shows that
7204 Hewlett-Packard Company 527186-005