[net.unix-wizards] Help with multplexed file limit

norm (04/19/83)

Has anyone successfully increased the number of multiplexed files which can
be simultaneously opened under 4.1bsd?  A large number of users at our site 
have adopted Gosling's emacs as their editor of choice, and its maintainer 
has enabled the subprocess option using multiplexed files.  Needless to say,
it doesn't take too long (or too many users) to run out of multiplexed files.

Normally I can handle the flak from our user community, but a recent wrinkle
has been introduced which is a bit sensitive.  Some fool went and wrote a
cutesy little menu package for our Company president using emacs, and its now
expected to work all of the time.  Since this gentleman also has to authorize
most of my equipment purchases, it would be in my best interests to resolve
this issue.  We are planning to convert to 4.1cbsd soon, but if I can even get
a weeks grace with an increased multiplexer count I would be grateful.

The first few lines of our mx.h file look like this:
    /*	mx.h	4.3	81/02/25	*/
    #define	NGROUPS		10	/* number of mpx files permitted at one 					   time */
    #define	NCHANS		20	/* number of channel structures */
    #define	NPORTS		30	/* number of channels to i/o ports */
    #define	CNTLSIZ		10
    #define	NLEVELS		4
    #define	NMSIZE		50	/* max size of mxlstn file name */

I've already tried the [foolishly] obvious of increasing NGROUPS from 10 to 20,
only to have the /tmp filesystem and password file scarfed up within 12 hours
of booting that version of the system.

Thanks in advance for any help or suggestions,

Norm Seethoff
Technical Computing 
John Fluke Mfg. Co., Inc.
decvax!microsoft!fluke!norm
lbl-csam!fluke!norm

swatt (04/21/83)

I'm not sure what emacs requires from MXP files.  If you're interested
in just increasing the number of MPX files that may exist at one time,
then:

	in mx.h:

	#define	NGROUPS	60	/* number of mpx files permitted at one time */
	#define	NCHANS	100	/* number of channel structures */
	#define	NPORTS	100	/* number of channels to i/o ports */
	#define	CNTLSIZ	10
	#define	NLEVELS	4
	#define	NMSIZE	50	/* max size of mxlstn file name */

I don't recall exactly what the relationship between GROUPS and CHANS
is, but I think GROUP is the total number of MPX files, and CHANS is
the total number of processes attached to MPX files.  One file with a
master process and a single process opening the other end would
therefore require 1 GROUP and 2 CHANS.  PORTS affect only the case of
joining MPX files to tty devices.

Note also the several-times mentioned bugs with mx2.c which will cause
directories to get scribbled on sometimes.  A modified source has been
posted twice.

Changes to increase the number of processes attached to a given MPX
file affects pretty much the entire kernel, as it changes the size of
the in-core inode structure.  You also need to change NINDEX in
"inode.h".  We did that from 6 to 15.

	in inode.h:

	#define	NINDEX	15

Will allow up to 15 processes to open an MPX file, however, just
increasing NINDEX is not the way MPX files were intended to be used.
What you're supposed to do is:

	master = mpx ("", 0666);
	sub = mpx ("node1", 0666);
	join (sub, master);
	sub = mpx ("node2", 0666);
	join (sub, master);
	sub = mpx ("node3", 0666);
	join (sub, master);

	<and so on>

This will give you "node1", "node2", ..., which are all "joined" to the
master node, which is nameless.  Each sub-node may be opened by as many
as NINDEX processes.  Operations on any of these sub nodes will be
handled by the process behind the master node.

You may nest nodes to the level of 4.  The MPX "id" is a 16-bit number,
consisting of 4 4-bit nibbles, one for each level in the tree.  Each
nibble is a number 0-14 identifying one of 15 channels at that level.
You can't increase NINDEX past 15 as the number 15 is reserved for an
illegal channel number.

Thus the number of channels you can have on a one-deep tree is NINDEX;
the number at a two-deep tree is NINDEX^2; and so on.  The whole number
is limited by the global parameters from mx.h

	- Alan S. Watt (who learned it the hard way ...)
	{decvax,duke,purdue,lbl-csam}!ittvax!swatt