📄 mpx.2
字号:
.TH MPX 2 .SH NAMEmpx \- create and manipulate multiplexed files.SH SYNOPSIS.B mpx(name, access).B char *name;.PP.B join(fd, xd).PP.B chan(xd).PP.B extract(i, xd).PP.B attach(i, xd).PP.B detach(i, xd).PP.B connect(fd, cd, end).PP.B npgrp(i, xd, pgrp).PP.B ckill(i, xd, signal).PP.B #include <sys/mx.h>.br.B mpxcall(cmd, vec).br.B int *vec;.SH DESCRIPTION.PP.B mpxcall(cmd, vec)is the system call shared by the library routines described below..I Cmdselects a command using valuesdefined in.IR <sys/mx.h> ..I Vecis the address of astructure containing the argumentsfor the command..PP.B mpx(name, access).PP.I Mpxcreates and opens the file .I namewith access permission.I access(see.IR creat (2))and returns a file descriptor available forreading and writing.A \-1 is returned if the file cannot be created,if.I namealready exists, orif the file table or other operating systemdata structures are full.The file descriptor is required for usewith other routines..PPIf.I namedesignates a null string,a file descriptor is returned as describedbut no entry is created in the file system..PPOnce created an mpx file may be opened(see.IR open (2))by any process.This provides a form of interprocess communicationwhereby a process B can `call' process Aby opening an mpx file created by A.To B, the file is ordinary with one exception:the.I connectprimitive could be applied to it.Otherwise the functionsdescribed below are used only in process Aand descendants that inherit the open mpx file..PPWhen a process opens an mpx file, the owner of thefile receives a control message when the file is next read.The method for `answering' this kind of call involves using.I attachand.I detachas described in more detail below..PPOnce B has opened A's mpx fileit is said to have a.I channelto A.A channel is a pair of data streams:in this case, one from B to A and theother from A to B.Several processes may open the same mpx fileyielding multiple channels within the one mpx file.By accessing the appropriate channel,A can communicate with B and any others.When A reads (see.IR read (2))from the mpx filedata written to A by the other processes appearsin A's buffer using a record formatdescribed in.IR mpxio (5).When A writes (see.IR write (2))on its mpx file the data must be formatted in a similar way..PPThe following commandsare used to manipulate mpx files and channels..IP.IR join \-adds a new channel on an mpx file to an open file F.I/O on the new channel is I/O on F..br.IR chan \-creates a new channel..br.IR extract \-file descriptor maintenance..br.IR connect \-similar to join except that the open file F is connectedto an existing channel..br.I attachand.IR detach \-used with call protocol..br.IR npgrp \-manipulates process group numbers so that a channelcan act as a control terminal (see.IR tty (4))..br.IR ckill \-send signal (see.IR signal (2))to process group through channel..PPA maximum of 15 channels may be connected to anmpx file.They are numbered 0 through 14..I Joinmay be used to make one mpx file appear as a channelon another mpx file.A hierarchy or tree of mpx files may be set up in this way.In this caseone of the mpx files must be the root of a treewhere the other mpx files are interior nodes.The maximum depth of such a treeis 4..PPAn.I indexis a 16-bit valuethat denotes a locationin an mpx tree other than the root:the path through mpx `nodes' from the rootto the location is expressed as a sequence of4-bit nibbles.The branch taken at the root is represented bythe low-order 4-bits of an index.Each succeeding branch is specified by the nexthigher-order nibble.If the length of a path to be expressedis less than 4,then the illegal channel number, 15,must be used to terminate the sequence.This is not strictly necessary for thesimple case of a tree consisting ofonly a root node: its channelscan be expressed by the numbers0 through 14.An index.I iand file descriptor.I xdfor the root of an mpx tree arerequired as arguments to mostof the commands described below.Indices also serve as channel identifiersin the record formats given in.IR mpxio (5).Since -1 is not a valid index,it can be returned as a error indicationby subroutines that normally returnindices..PPThe operating system informs the process managing an mpx fileof changes in the status of channels attached to the fileby generating messages thatare read along with data from the channels.The form and content of these messages is describedin.IR mpxio (5)..PP.B join(fd, xd)establishes a connection (channel) between an mpx fileand another object..I Fdis an open file descriptor for a character deviceor an mpx file and.I xdis the file descriptor of anmpx file..I Joinreturns the index for the new channelif the operation succeeds and \-1if it does not..PPFollowing join,.I fdmay still be used in any system call that wouldhave been meaningful before the join operation.Thusa process can read and write directly to.I fdas well as access it via.I xd.If the number of channelsrequired for a tree of mpx filesexceeds the number of open filespermitted a process by the operating system,some of the file descriptors can be released usingthe standard .IR close (2)call.Following a close on an active file descriptor for a channelor internal mpx node,that object may still be accessed through the root of thetree..PP.B chan(xd)allocates a channel and connectsone end of it to the mpx filerepresented by file descriptor.I xd..I Chanreturns the index of the new channel ora \-1 indicating failure.The.I extractprimitive can be used to get a non-multiplexedfile descriptor for the free end of a channelcreated by.I chan..PPBoth.I chanand.I joinoperate on the mpx file specified by.IR xd .File descriptors for interior nodes of anmpx tree must be preserved or reconstructed with.I extractfor use with.I joinor.IR chan .For the remaining commands described here,.I xddenotes the file descriptor for theroot of an mpx tree..PP.B Extract(i, xd)returns a file descriptor for the object withindex.I ion the mpx tree with root file descriptor.I xd.A \-1 is returned by extract if a file descriptor is not availableor if the arguments do not refer to an existingchannel and mpx file..PP.B attach(i, xd).br.BR "detach(i, xd)" .If a process A has created an mpx file representedby file descriptor.I xd,then a process Bcan open (see.IR open (2))the mpx file.The purpose is to establish a channel betweenA and B through the mpx file..I Attachand .I Detachare used by A to respond tosuch opens..PPAn open request by B fails immediately if a new channel cannot be allocated on the mpx file,if the mpx file does not exist,or if it does existbut there is no process (A)with a multiplexed file descriptorfor the mpx file(i.e..I xdas returned by.IR mpx (2)).Otherwise a channelwith index number.I iis allocated.The next time A reads on file descriptor.IR xd ,the WATCH control message(see.IR mpxio (5))will be delivered on channel.I i.A responds to this message with.I attachor .I detach.The former causes the open to complete andreturn a file descriptor to B.The latter deallocates channel.I iand causes the open to fail..PPOne mpx file may be placed in `listener' mode.This is done by writing.I "ioctl(xd, MXLSTN, 0)"where.I xdis an mpx file descriptorand MXLSTN is defined in .IR /usr/include/sgtty.h .The semantics of listener mode are thatall file names discovered by .IR open (2)to have the syntax.I "system!pathname"(see.IR uucp (1))are treated as opens on the mpx file.The operating system sends the listener process an OPEN message (see.IR mpxio (5))which includes the file name being opened..I Attachand.I detachthen apply as described above..PP.I Detachhas two other uses:it closes and releases the resourcesof any active channel it is applied to,and should be used to respond toa CLOSE message (see.IR mpxio (5))on a channel so the channel may be reused..PP.BR "connect(fd, cd, end)" ..I Fdis a character file descriptor and.I cdis a file descriptor for a channel,such as might be obtained via.I "extract( chan(xd), xd)"or by.IR open (2)followed by.I attach..I Connectsplices the two streams together.If.I endis negative, onlythe output of.I fdis spliced to the input of.I cd.If.I endis positive, the output of.I cdis spliced to the input of.I fd.If.I endis zero, then both splices are made..PP.BR "npgrp(i, xd, pgrp)" .If.I xdis negative.I npgrpapplies to the process executing it,otherwise.I iand.I xdare interpreted as a channel index andmpx file descriptorand.I npgrpis applied to the process on thenon-multiplexed end of the channel.If.I pgrpis zero, the process group number of the indicated processis set to the process number of that process,otherwise the value of.I pgrpis used as the process group number..PP.I Npgrpnormally returns the new process group number.If.I iand.I xdspecify a nonexistant channel,.I npgrpreturns \-1..PP.B ckill(i, xd, signal)sends the specified signal (see.IR signal (2))through the channel specified by.I iand.I xd.If the channel is connected to anything otherthan a process,.I ckillis a null operation.If there is a process at the other end of the channel,the process group will be interrupted (see.IR signal (2),.IR kill (2))..I Ckillnormally returns .I signal.If.I chand.I xdspecify a nonexistent channel,.I ckillreturns \-1..SH FILES/usr/include/sys/mx.h.br/usr/include/sgtty.h.SH "SEE ALSO"mpxio(5).SH BUGS.PPMpx files are an experimental part of the operatingsystem more subject to change and prone to bugsthan other parts.Maintenance programs, e.g..IR icheck (1),diagnose mpx files as an illegal mode.Channels may only be connected to objects in the operatingsystem that are accessible through the line disciplinemechanism.Higher performace line disciplines are needed.The maximum tree depth restriction is not really checked.A non-destructive.I disconnectprimitive (inverse of.IR connect )is not provided.A non-blocking flow control strategybased on messages defined in.IR mpxio (5)should not be attempted by novices;the enabling.I ioctlcommand should be protected.The.I joinoperation could be subsumed by.I connect.A mechanism is needed for moving a channel from onelocation in an mpx tree to another.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -