If only one process is accessing a file, setting a pointer
and reading a record in a two-step process does not present a problem.
Shared file access, however, presents potential retrieval contention.
If a pointer is positioned to retrieve a particular record by one process,
another process could modify or delete the record before the original
process reads it. The FLOCK and FUNLOCK intrinsics should
be used to ensure proper record
retrieval in any program that allows shared access to its file.
NOTE: File locking keeps the file inaccessible to other users
until the file is unlocked. This could be a potential source of
performance problems. A different file structure may be more suitable
for applications in a shared environment, such as IMAGE/3000, etc.
An FLOCK intrinsic call should be made prior to a pointer positioning
and record reading procedure to ensure that the proper retrieval is executed.
The FUNLOCK intrinsic restores shared access once the retrieval
is completed. Once the file is unlocked, do not assume that the
pointer is still valid. Before using the pointer again, reposition
it. The following sequence shows the appropriate locking procedure
to ensure the proper sequence of records.
FLOCK
FFINDBYKEY (sets the logical pointer)
FREAD loop (reads records in key sequence)
FUNLOCK