Using KSAM/XL and KSAM 64 (32650-90886)

Chapter 9 119
KSAM Intrinsics
FLOCK
FLOCK
Dynamically locks a file. A call to FLOCK is required before any attempt is made to read or
modify a file with shared access.
NOTE
The file system does not guarantee exclusive access, even when FLOCK and
FUNLOCK are used, unless all programs that access the file cooperate by using
locking. A program that opens the file with dynamic locking enabled will still
be allowed to modify the file, even if it never calls FLOCK.
Syntax
I16V U16V
FLOCK(
filenum,lockflag
);
Parameters
filenum
16-bit signed integer by value (required)
Passes the file number of the file whose global resource identification
number (RIN) is to be locked.
lockflag
16-bit unsigned integer by value (required)
Specify either conditional or unconditional locking by setting bit (15:1) as
follows:
Value Meaning
0 Locking takes place only if the file's global RIN is not
currently locked. If the RIN is locked, control returns
immediately to the calling process, with condition code
CCG.
1 Locking takes place unconditionally. If the file cannot be
locked immediately, the calling process suspends until the
file can be locked.
Condition Codes
The following condition codes are possible when
lockflag
bit (15:1)=1:
CCE Request granted.
CCG Not returned.
CCL Request denied. This file was not opened with the dynamic locking
aoption
bit (10:1) specified in the FOPEN/HPFOPEN intrinsic.
Refer to this intrinsic in the MPE/iX Intrinsics Reference Manual for other codes
pertaining to KSAM files.