~kris/9p

9hist

99e17d2be68bb57fa6bd607cff14b14bfb3c14d0 — David du Colombier 34 years ago 4df8aa2
Plan 9 from Bell Labs 1992-03-09
6 files changed, 55 insertions(+), 26 deletions(-)

M gnot/lib.h
M port/lib.h
M port/portdat.h
M port/proc.c
M port/sysproc.c
M port/systab.h
M gnot/lib.h => gnot/lib.h +2 -3
@@ 118,8 118,7 @@ struct Dir

struct Waitmsg
{
	int	pid;		/* of loved one */
	int	status;		/* unused; a placeholder */
	ulong	time[3];	/* of loved one */
	char	pid[12];	/* of loved one */
	char	time[3*12];	/* of loved one and descendants */
	char	msg[ERRLEN];
};

M port/lib.h => port/lib.h +2 -3
@@ 118,8 118,7 @@ struct Dir

struct Waitmsg
{
	int	pid;		/* of loved one */
	int	status;		/* unused; a placeholder */
	ulong	time[3];	/* of loved one */
	char	pid[12];	/* of loved one */
	char	time[3*12];	/* of loved one and descendants */
	char	msg[ERRLEN];
};

M port/portdat.h => port/portdat.h +1 -1
@@ 46,7 46,7 @@ struct List
struct Ref
{
	Lock;
	int	ref;
	long	ref;
};

struct Rendez

M port/proc.c => port/proc.c +14 -16
@@ 5,11 5,7 @@
#include	"fns.h"
#include	"../port/error.h"

struct
{
	Lock;
	ulong	pid;
}pidalloc;
Ref	pidalloc;

struct
{


@@ 34,7 30,8 @@ typedef struct
Schedq	runhiq, runloq;
int	nrdy;

char *statename[]={	/* BUG: generate automatically */
char *statename[] =
{			/* BUG: generate automatically */
	"Dead",
	"Moribund",
	"Ready",


@@ 231,9 228,7 @@ newproc(void)
			p->procctl = 0;
			p->notepending = 0;
			memset(p->seg, 0, sizeof p->seg);
			lock(&pidalloc);
			p->pid = ++pidalloc.pid;
			unlock(&pidalloc);
			p->pid = incref(&pidalloc);
			if(p->pid == 0)
				panic("pidalloc");
			return p;


@@ 448,7 443,6 @@ postnote(Proc *p, int dolock, char *n, int flag)
	return ret;
}


/*
 * weird thing: keep at most NBROKEN around
 */


@@ 527,12 521,15 @@ pexit(char *exitstr, int freemem)
			panic("boot process died");
			
		wq = newwaitq();
		wq->w.pid = c->pid;
		readnum(0, wq->w.pid, NUMSIZE, c->pid, NUMSIZE);
		utime = c->time[TUser] + c->time[TCUser];
		stime = c->time[TSys] + c->time[TCSys];
		wq->w.time[TUser] = TK2MS(utime);
		wq->w.time[TSys] = TK2MS(stime);
		wq->w.time[TReal] = TK2MS(MACHP(0)->ticks - c->time[TReal]);
		readnum(0, &wq->w.time[TUser*12], NUMSIZE,
			TK2MS(utime), NUMSIZE);
		readnum(0, &wq->w.time[TSys*12], NUMSIZE,
			TK2MS(stime), NUMSIZE);
		readnum(0, &wq->w.time[TReal*12], NUMSIZE,
			TK2MS(MACHP(0)->ticks - c->time[TReal]), NUMSIZE);
		if(exitstr && exitstr[0]){
			n = sprint(wq->w.msg, "%s %d:", c->text, c->pid);
			strncpy(wq->w.msg+n, exitstr, ERRLEN-n);


@@ 540,7 537,8 @@ pexit(char *exitstr, int freemem)
			wq->w.msg[0] = '\0';

		lock(&p->exl);
		/* My parent still alive */
		/* My parent still alive, processes are limited to 128 Zombies to
		 * prevent badly written daemon consuming all the wait records */
		if(p->pid == c->parentpid && p->state != Broken && p->nwait < 128) {	
			p->nchild--;
			p->time[TCUser] += utime;


@@ 631,7 629,7 @@ pwait(Waitmsg *w)

	if(w)
		memmove(w, &wq->w, sizeof(Waitmsg));
	cpid = wq->w.pid;
	cpid = atoi(wq->w.pid);
	freewaitq(wq);
	return cpid;
}

M port/sysproc.c => port/sysproc.c +30 -0
@@ 434,6 434,36 @@ syswait(ulong *arg)
}

long
sys__wait__(ulong *arg)			/* binary compatibility: BUG */
{
	int i;

	struct oldWaitmsg
	{
		int	pid;		/* of loved one */
		int	status;		/* unused; a vestige */
		long	time[3];	/* of loved one & descendants */
		char	msg[ERRLEN];
	} *wp;
	Waitmsg w;

	if(arg[0]){
		validaddr(arg[0], sizeof(struct oldWaitmsg), 1);
		evenaddr(arg[0]);
		i = pwait(&w);
		wp = (struct oldWaitmsg*)arg[0];
		wp->pid = atoi(w.pid);
		wp->status = 0;
		wp->time[TUser] = atoi(w.time+TUser*NUMSIZE);
		wp->time[TSys] = atoi(w.time+TSys*NUMSIZE);
		wp->time[TReal] = atoi(w.time+TReal*NUMSIZE);
		memmove(wp->msg, w.msg, ERRLEN);
		return i;
	}
	return pwait(0);
}

long
sysdeath(ulong *arg)
{
	USED(arg);

M port/systab.h => port/systab.h +6 -3
@@ 22,7 22,7 @@ Syscall sysread;
Syscall sysseek;
Syscall syssleep;
Syscall sysstat;
Syscall syswait;
Syscall sys__wait__;
Syscall syswrite;
Syscall syspipe;
Syscall syscreate;


@@ 39,6 39,7 @@ Syscall syssegfree;
Syscall syssegflush;
Syscall sysrendezvous;
Syscall sysunmount;
Syscall syswait;

Syscall *systab[]={
	[SYSR1]		sysr1,


@@ 60,7 61,7 @@ Syscall *systab[]={
	[SEEK]		sysseek,
	[SLEEP]		syssleep,
	[STAT]		sysstat,
	[WAIT]		syswait,
	[__WAIT__]	sys__wait__,
	[WRITE]		syswrite,
	[PIPE]		syspipe,
	[CREATE]	syscreate,


@@ 77,6 78,7 @@ Syscall *systab[]={
	[SEGFLUSH]	syssegflush,
	[RENDEZVOUS]	sysrendezvous,
	[UNMOUNT]	sysunmount,
	[WAIT]		syswait,
};

char *sysctab[]={


@@ 99,7 101,7 @@ char *sysctab[]={
	[SEEK]		"Seek",
	[SLEEP]		"Sleep",
	[STAT]		"Stat",
	[WAIT]		"Wait",
	[__WAIT__]	"__wait_",
	[WRITE]		"Write",
	[PIPE]		"Pipe",
	[CREATE]	"Create",


@@ 116,4 118,5 @@ char *sysctab[]={
	[SEGFLUSH]	"Segflush",
	[RENDEZVOUS]	"Rendez",
	[UNMOUNT]	"Unmount",
	[WAIT]		"Wait",
};