From ace26b95915010cf8deb169f71f706eb937ab81b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 11 Aug 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-08-11 --- alphapc/dat.h | 1 - carrera/dat.h | 1 - carrera/fns.h | 1 + ip/tcp.c | 2 +- mpc/dat.h | 1 - pc/dat.h | 1 - port/chan.c | 43 +++++++++++++++++++++++++------------------ port/proc.c | 10 +++++----- port/sysfile.c | 4 ++-- port/taslock.c | 16 ++++++---------- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/alphapc/dat.h b/alphapc/dat.h index aed58a6686e8d7eafd7384413636ea149956e726..166d03eeab19d3c115f37a8fb0581c66f2ff4adf 100644 --- a/alphapc/dat.h +++ b/alphapc/dat.h @@ -33,7 +33,6 @@ struct Lock Proc *p; ulong pid; ushort isilock; - ulong glare; }; struct Label diff --git a/carrera/dat.h b/carrera/dat.h index a49a43154591c9dfbd2a97bc68f2e232dbe47d7b..d14b4ee3f10777abba5e9c23a80e738ceb197249 100644 --- a/carrera/dat.h +++ b/carrera/dat.h @@ -29,7 +29,6 @@ struct Lock ulong pc; Proc *p; ushort isilock; - ulong glare; }; struct Label diff --git a/carrera/fns.h b/carrera/fns.h index 3ee2781383662cd9e89de46f3d60cb265bd051ef..e9fa35b8b624d112fd292ece348494807351f6bd 100644 --- a/carrera/fns.h +++ b/carrera/fns.h @@ -36,6 +36,7 @@ KMap* kmap(Page*); void kmapinit(void); void kmapinval(void); void kunmap(KMap*); +void links(void); void mmunewpage(Page*); void mouseintr(void); int newtlbpid(Proc*); diff --git a/ip/tcp.c b/ip/tcp.c index 7b9b839921361328b0c8ed1cb405c87c51e32231..3ae52523141a068f2591e389ada4e580f50fb126 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -1971,7 +1971,7 @@ void addreseq(Tcpctl *tcb, Tcp *seg, Block *bp, ushort length) { Reseq *rp, *rp1; - int i, x; + int i; rp = malloc(sizeof(Reseq)); if(rp == nil){ diff --git a/mpc/dat.h b/mpc/dat.h index e10a5675887b67c0d2b619ff165353913b45eec7..8512b4616dce1d8e4ddea76eb2298b6d298e13de 100644 --- a/mpc/dat.h +++ b/mpc/dat.h @@ -30,7 +30,6 @@ struct Lock ulong sr; Proc *p; ushort isilock; - ulong glare; }; struct Label diff --git a/pc/dat.h b/pc/dat.h index 8e757e16cf1933b3a1fdb774f2e09f526fdaec70..1cfc12ba3531be282a435b23c07d69b57c2425a9 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -28,7 +28,6 @@ struct Lock ulong pc; Proc *p; ushort isilock; - ulong glare; }; struct Label diff --git a/port/chan.c b/port/chan.c index 34df5ed46a72c55f1445198ad04bceb85fe7ba4e..4b2f015bb3622f5467a6a10dd404efbb30a028de 100644 --- a/port/chan.c +++ b/port/chan.c @@ -19,6 +19,7 @@ struct }chanalloc; #define SEP(c) ((c) == 0 || (c) == '/') +void cleancname(Cname*, int); int incref(Ref *r) @@ -426,6 +427,9 @@ domount(Chan *c) nc->mh = m; nc->xmh = m; incref(m); + cnameclose(nc->name); + nc->name = c->name; + incref(c->name); cclose(c); c = nc; poperror(); @@ -459,7 +463,16 @@ undomount(Chan *c) for(f = *h; f; f = f->hash) { for(t = f->mount; t; t = t->next) { if(eqchan(c, t->to, 1)) { + /* + * We want to come out on the left hand side of the mount + * point using the element of the union that we entered on. + * To do this, find the element that has a from name of + * c->name->s. + */ + if(strcmp(t->head->from->name->s, c->name->s) != 0) + continue; nc = cclone(t->head->from, 0); + /* don't need to update nc->name because c->name is same! */ cclose(c); c = nc; break; @@ -472,21 +485,6 @@ undomount(Chan *c) return c; } -int -walkname(Chan **cp, char *name, int domnt) -{ - Chan *c; - - if(walk(cp, name, domnt) < 0) - return -1; - c = *cp; - if(c->name == nil) - c->name = newcname(name); - else - c->name = addelem(c->name, name); - return 0; -} - int walk(Chan **cp, char *name, int domnt) { @@ -507,10 +505,19 @@ walk(Chan **cp, char *name, int domnt) ac->flag &= ~CCREATE; /* not inherited through a walk */ if(devtab[ac->type]->walk(ac, name) != 0) { - if(dotdot) - *cp = undomount(*cp); + /* walk succeeded: update name associated with *cp (ac) */ + c = *cp; + if(c->name == nil) + c->name = newcname(name); + else + c->name = addelem(c->name, name); + + if(dotdot){ + cleancname(c->name, c->name->s[0]=='#'); /* could be cheaper */ + *cp = undomount(c); + } if(domnt) - *cp = domount(*cp); + *cp = domount(c); return 0; } diff --git a/port/proc.c b/port/proc.c index dc38de3ced5c730fc3ef9158977fe0edb0aa8a8f..065debd095caed67925feb4cef7d373cf93c9722 100644 --- a/port/proc.c +++ b/port/proc.c @@ -201,7 +201,7 @@ loop: spllo(); for(;;){ idlehands(); - if((++(m->fairness) & 3) == 0){ + if((++(m->fairness) & 0x3) == 0){ /* * once in a while, run process that's been waiting longest * regardless of movetime @@ -235,7 +235,7 @@ loop: continue; for(; p; p = p->rnext){ if(p->mp == MACHP(m->machno) - || p->movetime < m->ticks) + || p->movetime < MACHP(0)->ticks) goto found; } } @@ -249,7 +249,7 @@ found: l = 0; for(p = rq->head; p; p = p->rnext){ - if(p->mp == MACHP(m->machno) || p->movetime < m->ticks) + if(p->mp == MACHP(m->machno) || p->movetime < MACHP(0)->ticks) break; l = p; } @@ -275,7 +275,7 @@ found: p->state = Scheding; if(p->mp != MACHP(m->machno)) - p->movetime = m->ticks + HZ/10; + p->movetime = MACHP(0)->ticks + HZ/10; p->mp = MACHP(m->machno); return p; } @@ -998,7 +998,7 @@ scheddump(void) print("rq%ld:", rq-runq); for(p = rq->head; p; p = p->rnext) print(" %lud(%lud, %lud)", p->pid, m->ticks - p->readytime, - m->ticks - p->movetime); + MACHP(0)->ticks - p->movetime); print("\n"); delay(150); } diff --git a/port/sysfile.c b/port/sysfile.c index 63eb9ce0e0592b2de21f3e071fb8228d398bd9c8..197af576c8d20d423f6b0407d1ec1a14b09a3b0f 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -147,9 +147,9 @@ syspipe(ulong *arg) nexterror(); } c[1] = cclone(c[0], 0); - if(walkname(&c[0], "data", 1) < 0) + if(walk(&c[0], "data", 1) < 0) error(Egreg); - if(walkname(&c[1], "data1", 1) < 0) + if(walk(&c[1], "data1", 1) < 0) error(Egreg); c[0] = d->open(c[0], ORDWR); c[1] = d->open(c[1], ORDWR); diff --git a/port/taslock.c b/port/taslock.c index 1c964cb3261cda77b29c0787c4ede9e403d97e8c..e4d9f3081cc66ab5c3e9cb7a960d313ac7c6c99a 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -35,7 +35,7 @@ lock(Lock *l) pc = getcallerpc(&l); -lockstats.locks++; + lockstats.locks++; if(tas(&l->key) == 0){ l->pc = pc; l->p = up; @@ -43,7 +43,7 @@ lockstats.locks++; return; } -lockstats.glare++; + lockstats.glare++; cansched = up != nil && up->state == Running; if(cansched){ oldpri = up->priority; @@ -53,7 +53,7 @@ lockstats.glare++; oldpri = 0; for(;;){ -lockstats.inglare++; + lockstats.inglare++; i = 0; while(l->key){ if(conf.nmach < 2 && cansched){ @@ -90,7 +90,7 @@ ilock(Lock *l) int cansched; pc = getcallerpc(&l); -lockstats.locks++; + lockstats.locks++; x = splhi(); if(tas(&l->key) == 0){ @@ -101,11 +101,7 @@ lockstats.locks++; return; } -lockstats.glare++; -if(l->glare++ > 10000){ -print("glare %lux\n", l); -l->glare = 0; -} + lockstats.glare++; cansched = up != nil && up->state == Running; if(cansched){ oldpri = up->priority; @@ -117,7 +113,7 @@ l->glare = 0; panic("ilock: no way out: pc %uX\n", pc); for(;;){ -lockstats.inglare++; + lockstats.inglare++; splx(x); while(l->key) ;