Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (L)
Guardian Procedure Calls Reference Manual522629-013
8-22
LOCKREC Procedure
If the LOCKREC procedure is used to initiate an operation with a file opened
nowait, it must complete with a corresponding call to the AWAITIO procedure.
Default locking mode
If the record is already locked by another user when 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
continues to completion.
Alternate locking mode
If the record is already locked by another user when LOCKREC is called, the lock
request is rejected, and the call to LOCKREC completes immediately with file-
system error 73 (“record is locked”). The alternate locking mode is specified by
calling the 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 READ or READUPDATE is called for a
record that is locked by another user, the caller to READ or READUPDATE 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.)
Selecting the locking mode with SETMODE
The locking mode is specified by the SETMODE procedure with
function =4.
A count of the locks in effect is not maintained. Multiple locks can be unlocked with
one call to UNLOCKFILE. For example:
CALL LOCKREC ( file^a,... ); ! locks the current record
! in "file^a."
...
CALL LOCKREC ( file^a,... ); ! has no effect since the
! current record is already
! locked.
...
CALL UNLOCKREC (file^a,...); ! unlocks the current record
! in "file^a."
...
CALL UNLOCKREC (file^a,...); ! has no effect since the
Note. For non-audited files, a deadlock condition—a permanent suspension of your
application—occurs if READ or READUPDATE is called by the process which has a record
locked by a filenum other than that supplied to READ or READUPDATE. (Refer to the
FILE_OPEN_ or OPEN procedure for an explanation of multiple opens by the same process.)