mpx \- create and manipulate multiplexed files
is the system call shared by the
library routines described below.
selects a command using values
structure containing the arguments
creates and opens the file
and returns a file descriptor available for
A \-1 is returned if the file cannot be created,
if the file table or other operating system
data structures are full.
The file descriptor is required for use
designates a null string,
a file descriptor is returned as described
but no entry is created in the file system.
Once created an mpx file may be opened
This provides a form of interprocess communication
whereby a process B can `call' process A
To B, the file is ordinary with one exception:
primitive could be applied to it.
described below are used only in process A
and descendants that inherit the open mpx file.
When a process opens an mpx file, the owner of the
file receives a control message when the file is next read.
The method for `answering'
this kind of call involves
as described in more detail below.
Once B has opened A's mpx file
A channel is a pair of data streams:
in this case, one from B to A and the
Several processes may open the same mpx file
yielding multiple channels within the one mpx file.
By accessing the appropriate channel,
A can communicate with B and any others.
data written to A by the other processes appears
in A's buffer using a record format
on its mpx file the data must be formatted in a similar way.
are used to manipulate mpx files and channels.
adds a new channel on an mpx file to an open file F.
I/O on the new channel is I/O on F.
file descriptor maintenance.
similar to join except that the open file F is connected
manipulates process group numbers so that a channel
can act as a control terminal (see
to process group through channel.
A maximum of 15 channels may be connected to an
They are numbered 0 through 14.
may be used to make one mpx file appear as a channel
A hierarchy or tree of mpx files may be set up in this way.
one of the mpx files must be the root of a tree
where the other mpx files are interior nodes.
The maximum depth of such a tree
in an mpx tree other than the root:
the path through mpx `nodes' from the root
to the location is expressed as a sequence of
The branch taken at the root is represented by
the low-order 4-bits of an index.
Each succeeding branch is specified by the next
If the length of a path to be expressed
then the illegal channel number, 15,
must be used to terminate the sequence.
This is not strictly necessary for the
simple case of a tree consisting of
only a root node: its channels
can be expressed by the numbers
for the root of an mpx tree are
required as arguments to most
of the commands described below.
Indices also serve as channel identifiers
in the record formats given in
Since -1 is not a valid index,
it can be returned as a error indication
by subroutines that normally return
The operating system informs the process managing an mpx file
of changes in the status of channels attached to the file
by generating messages that
are read along with data from the channels.
The form and content of these messages is described
establishes a connection (channel) between an mpx file
is an open file descriptor for a character device
is the file descriptor of an
returns the index for the new channel
if the operation succeeds and \-1
may still be used in any system call that would
have been meaningful before the join operation.
a process can read and write directly to
If the number of channels
required for a tree of mpx files
exceeds the number of open files
permitted a process by the operating system,
some of the file descriptors can be released using
Following a close on an active file descriptor for a channel
that object may still be accessed through the root of the
allocates a channel and connects
one end of it to the mpx file
represented by file descriptor
returns the index of the new channel or
a \-1 indicating failure.
primitive can be used to get a non-multiplexed
file descriptor for the free end of a channel
operate on the mpx file specified by
File descriptors for interior nodes of an
mpx tree must be preserved or reconstructed with
For the remaining commands described here,
denotes the file descriptor for the
returns a file descriptor for the object with
on the mpx tree with root file descriptor
A \-1 is returned by extract if a file descriptor is not available
or if the arguments do not refer to an existing
If a process A has created an mpx file represented
The purpose is to establish a channel between
A and B through the mpx file.
are used by A to respond to
An open request by B fails immediately if a
new channel cannot be allocated on the mpx file,
if the mpx file does not exist,
but there is no process (A)
with a multiplexed file descriptor
The next time A reads on file descriptor
the WATCH control message
will be delivered on channel
A responds to this message with
The former causes the open to complete and
return a file descriptor to B.
The latter deallocates channel
and causes the open to fail.
One mpx file may be placed in `listener' mode.
.I "ioctl(xd, MXLSTN, 0)"
is an mpx file descriptor
.IR /usr/include/sgtty.h .
The semantics of listener mode are that
all file names discovered by
are treated as opens on the mpx file.
The operating system sends the listener process
which includes the file name being opened.
then apply as described above.
it closes and releases the resources
of any active channel it is applied to,
and should be used to respond to
on a channel so the channel may be reused.
.BR "connect(fd, cd, end)" .
is a character file descriptor and
is a file descriptor for a channel,
such as might be obtained via
.I "extract( chan(xd), xd)"
splices the two streams together.
is spliced to the input of
is positive, the output of
is spliced to the input of
is zero, then both splices are made.
.BR "npgrp(i, xd, pgrp)" .
applies to the process executing it,
are interpreted as a channel index and
is applied to the process on the
non-multiplexed end of the channel.
is zero, the process group number of the indicated process
is set to the process number of that process,
is used as the process group number.
normally returns the new process group number.
specify a nonexistant channel,
sends the specified signal (see
through the channel specified by
If the channel is connected to anything other
If there is a process at the other end of the channel,
the process group will be interrupted (see
specify a nonexistent channel,
Mpx files are an experimental part of the operating
system more subject to change and prone to bugs
Maintenance programs, e.g.
diagnose mpx files as an illegal mode.
Channels may only be connected to objects in the operating
system that are accessible through the line discipline
Higher performace line disciplines are needed.
The maximum tree depth restriction is not really checked.
A non-blocking flow control strategy
based on messages defined in
should not be attempted by novices;
command should be protected.
operation could be subsumed by
A mechanism is needed for moving a channel from one
location in an mpx tree to another.