|
|
KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 4 USING KSAM FILES IN SPL PROGRAMSFLOCK |
|
Dynamically locks a file.
The FLOCK intrinsic dynamically locks a file and transfers the latest control information from disc to the buffers. A call to FLOCK is required before any attempt is made to read or modify a file opened for shared access.
The condition codes possible when lockcond = TRUE are
The condition codes possible if lockcond = FALSE are
Split stack calls permitted. Standard Capability sufficient if only one file is to be locked dynamically. If more than one file is to be locked dynamically, the Multiple RIN Capability is required. The dynamic locking and unlocking capability allows you to complete any update to a file when it is possible for other users to access the file. When dynamic locking is allowed (bit 10 of FOPEN aoptions parameter is set to allow dynamic locking); then you must use the FLOCK intrinsic to lock the file before writing, rewriting, or deleting any records. This requirement insures that another user does not attempt to change the same record at the same time. FLOCK also insures that the most recent data is available in the file. A locked file can be unlocked following the update with the FUNLOCK intrinsic. When FLOCK is executed, it clears all the buffers and transfers the latest control information from the KSAM file to the buffers. This insures that any subsequent read of the file retrieves the latest information from disc rather than from the buffers. (Note that FCONTROL control code 7 also clears the buffers.) If you use the Multiple RIN capability, a sequence of file locking should be agreed upon or you should use conditional locking (lockcond = FALSE). Otherwise, it is possible to lock other users from the file. Consider the situation where one program unconditionally locks file A and then attempts to lock file B. If another program unconditionally locks file B and then attempts to lock file A, both programs will wait indefinitely to lock the second file in sequence. To avoid this, both programs should agree to lock the files in the sequence A first, then B; or both programs should use only conditional locks. For example, suppose you open a KSAM file called DATA1 for shared access in update mode and allow dynamic locking and unlocking:
The parameters specified are:
This file can then be locked as follows:
The parameters specified are:
|
|