From e4edfca1070c9219208af7b253532a9e10c8351a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 26 Jul 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-07-26 --- gnot/devdk.c | 9 ++--- gnot/devmnt.c | 1 + gnot/errno.h | 1 - gnot/proc.c | 11 ++--- gnot/sturp.c | 108 ++++++++++++++------------------------------------ port/devbit.c | 4 +- port/proc.c | 1 + port/sturp.c | 1 + 8 files changed, 41 insertions(+), 95 deletions(-) diff --git a/gnot/devdk.c b/gnot/devdk.c index dd6c6ed75729bb518c81e1117e8df49b8879a204..88599861ed9b0178e491ba31402c32f01b3732c7 100644 --- a/gnot/devdk.c +++ b/gnot/devdk.c @@ -456,7 +456,6 @@ dkmuxconfig(Dk *dp, Block *bp) */ dp->restart = 1; n = getfields((char *)bp->rptr, fields, 4, ' '); - strcpy(dp->name, "dk"); switch(n){ case 4: strncpy(dp->name, fields[3], sizeof(dp->name)); @@ -495,7 +494,7 @@ dkmuxconfig(Dk *dp, Block *bp) /* * start a process to deal with it */ - sprint(buf, "csckproc%d", dp->ncsc); + sprint(buf, "**csckproc%d**", dp->ncsc); kproc(buf, dkcsckproc, dp); poperror(); @@ -504,7 +503,7 @@ dkmuxconfig(Dk *dp, Block *bp) */ if(dktimeron == 0){ dktimeron = 1; - kproc("dktimer", dktimer, 0); + kproc("**dktimer**", dktimer, 0); } } @@ -593,10 +592,8 @@ dkattach(char *spec) Dk *dp; /* - * find a multiplexor with the same name (default dk) + * find a multiplexor with the same name */ - if(*spec == 0) - spec = "dk"; for(dp = dk; dp < &dk[Ndk]; dp++){ qlock(dp); if(dp->wq && strcmp(spec, dp->name)==0) { diff --git a/gnot/devmnt.c b/gnot/devmnt.c index 239b2b253383fbeb890e71a0eda588606e89c1e2..c96f567a91dad05afe95d1d46a88913cf1dd2b3c 100644 --- a/gnot/devmnt.c +++ b/gnot/devmnt.c @@ -291,6 +291,7 @@ mntattach(char *spec) mh = mhalloc(); if(waserror()){ mhfree(mh); + mqfree(q); close(c); nexterror(); } diff --git a/gnot/errno.h b/gnot/errno.h index ee070d757d339a590130a6765dd747ff37150b39..f569775960d22f6307d687a57ff826844e296c87 100644 --- a/gnot/errno.h +++ b/gnot/errno.h @@ -50,7 +50,6 @@ enum{ Enobitmap, /* out of bitmap descriptors */ Enobitstore, /* out of bitmap storage */ Ebadbitmap, /* unallocated bitmap */ - Ebadfont, /* unallocated font */ Eshortmsg, /* short message */ Ebadmsg, /* format error or mismatch in message */ Ebadcnt, /* read count greater than requested */ diff --git a/gnot/proc.c b/gnot/proc.c index d86d46c3cbc8c19176619eedb4cdf59faae0ad06..eed82727919e996223972847a5452ceee822cd95 100644 --- a/gnot/proc.c +++ b/gnot/proc.c @@ -575,7 +575,6 @@ kproc(char *name, void (*func)(void *), void *arg) int lastvar; /* used to compute stack address */ User *up; KMap *k; - static Pgrp *kpgrp; /* * Kernel stack @@ -613,16 +612,12 @@ kproc(char *name, void (*func)(void *), void *arg) p->mach = m; m->proc = p; spllo(); + strncpy(p->text, name, sizeof p->text); (*func)(arg); pexit(0, 1); } - if(kpgrp == 0){ - kpgrp = newpgrp(); - strcpy(kpgrp->user, "bootes"); - } - p->pgrp = kpgrp; - incref(kpgrp); - sprint(p->text, "%s.%.6s", name, u->p->pgrp->user); + p->pgrp = u->p->pgrp; + incref(p->pgrp); p->nchild = 0; p->parent = 0; memset(p->time, 0, sizeof(p->time)); diff --git a/gnot/sturp.c b/gnot/sturp.c index b85c6ebe64003fabaf41f0100f1b06bfa963bf5f..a6879dc8ccef1fbff799e5511a68737309705caa 100644 --- a/gnot/sturp.c +++ b/gnot/sturp.c @@ -11,7 +11,7 @@ enum { Nmask= 0x7, }; -#define DPRINT /*if(q->flag&QDEBUG)kprint*/ +#define DPRINT if(q->flag&QDEBUG)kprint typedef struct Urp Urp; @@ -67,12 +67,6 @@ struct Urp { #define IN(x, f, n) (f<=n ? (x>=f && x=f)) #define NEXT(x) (((x)+1)&Nmask) -/* - * Alarm for urptiming - */ -Alarm *urptiming; -Lock urptlock; - /* * Protocol control bytes */ @@ -122,7 +116,6 @@ static void sendrej(Urp*); static void initoutput(Urp*, int); static void initinput(Urp*, int); static void urpkproc(void *arg); -static void urptimer(Alarm*); static void urpvomit(char*, Urp*); Qinfo urpinfo = { urpciput, urpoput, urpopen, urpclose, "urp" }; @@ -167,18 +160,10 @@ urpopen(Queue *q, Stream *s) /* * start the ack/(re)xmit process */ - sprint(name, "urp%d", up - urp); - kproc(name, urpkproc, up); - - /* - * start the urptimer if it isn't already - */ - if(urptiming==0){ - if(canlock(&urptlock)){ - if(urptiming == 0) - urptiming = alarm(500, urptimer, 0); - unlock(&urptlock); - } + if(up->kstarted == 0){ + up->kstarted = 1; + sprint(name, "**urp%d**", up - urp); + kproc(name, urpkproc, up); } } @@ -186,14 +171,6 @@ urpopen(Queue *q, Stream *s) * Shut down the connection and kill off the kernel process */ static int -isdead(void *a) -{ - Urp *up; - - up = (Urp *)a; - return up->kstarted==0; -} -static int isflushed(void *a) { Urp *up; @@ -222,7 +199,7 @@ urpclose(Queue *q) tsleep(&up->r, isflushed, up, 2*60*1000); /* - * tell kernel process to die + * kill off the kernel process */ up->state |= HUNGUP; wakeup(&up->rq->r); @@ -246,13 +223,10 @@ urpclose(Queue *q) } qunlock(&up->xmit); - /* - * wait for kernel process to die - */ - while(up->kstarted) - sleep(&up->r, isdead, up); - - up->state = 0; + if(up->kstarted == 0){ + DPRINT("urpclose %ux\n", up); + up->state = 0; + } } /* @@ -615,17 +589,6 @@ output(Urp *up) int n; int i; - /* - * start the urptimer if it isn't already - */ - if(urptiming==0){ - if(canlock(&urptlock)){ - if(urptiming == 0) - urptiming = alarm(500, urptimer, 0); - unlock(&urptlock); - } - } - if(!canqlock(&up->xmit)) return; @@ -644,7 +607,9 @@ output(Urp *up) sendctl(up, INIT1); up->timer = now + MSrexmit; } - goto out; + qunlock(&up->xmit); + poperror(); + return; } /* @@ -688,7 +653,9 @@ output(Urp *up) up->timer = NOW + MSrexmit; up->state &= ~REJECTING; sendctl(up, ENQ); - goto out; + qunlock(&up->xmit); + poperror(); + return; } /* @@ -709,7 +676,6 @@ output(Urp *up) up->next = NEXT(up->next); poperror(); } -out: qunlock(&up->xmit); poperror(); } @@ -975,53 +941,39 @@ todo(void *arg) static void urpkproc(void *arg) { - Urp *up; + Urp *up; Queue *q; up = (Urp *)arg; - up->kstarted = 1; + q = up->wq; if(waserror()){ print("urpkproc error %ux\n", up); + up->state = 0; up->kstarted = 0; wakeup(&up->r); return; } for(;;){ - if(up->state & HUNGUP) + if(up->state & (HUNGUP|CLOSING)){ + if(isflushed(up)) + wakeup(&up->r); + if(up->state & HUNGUP) + break; + } + if(up->state == 0){ + DPRINT("urpkproc: %ux->state == 0\n", up); break; + } if(!QFULL(up->rq->next)) sendack(up); output(up); - sleep(&up->rq->r, todo, up); + tsleep(&up->rq->r, todo, up, MSrexmit/2); } + up->state = 0; up->kstarted = 0; - wakeup(&up->r); - poperror(); DPRINT("urpkproc %ux\n", up); } -/* - * timer to wakeup urpkproc's for retransmissions - */ -static void -urptimer(Alarm *a) -{ - Urp *up; - Urp *last; - Queue *q; - - urptiming = 0; - for(up = urp, last = &urp[conf.nurp]; up < last; up++){ - if(up->state==0) - continue; - if(up->unacked!=up->next && NOW>up->timer){ - q = up->rq; - if(q) - wakeup(&q->r); - } - } -} - /* * urp got very confused, complain */ diff --git a/port/devbit.c b/port/devbit.c index f324a3567cb318a521a6795a642c35773402a0fe..bd217e8f98912d5d0bacd94789bc2af8bba17f9e 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -61,7 +61,7 @@ struct{ Cursor arrow = { - {1, 1}, + {0, 0}, {0xFF, 0xE0, 0xFF, 0xE0, 0xFF, 0xC0, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0xFF, 0xC0, 0xFF, 0xE0, 0xE7, 0xF0, 0xE3, 0xF8, 0xC1, 0xFC, 0x00, 0xFE, @@ -657,7 +657,7 @@ bitwrite(Chan *c, void *va, long n) v = GSHORT(p+1); f = &bit.font[v]; if(v<0 || v>=conf.nfont || f->bits==0) - error(0, Ebadfont); + error(0, Ebadbitmap); f->bits = 0; m -= 3; p += 3; diff --git a/port/proc.c b/port/proc.c index a68f9eb1f4c72ce8f6b0c082a91ca4a6a7707f11..e94fc65960ae39adb5f09e61cbae06fdf4bdfea7 100644 --- a/port/proc.c +++ b/port/proc.c @@ -299,6 +299,7 @@ void twakeme(Alarm *a) { wakeup((Rendez*)(a->arg)); + cancel(a); } int diff --git a/port/sturp.c b/port/sturp.c index 51084d8cb87cf0d1b8f407b29a8c5769281c687d..e8a412e9dc84befc9d2934d7ebbe6ea5ad336a0d 100644 --- a/port/sturp.c +++ b/port/sturp.c @@ -1013,6 +1013,7 @@ urptimer(Alarm *a) Urp *last; Queue *q; + cancel(a); urptiming = 0; for(up = urp, last = &urp[conf.nurp]; up < last; up++){ if(up->state==0)