| United States-English |
|
|
|
![]() |
Using KSAM XL: 900 Series HP 3000 Computer Systems > Appendix B BASIC/V IntrinsicsBKLOCK |
|
Dynamically locks KSAM file during shared access.
When more than one user accesses the same file, BKLOCK can be used to make access to the file exclusive for one user while he writes to or updates the file. In order to use BKLOCK, the file must be opened with dynamic locking allowed by all users who are sharing the file. When finished with the changes that required exclusive access, the user who has locked the file with BKLOCK should unlock it with BKUNLOCK.
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. Figure B-3 Dynamically Locking a KSAM File with BKLOCK
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||