When an HPFOPEN/FOPEN request is issued for a file, that request is
regarded as an individual accessor of the file and a unique file number and
other file control information is established for that file. Even when the same
program issues several different HPFOPEN/FOPEN calls for the same
file, each call is treated
as a separate accessor. Under the normal (default) security provisions
of MPE/iX, when an accessor opens a file not presently in use, the
access restrictions that apply to this file for other accessors
depend upon the access mode requested by this initial accessor:
If the first accessor opens the file for Read-only access, any
other accessor can open it for any other type of access (such as
Write-only or Append), except that other accessors are prohibited
Exclusive access.
If the first accessor opens the file for any other access mode
(such as Write-only, Append, or Update), this accessor maintains
Exclusive access to the file until it closes the file; no other
accessor can access the file in any mode.
Programs can override these defaults by specifying other options in
HPFOPEN/FOPEN intrinsic calls. Users running those programs can, in
turn, override both the defaults and programmatic options through the
FILE command. The options are listed in
Table 12-1 "File Sharing Restriction
Options" The actions taken by MPE/iX when these options are in effect, and
simultaneous access is attempted by other HPFOPEN/FOPEN calls, are
summarized in Figure 12-1 "Requested Access
Granted, Unless Noted" The action taken depends upon the current use of the
file versus the access requested.
Table 12-1 File Sharing Restriction Options
ACCESS RESTRICTION
FILE\ PARAMETER
DESCRIPTION
Exclusive Access
EXC
After file is opened, prohibits concurrent access in any mode through
another HPFOPEN/FOPEN request, whether issued by this or another
program, until this program issues FCLOSE or terminates.
Exclusive Write Access
SEMI
After file is opened, prohibits concurrent Write access through another
HPFOPEN/FOPEN request, whether issued by this or another program,
until this program issues FCLOSE or terminates.
Shareable Access
SHR
After file is opened, permits concurrent access to file in any mode
through another HPFOPEN/FOPEN request issued by this or another
program, in this or any session or job.
This option is useful when you wish to update a file and wish
to prevent other users or programs from reading or writing on the
file while you are using it; thus, no user can read information
that is about to be changed, nor can he alter that information.
To override the programmatic option under which the file would be
opened and request exclusive access, you could use the EXC keyword
parameter in the FILE command:
FILE DATALIST;EXC <---- Requests exclusive access
RUN FLUPDATE
NOTE: In all cases, when the first accessor to a file opens
it with Exclusive (EXC) access, all other attempts to open the file fails.
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
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.
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
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.
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.