Accessing Files Programmer's Guide (32650-90885)

156 Chapter12
Sharing a File
Simultaneous Access of Files
To use Write access most effectively with shared files, specify the multiaccess option as
discussed below.
To request share access for a file, use the SHR parameter in the FILE command, as follows:
FILE RDFILE;SHR <---- Requests shared access
RUN RDPROG
Multiaccess
This option extends the features of the share access option to allow a deeper level of
multiple access. Multiaccess not only makes the file available simultaneously to other
accessors (in the same job or session), but permits them to use the same data pointers,
blocking factor, and other file-control information. Thus, transfers to and from the file
occur in the order they are requested, regardless of which program in your job or session
does the requesting. When several concurrently running programs (processes) are writing
to the file, the effect on the file is the same as if one program were performing all output;
truly sequential access by several concurrently running programs.
NOTE
Multiaccess allows the file to be shared (in all access modes) among several
HPFOPEN/FOPEN requests from the same program, or from different
concurrently running programs in the same job or session. Unlike share,
access, however, multiaccess does not permit the file to be shared among
different sessions and jobs.
Global multiaccess
This option extends the features of the multiaccess option to permit simultaneous access of
a file by processes in different jobs or sessions. As in multiaccess, accessors use the same
data pointer, blocking factor, and other file-control information. You can request this option
as follows:
FILE GFILE;GMULTI <---- Requests global multi access
RUN GPROG
NOTE
To prohibit the use of MULTI or GMULTI access, use the NOMULTI keyword in
a FILE command. When the NOMULTI keyword is used, different processes
may share the data in a file, but they maintain separate buffers and pointers.
Note that it is the first accessor to a file that sets the allowable access to a file. For
example, if the first accessor specifies share access, that is, the access that will be allowed
to all future accessors. However, if a subsequent accessor specifies an access option that is
more restrictive than the first opener's access option, it remains in effect until the user
that requested it closes the file.