Plan 9 from Bell Labs’s /usr/web/sources/contrib/mycroftiv/root/sys/src/cmd/iosrv/dat.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#define BUCKSIZE 524288
#define MAXQ 512
#define MAXFDS 64
#define MAXHOLD 2048
#define SMBUF 256
#define HUBNUM 32

/* A Hub is an abstraction that is like a pipe with multiple attachments on each end */
/* in general all clients receive all messages and writes are first-come first served */

typedef struct Hub	Hub;
struct Hub{
	char name[SMBUF];			/* name */
	char bucket[BUCKSIZE];		/* data buffer */
	int hubstate;				/* control switch */
	int sleeptime;				/* heuristic sleep timer */
	int infds[MAXFDS];			/* input file descriptors */
	int outfds[MAXFDS];			/* output file descriptors */
	int infdcount;				/* total number of inclients */
	int outfdcount;				/* total number of outclients */
	int infdpids[MAXFDS];		/* input listener process IDs */
	int outfdpids[MAXFDS];		/* output writer process IDs */
	int infdstat[MAXFDS];		/* status of reading processes */
	int outfdstat[MAXFDS];		/* status of writing processes */
	char *inbuckp;				/* location to store next message */
	int inqsize[MAXQ];			/* incoming message length index */
	char *msgptr[MAXQ];		/* message starting location index */
	int inqcount;				/* total number of messages received */
	int outq[MAXFDS];			/* message index queue for output writers  */
	QLock iblck;				/* locks for the inputbucket and queues */
	QLock wroblck[MAXFDS];		/* individual lock for each writer proc */
	QLock entwrlck;			/* lock for releasing subwriter locks */
};

enum flags{
	GO = 1,
	STOP = 2,
	UP = 3, 
	DOWN = 4, 
};

char *srvname;				/* name posted in /srv */
char dirname[SMBUF];		/* tmp directory name */
int masterswitch;			/* one flag to rule them all */
int verbosity;				/* debugging output toggle */
int fdctl;					/* fd for control server input */
int sleepdefault;			/* default sleep timer milliseconds */
int fdcounter;				/* extrafd array counter for pipe fds */
int hubmon[HUBNUM];		/* external hub status monitor flag array */
char nohold;				/* determines if fds will be held for safety */
int extrafds[MAXHOLD];		/* holds pipe (3) fds so they dont vanish */
int paranoia;				/* locks reader speed to writer speed */
int ketchup;				/* monitors paranoia justification */

/* An array of pointers to Hubs is the outer layer of the data structures */
/* As it is allocated, each Hub uses BUCKSIZE memory */
/* The HUBNUM limit is a pragmatic limit on maximum possible memory consumption */

Hub *Hubs[HUBNUM];

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].