A Note On Syntax [ Interprocess Communication:Programmer's Guide ] MPE/iX 5.0 Documentation
Interprocess Communication:Programmer's Guide
A Note On Syntax
In some of the following intrinsics, a parameter contains more than one
piece of information within a word. When this is the case, data fields
are described in the format (n:m), where n is the first bit of the field
and m is the number of consecutive bits in the field. For example, the
FOPTION field for File Type occupies bits (2:3), or bits 2, 3 and 4.
Parameters not discussed in the following descriptions retain their
normal value range and defaults. For more information about
these intrinsics, refer to the MPE XL Intrinsics Reference Manual
(32650-90028).
HPFOPEN
NOTE The following discussion also applies to the FOPEN intrinsic, which
is the equivalent within MPE V/E of HPFOPEN. The FOPEN parameter
name follows the HPFOPEN parameter name. For more information on
FOPEN, refer to the MPE XL Intrinsics Reference Manual
(32650-90028).
Item #6, record Message files are always formatted internally as
format option; variable-length record files (option=1). If
FOPTION (8:2) fixed-length records are requested (option=0), the file
can appear fixed when it is opened. There is no
difference for a writer; for a reader, the portion of
the target area that exceeds the record is filled with
blanks (for an ASCII file) or zeros (for a binary file).
Files accessed in copy mode are always formatted as
variable. (See item #17 for more information on copy
mode.)
Item #11, The type of access allowed for this file is specified by
access type the following values:
option; AOPTION
(12:4) 0 - READ-only access. A process that has opened a file
with this access type is a "reader." (FWRITE calls will
not be allowed.)
1 - WRITE-only access. If this is the only current open
of the file, any data written in the file prior to the
current HPFOPEN request is deleted. If this is not the
only current open of the file, the file is treated as if
Access Type 3 has been specified. A process that has
opened a file with this access type is a "writer."
(FREAD calls will not be allowed.)
2 - WRITE-SAVE access. The file system sets this to
APPEND access for message files.
3 - APPEND-only access. The FREAD intrinsic cannot
reference this file. Calls to FWRITE will add data to
the end of the file. A process that has opened a file
with this access type is a "writer."
For a file accessed in copy mode, any access type other
than READ-only access (option = 0) is changed to
WRITE-only access (option = 1) by the file system.
Item #13, The values for this option are the same as for any other
exclusive file. However, the significance of each value is
option; AOPTION different:
(8:2)
User | Value | Meaning
EXCLUSIVE | 1 | One reader, one writer
SEMI | 2 | One reader, multiple
| | writers
SHARE | 3 | Multiple readers and
| | writers
Default | 0 | Same as 1
In copy mode, the value is always 1.
Item #14, This feature permits processes located in different jobs
multiaccess or sessions to open the same file.
mode; AOPTION
(5:2) 0 - No multiaccess. The file system changes this value
to 2 to allow global multiaccess.
1 - Only intrajob multiaccess allowed; this is the same
as specifying the MULTI option in a :FILE command.
2 - Interjob multiaccess allowed; this is the same as
specifying the GMULTI option in a :FILE command.
In copy mode, the value is always 0 (no multiaccess).
Item #15, For message files, the file system sets this bit to 0,
multirecord except in copy mode. This option is available only if
option; AOPTION you also select the inhibit buffering option, Item #46.
(11:1)
Item #17, copy This feature permits a message file to be treated as a
mode option; standard sequential file, so that it can be copied by
AOPTION (3:1) logical record or physical block to another file.
0 - The file is accessed in its own mode; that is, a
message (MSG) file is treated as a message file.
1 - The file is to be treated as a standard (STD),
sequential file with variable-length records. For
message files, this allows nondestructive reading of an
old message file at either the logical record or the
physical block level. Only block level access is
permitted if the file is being written in message-file
format. This prevents incorrectly formatted data from
being written to the message file while that file is
unprotected. In order to access a message file in copy
mode, a process must have EXCLUSIVE access to the file.
Item #22, These fields are relevant only if this is a new file.
volume class If you specify volume class field, you must specify a
option, Item disc; specification of any device other than a disc
#23, volume opens the device, and the file is no longer a message
name option; file.
DEVICE field
Item #35, For message files, the number of records is rounded up
filesize to completely fill the last block and to make the last
option; extent the same size as the other extents. Two
FILESIZE field additional records are included for the open and close
records. Because of spare tracks or remapped tracks,
the logical size is usually smaller than the physical
size.
Item #44, The number of buffers you wish to allocate to the file.
numbuffers Value must be between 2 and 31; default is 2.
option;
NUMBUFFERS
IPC needs at least two buffers; if fewer than two are
specified, the field is changed to two. Also, IPC never
uses more buffers than there are blocks in the file. If
more are specified, the lower number is used (except in
copy mode).
Item #46, For message files, the file system sets this value to 0.
inhibit
buffering Readers may open a message file with NOBUF if they are
option; AOPTION in copy mode. This option determines whether the reader
(7:1) will be accessing the file record by record or block by
block:
0 - read by logical record
1 - read by physical block
Writers must open message files with NOBUF if they are
in copy mode; they access the file block by block.
FCONTROL
A few control codes deal specifically with message files. Those not
mentioned here are invalid when message files are being used.
Code | Param | Description
2 | | Complete all I/O; ignored in the
| | case of message files.
4 | Integer | Set timeout interval. Indicates
| | that a timeout interval is to be
| | applied to a file. In the case of
| | message files, param specifies the
| | length of time (in seconds) that a
| | process waits when reading from an
| | empty file or writing to a full
| | one. The timeout remains enabled
| | until it is explicitly cancelled.
| | (Refer to Chapter 4.)
6 | | Write End-Of-File. For message
| | files, this is used to verify the
| | state of the file by writing the
| | file label and buffer area to disc.
| | This ensures that the message file
| | can survive system crashes. No EOF
| | is written. (Refer to Chapter 4.)
43 | | Abort NOWAIT I/O. For message
| | files, CCG is returned when an
| | outstanding I/O operation has
| | completed. You must issue an
| | IOWAIT call to finish the request.
| | (Refer to Chapter 5.)
45 | 1 or 0 | Enable/disable extended wait. For
| | message files, a param value of 1
| | enables extended wait. This
| | permits a reader to wait on an
| | empty file that is not currently
| | opened by any writer, or a writer
| | to wait on a full file that has no
| | reader. This parameter remains in
| | effect until you issue an FCONTROL
| | call with a controlcode of 45 and a
| | param value of 0.
46 | 1 or 0 | Enable/disable reading the writer's
| | ID. For message files, a param
| | value of 1 enables reading the
| | writer's ID. Each record read has a
| | one-word header. The first 16 bits
| | indicate the type of record with
| | the following codes:
| |
| |
| | 0 - data record
| |
| | 1 - open record
| |
| | 2 - close record
| |
| | The second 16 bits contain the
| | writer's ID number. If the record
| | is a data record, the data follows
| | the header. Open and close records
| | contain no more information.
| |
| | If the param value is 0, reading
| | the writer's ID is disabled. Only
| | data is read to the reader's target
| | area. The open and close records
| | are skipped and deleted by the file
| | system when they come to the head
| | of the message queue, and the
| | one-word header is transparent to
| | the reader. (Refer to Chapter 4.)
47 | 1 or 0 | Nondestructive read. If the param
| | value is 1, the next FREAD by this
| | reader will not delete the record.
| | Subsequent FREAD calls are
| | unaffected. If the param value is
| | 0, the next FREAD by this reader
| | deletes the record. (Refer to
| | Chapter 4.)
48 | plabel | Arm/disarm software interrupts.
| | The param parameter must pass the
| | external label (plabel) of your
| | interrupt procedure. If the value
| | of param is 0, the interrupt
| | mechanism is disabled for this
| | file.
| |
| | Also, if AOPTIONS (4:1) was set to
| | 0, option 48 resets it to 1. Be
| | sure to use IOWAIT or IODONTWAIT if
| | you use controlcode 48. (Refer to
| | Chapter 6.)
NOTE Native Mode plabels are 32 bits long, while Compatibility Mode
plabels are 16 bits. Therefore, the interrupt handler and the
FCONTROL call to it must be compiled in the same mode. Arming
software interrupts in cross-mode programming can be unpredictable,
and you should avoid this whenever possible.
FCHECK
One error message is returned only when using IPC:
151 CURRENT RECORD WAS LAST RECORD WRITTEN BEFORE SYSTEM
CRASHED.
This error is returned when for some reason (usually a system failure, or
running out of disc space), the system was unable to close the file
cleanly. (An FREAD of the record returns a CCL, and you can then use
FCHECK to read the message.)
FGETINFO
The values returned for recsize and EOF differ if FCONTROL with a
controlcode of 46 is in effect. The recsize value indicates the size of
your data records, including the 4-byte header. The number of records
returned in EOF includes open and close records as well as the data
records.
NOTE The recsize is supported to ensure backward compatibility with MPE
V/E-based systems. If a file's record size exceeds MPE V/E limits,
a zero is returned. Refer to the discussion of FGETINFO in the MPE
XL Intrinsics Reference Manual (32650-90028).
FFILEINFO
Three values for itemvalue are specifically for use with IPC:
Item # | Type | Description
34 | I16 | The current number of writers.
35 | I16 | The current number of readers.
49 | I16 | Software interrupt plabel. A value
| | of zero implies that software
| | interrupts are not being used.
MPE/iX 5.0 Documentation