Accessing Files Programmer's Guide (32650-90885)

153
12 Sharing a File
Accessing and controlling a file that is open only to you is a relatively simple matter. When
your file is being accessed by several users simultaneously, each user must be aware of
special considerations for this shared file. As you read this chapter, keep these
considerations in mind:
How will others be allowed concurrent access to your file?
Will the concurrent access need special management?
NOTE
In most cases, the following discussions pertain only to non-message files. For
more information about using message files; refer to the Interprocess
Communication Programmer's Guide.
Simultaneous Access of Files
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. on
page 154 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. The