Dynamically locks KSAM file during shared access.
Operation Notes |
 |
In order to call BKLOCK, the file must be opened with dynamic locking
allowed. That is, the parameter lock in the BKOPEN procedure must be set to 1. Also, since dynamic
locking is useful only when access is shared, probably the file
will have been opened with the exclusive parameter in BKOPEN set to 3.
Users who share the same file should cooperate on how they
will share the file. Unless they all agree to allow locking, no
one will be able to lock the file. Also, it is important to avoid situations
where one user locks the file and forgets to unlock it. If this
occurs when condition is set to a non-zero value, the calling process is
not halted. But if the file is locked already and you attempt to
lock a file with condition omitted or set to zero, your process is halted until
the other user either unlocks the file or logs off.
You should always check the status parameter immediately following a call to BKLOCK in order to determine if the call was completed
successfully. If you locked with condition set to a nonzero value, you should check if the file
was locked before continuing. If it was locked, status will have
a 0 in the first character, but if another user had locked the file preventing
your call to BKLOCK from working, then status contains the value 71.
Figure B-3 “Dynamically Locking a KSAM File with
BKLOCK” contains an example of locking a
file with BKLOCK.