Accessing Files Programmer's Guide (32650-90885)

Chapter 12 155
Sharing a File
Simultaneous Access of Files
Figure 12-1. Requested Access Granted, Unless Noted
Semi-exclusive access
This option allows other accessors to read the file, but prevents them from altering it.
When appending new part numbers to a file containing a parts list, for instance, you might
use this option to allow other users to read the current part numbers at the same time that
you are adding new ones to the end of the file. You could request this option as follows:
FILE PARTSLST;SEMI <---- Requests semi-exclusive access
RUN FLAPPEND
Shared access
When opened with the share option, a file can be shared (in all access modes) among
several HPFOPEN/FOPEN requests, whether they are issued from the same program,
different programs within the same job or session, or programs running under different
jobs or sessions. Each accessor transfers its input/output to and from the file with its own
unique buffer, using its own set of file control information and specifying its own buffer
size and blocking factor. Effectively, each accessor accesses its own copy of that portion of
the file presently in its buffer. Thus, share access is useful for allowing several users to
read different parts of the same file. It can, however, present problems when several users
try to write to the file. For instance, if two users are updating a file concurrently, one could
easily overwrite the other's changes when the buffer content from the first user's output is
overwritten on the file by the buffer content from the second user's output.