Guardian Procedure Calls Reference Manual

Parameters
filenum
input
INT:value
is the number of an open file that identifies the file to be locked.
tag
input
INT(32):value
is for nowait I/O only. tag is a value you define that uniquely identifies the operation associated
with this LOCKFILE.
NOTE: The system stores the tag value until the I/O operation completes. The system then
returns the tag information to the program in the tag parameter of the call to AWAITIO, thus
indicating that the operation completed.
Condition Code Settings
indicates that an error occurred (call FILE_GETINFO_ or FILEINFO).< (CCL)
indicates that the LOCKFILE was successful.= (CCE)
indicates that the file is not a disk file.> (CCG)
Considerations
Nowait and LOCKFILE
If the LOCKFILE procedure is used to initiate an operation with a file opened nowait, it must
complete with a corresponding call to the AWAITIO procedure.
Locking modes
Default mode
If the file is already locked by another user when LOCKFILE is called, the process requesting
the lock is suspended and queued in a "locking" queue behind other users trying to access
the file. When the file becomes unlocked, the user at the head of the locking queue is
granted access to the file. 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, the read operation continues to completion.
Alternate mode
If the file is already locked by another user when the call to LOCKFILE is made, the lock
request is rejected, and the call to LOCKFILE completes immediately with error 73 (file is
locked). The alternate locking mode is specified by calling the SETMODE procedure and
specifying function 4.
Locks and open files—applies to non-audited files only
Locks are granted on an open file (that is, file number) basis. Therefore, if a process has
multiple opens of the same file, a lock of one file number excludes access to the file through
other file numbers.
Attempting to read a locked file in default locking mode
If the default locking mode is in effect when a call to READ or READUPDATE is made to a file
which is locked by another user, the caller of READ or READUPDATE is suspended and queued
in the "locking" queue behind other users attempting to access the file.
LOCKFILE Procedure 769