From b289cd8b27e92b1ed3a777a6afb140228d1f662c Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 20 Jun 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-06-20 --- port/alloc.c | 55 ++++++++++------- port/chan.c | 70 ++++++++++------------ port/devarp.c | 4 +- port/devconc.c | 2 +- port/devcons.c | 6 -- port/devkprof.c | 2 +- port/devmnt.c | 156 ++++++++++++++++++++---------------------------- port/devscc.c | 7 ++- port/devsrv.c | 5 +- port/page.c | 36 +---------- port/portdat.h | 4 +- port/portfns.h | 3 - port/proc.c | 58 ++++-------------- ss/dat.h | 13 ---- ss/main.c | 19 +----- ss/trap.c | 9 +-- 16 files changed, 162 insertions(+), 287 deletions(-) diff --git a/port/alloc.c b/port/alloc.c index 48a04ec14c689c33285eda3bf80d93c6cae0ab6d..3ec7243526da279fa64a38f47c7f778c8d805768 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -13,7 +13,7 @@ enum Maxpow = 16, Nhole = 128, Magichole = 0xDeadBabe, - Magic2n = 0xBadC0c0a, + Magic2n = 0xFeedBeef, }; typedef struct Hole Hole; @@ -56,7 +56,8 @@ struct Bucket struct Arena { Lock; - Bucket *btab[Maxpow]; + Bucket *btab[Maxpow]; + int nbuck[Maxpow]; }; static Arena arena; @@ -226,32 +227,13 @@ xhole(ulong addr, ulong size) unlock(&xlists); } -void -xsummary(void) -{ - int i; - Hole *h; - - i = 0; - for(h = xlists.flist; h; h = h->link) - i++; - - print("%d holes free\n", i); - i = 0; - for(h = xlists.table; h; h = h->link) { - print("%.8lux %.8lux %d\n", h->addr, h->top, h->size); - i += h->size; - } - print("%d bytes free\n", i); -} - void* malloc(ulong size) { int pow; Bucket *bp; - for(pow = 1; pow < Maxpow; pow++) + for(pow = 3; pow < Maxpow; pow++) if(size <= (1<data, 0, size); return bp->data; } + arena.nbuck[pow]++; unlock(&arena); size = sizeof(Bucket)+(1<link) + i++; + + print("%d holes free\n", i); + i = 0; + for(h = xlists.table; h; h = h->link) { + print("%.8lux %.8lux %d\n", h->addr, h->top, h->size); + i += h->size; + } + print("%d bytes free\n", i); + for(i = 3; i < Maxpow; i++) { + if(arena.btab[i] == 0 && arena.nbuck[i] == 0) + continue; + nfree = 0; + for(k = arena.btab[i]; k; k = k->next) + nfree++; + print("%8d %4d %4d\n", 1<fid = i; - c->next = c+1; - } - c->next = 0; -} - void chandevreset(void) { @@ -75,30 +61,36 @@ Chan* newchan(void) { Chan *c; + int nfid; - for(;;) { - lock(&chanalloc); - if(c = chanalloc.free) { - chanalloc.free = c->next; - /* if you get an error before associating with a dev, - close calls rootclose, a nop */ - c->type = 0; - c->flag = 0; - c->ref = 1; - unlock(&chanalloc); - c->dev = 0; - c->offset = 0; - c->mnt = 0; - c->stream = 0; - c->aux = 0; - c->mchan = 0; - c->mqid = (Qid){0, 0}; - return c; - } - unlock(&chanalloc); - resrcwait("no chans\n"); + SET(nfid); + + lock(&chanalloc); + c = chanalloc.free; + if(c) + chanalloc.free = c->next; + else + nfid = ++chanalloc.fid; + unlock(&chanalloc); + + if(c == 0) { + c = smalloc(sizeof(Chan)); + c->fid = nfid; } - return 0; /* not reached */ + + /* if you get an error before associating with a dev, + close calls rootclose, a nop */ + c->type = 0; + c->flag = 0; + c->ref = 1; + c->dev = 0; + c->offset = 0; + c->mnt = 0; + c->stream = 0; + c->aux = 0; + c->mchan = 0; + c->mqid = (Qid){0, 0}; + return c; } void diff --git a/port/devarp.c b/port/devarp.c index d9e70b4e3338f8b6ec1dc7784cc68fe905df0427..16024a80d5871d9a5d3126153a8a56cb46841a68 100644 --- a/port/devarp.c +++ b/port/devarp.c @@ -94,8 +94,8 @@ arpreset(void) { Arpcache *ap, *ep; - arp = (Arpcache *)ialloc(sizeof(Arpcache) * conf.arp, 0); - arphash = (Arpcache **)ialloc(sizeof(Arpcache *) * Arphashsize, 0); + arp = xalloc(sizeof(Arpcache) * conf.arp); + arphash = (Arpcache **)xalloc(sizeof(Arpcache *) * Arphashsize); ep = &arp[conf.arp]; for(ap = arp; ap < ep; ap++) { diff --git a/port/devconc.c b/port/devconc.c index 2ab9fe4e2d4da5fba015faadf2d4ecfb42b8c681..8a8a48869ed87fcfc487c29d0bf9ff944cdf6936 100644 --- a/port/devconc.c +++ b/port/devconc.c @@ -285,7 +285,7 @@ concdevstclose(Queue *q) q->ptr = 0; q->other->ptr = 0; dp->rq = 0; - streamexit(cp->s, 0); + streamexit(cp->s); qunlock(cp); } diff --git a/port/devcons.c b/port/devcons.c index 44d207c172981a0276cbc057ffe82592a64a9969..de36bde7c5626203d1891dda1f6a6101a14924c4 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -234,15 +234,9 @@ echo(Rune r, char *buf, int n) case 'd': consdebug(); return; - case 'm': - mntdump(); - return; case 'p': procdump(); return; - case 'q': - dumpqueues(); - return; case 'r': exit(); break; diff --git a/port/devkprof.c b/port/devkprof.c index f2805e581e35a198e89469d41d39b06f0b848cdf..5f397b9b6993e6163126b0f4ec2b9e7919d9b733 100644 --- a/port/devkprof.c +++ b/port/devkprof.c @@ -42,7 +42,7 @@ kprofreset(void) kprof.maxpc = (ulong)etext; kprof.nbuf = (kprof.maxpc-kprof.minpc) >> LRES; n = kprof.nbuf*SZ; - kprof.buf = ialloc(n, 0); + kprof.buf = xalloc(n); kproftab[0].length = n; if(SZ != sizeof kprof.buf[0]) panic("kprof size"); diff --git a/port/devmnt.c b/port/devmnt.c index 3f3a4a731a28aa548e8029ad8864adea39159587..1871ff35c60a52da852a11e648c363d832decd32 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -7,8 +7,6 @@ #include "devtab.h" typedef struct Mntrpc Mntrpc; -typedef struct Mnt Mnt; - struct Mntrpc { Mntrpc *list; /* Free/pending list */ @@ -40,11 +38,11 @@ struct Mnt struct Mntalloc { Lock; - Mnt *mntfree; - Mnt *mntarena; + Mnt *list; /* Mount devices in used */ + Mnt *mntfree; /* Free list */ Mntrpc *rpcfree; - Mntrpc *rpcarena; int id; + int rpctag; }mntalloc; #define MAXRPC (MAXFDATA+MAXMSG) @@ -71,6 +69,7 @@ void mntpntfree(Mnt*); enum { Tagspace = 1, + Tagfls = 0x8000, Tagend = 0xfffe, ALIGN = 256, /* Vme block mode alignment */ @@ -79,39 +78,8 @@ enum void mntreset(void) { - Mnt *me, *md; - Mntrpc *re, *rd; - ushort tag; - ulong p; - int i; - - mntalloc.mntarena = ialloc(conf.nmntdev*sizeof(Mnt), 0); - mntalloc.mntfree = mntalloc.mntarena; - me = &mntalloc.mntfree[conf.nmntdev]; - - mntalloc.rpcfree = ialloc(conf.nmntbuf*sizeof(Mntrpc), 0); - mntalloc.rpcarena = mntalloc.rpcfree; - re = &mntalloc.rpcfree[conf.nmntbuf]; - - /* - * Align mount buffers to 256 byte boundaries - * so we can use burst mode vme transfers - */ - tag = Tagspace; - for(rd = mntalloc.rpcfree; rd < re; rd++) { - rd->list = rd+1; - rd->request.tag = tag++; - rd->rpc = iallocspan(MAXRPC, ALIGN, 0); - } - re[-1].list = 0; - for(md = mntalloc.mntfree; md < me; md++){ - md->list = md+1; - md->flushbase = tag; - md->flushtag = tag; - } - me[-1].list = 0; - mntalloc.id = 1; + mntalloc.rpctag = Tagspace; } void @@ -122,7 +90,7 @@ mntinit(void) Chan* mntattach(char *muxattach) { - Mnt *m, *e; + Mnt *m; Chan *c; struct bogus{ Chan *chan; @@ -131,11 +99,14 @@ mntattach(char *muxattach) }bogus; bogus = *((struct bogus *)muxattach); - e = &mntalloc.mntarena[conf.nmntdev]; - for(m = mntalloc.mntarena; m < e; m++) { - if(m->c == bogus.chan && m->id) { + c = bogus.chan; + + lock(&mntalloc); + for(m = mntalloc.list; m; m = m->list) { + if(m->c == c && m->id) { lock(m); - if(m->id && m->ref > 0 && m->c == bogus.chan) { + if(m->id && m->ref > 0 && m->c == c) { + unlock(&mntalloc); m->ref++; unlock(m); return mattach(m, bogus.spec, bogus.serv); @@ -143,29 +114,36 @@ mntattach(char *muxattach) unlock(m); } } - lock(&mntalloc); - if(mntalloc.mntfree == 0) { - unlock(&mntalloc); - exhausted("mount devices"); - } m = mntalloc.mntfree; - mntalloc.mntfree = m->list; + if(m != 0) + mntalloc.mntfree = m->list; + else { + m = malloc(sizeof(Mnt)); + if(m == 0) { + unlock(&mntalloc); + exhausted("mount devices"); + } + m->flushbase = Tagfls; + m->flushtag = Tagfls; + } + m->list = mntalloc.list; + mntalloc.list = m; m->id = mntalloc.id++; lock(m); unlock(&mntalloc); + m->ref = 1; m->queue = 0; m->rip = 0; - m->c = bogus.chan; + m->c = c; m->c->flag |= CMSG; m->blocksize = MAXFDATA; - switch(devchar[m->c->type]) { default: m->mux = 0; break; - case 'H': /* Cyclone */ + case 'C': /* Cyclone */ m->mux = 1; break; } @@ -195,7 +173,7 @@ mattach(Mnt *m, char *spec, char *serv) lock(&mntalloc); c->dev = mntalloc.id++; unlock(&mntalloc); - c->mntindex = m-mntalloc.mntarena; + c->mntptr = m; if(waserror()){ mntfree(r); @@ -442,7 +420,18 @@ mntdoclunk(Mnt *m, Mntrpc *r) void mntpntfree(Mnt *m) { + Mnt *f, **l; + lock(&mntalloc); + l = &mntalloc.list; + for(f = *l; f; f = f->list) { + if(f == m) { + *l = m->list; + break; + } + l = &f->list; + } + m->list = mntalloc.mntfree; mntalloc.mntfree = m; unlock(&mntalloc); @@ -538,17 +527,21 @@ mntrdwr(int type, Chan *c, void *buf, long n, ulong offset) void mountrpc(Mnt *m, Mntrpc *r) { - r->reply.tag = 0; /* safety checks */ + r->reply.tag = 0; /* poison the old values */ r->reply.type = 4; + mountio(m, r); if(r->reply.type == Rerror) error(r->reply.ename); + if(r->reply.type == Rflush) error(Eintr); if(r->reply.type != r->request.type+1) { - print("devmnt: mismatched reply 0x%lux T%d R%d tags req %d fls %d rep %d\n", - r, r->request.type, r->reply.type, r->request.tag, r->flushtag, r->reply.tag); + print("mnt: mismatched reply 0x%lux T%d R%d tags req %d fls %d rep %d\n", + r, r->request.type, r->reply.type, r->request.tag, + r->flushtag, r->reply.tag); + error(Emountrpc); } } @@ -744,19 +737,23 @@ mntralloc(void) { Mntrpc *new; - for(;;) { - lock(&mntalloc); - if(new = mntalloc.rpcfree) { - mntalloc.rpcfree = new->list; + lock(&mntalloc); + new = mntalloc.rpcfree; + if(new != 0) + mntalloc.rpcfree = new->list; + else { + new = xalloc(sizeof(Mntrpc)+MAXRPC); + if(new == 0) { unlock(&mntalloc); - new->done = 0; - new->flushed = 0; - return new; + exhausted("mount rpc buffer"); } - unlock(&mntalloc); - resrcwait("no mount buffers"); + new->rpc = (char*)new+sizeof(Mntrpc); + new->request.tag = mntalloc.rpctag++; } - return 0; /* not reached */ + unlock(&mntalloc); + new->done = 0; + new->flushed = 0; + return new; } void @@ -793,9 +790,9 @@ mntchk(Chan *c) { Mnt *m; - m = &mntalloc.mntarena[c->mntindex]; + m = c->mntptr; /* Was it closed and reused ? */ - if(m->id == 0 || m->id >= c->dev) + if(m->id == 0 || m->id >= c->dev) /* Sanity check */ error(Eshutdown); return m; } @@ -814,28 +811,3 @@ rpcattn(Mntrpc *r) { return r->done || r->m->rip == 0; } - -void -mntdump(void) -{ - Mnt *me, *m; - Mntrpc *re, *r; - - me = &mntalloc.mntarena[conf.nmntdev]; - for(m = mntalloc.mntarena; m < me; m++) { - if(m->ref == 0) - continue; - print("mount %d: mux %d queue %lux rip 0x%lux %d %s\n", - m->id, m->mux, m->queue, m->rip, - m->rip ? m->rip->pid : 0, m->rip ? m->rip->text : "no"); - } - print("rpcfree 0x%lux\n", mntalloc.rpcfree); - re = &mntalloc.rpcarena[conf.nmntbuf]; - for(r = mntalloc.rpcarena; r < re; r++) - print("%.8lux %.8lux T%d R%d tags req %d fls %d rep %d d %d f %d\n", - r, r->list, r->request.type, r->reply.type, - r->request.tag, r->flushtag, r->reply.tag, - r->done, r->flushed); - -} - diff --git a/port/devscc.c b/port/devscc.c index 55c9b65f90852c7d6dac4e8644a4940f6350ed2d..3cdb448e3603534a594b03d5264c110fe9fc8fb7 100644 --- a/port/devscc.c +++ b/port/devscc.c @@ -298,6 +298,7 @@ sccsetup0(SCC *sp) sp->sticky[5] = TxEna | Tx8bits; sccwrreg(sp, 5, 0); } + void sccsetup(void *addr, ulong freq) { @@ -309,13 +310,13 @@ sccsetup(void *addr, ulong freq) /* * allocate a structure, set port addresses, and setup the line */ - sp = ialloc(sizeof(SCC), 0); + sp = xalloc(sizeof(SCC)); scc[nscc] = sp; sp->ptr = &dev->ptra; sp->data = &dev->dataa; sp->freq = freq; sccsetup0(sp); - sp = ialloc(sizeof(SCC), 0); + sp = xalloc(sizeof(SCC)); scc[nscc+1] = sp; sp->ptr = &dev->ptrb; sp->data = &dev->datab; @@ -647,7 +648,7 @@ sccreset(void) int i; Dirtab *dp; - sccdir = ialloc(2 * nscc * sizeof(Dirtab), 0); + sccdir = xalloc(2 * nscc * sizeof(Dirtab)); dp = sccdir; for(i = 0; i < nscc; i++){ /* 2 directory entries per port */ diff --git a/port/devsrv.c b/port/devsrv.c index 3185daa7d25df97a04c7b359a72599ebb900741c..2681aa96e215e44a5d7e6f99eadee21b7392ae57 100644 --- a/port/devsrv.c +++ b/port/devsrv.c @@ -7,7 +7,7 @@ #include "devtab.h" -typedef struct Srv Srv; +typedef struct Srv Srv; struct Srv{ char name[NAMELEN]; char owner[NAMELEN]; @@ -196,8 +196,8 @@ srvwrite(Chan *c, void *va, long n, ulong offset) memmove(buf, va, n); /* so we can NUL-terminate */ buf[n] = 0; fd = strtoul(buf, 0, 0); - f = u->p->fgrp; + f = u->p->fgrp; lock(f); if(waserror()){ unlock(f); @@ -218,6 +218,7 @@ srvwrite(Chan *c, void *va, long n, ulong offset) i = c->qid.path; if(srv[i].chan != c) /* already been written to */ error(Egreg); + srv[i].chan = c1; unlock(&srvlk); poperror(); diff --git a/port/page.c b/port/page.c index 0c2230e07c53ed49a29ea9e0ec36a54cce163a12..489d3dfabeadb13eb07712ebfaaa851f058c08df 100644 --- a/port/page.c +++ b/port/page.c @@ -8,13 +8,6 @@ #define PGHFUN(x, y) (((ulong)x^(ulong)y)%PGHSIZE) #define pghash(s) palloc.hash[PGHFUN(s->image, p->daddr)] -struct Ptealloc -{ - Lock; - Pte *free; - int pages; -}ptealloclk; - static Lock pglock; struct Palloc palloc; @@ -361,31 +354,10 @@ Pte* ptealloc(void) { Pte *new; - int i, n; - KMap *k; - - lock(&ptealloclk); - while(ptealloclk.free == 0) { - unlock(&ptealloclk); - - k = kmap(newpage(1, 0, 0)); - new = (Pte*)VA(k); - n = (BY2PG/sizeof(Pte))-1; - for(i = 0; i < n; i++) - new[i].next = &new[i+1]; - lock(&ptealloclk); - ptealloclk.pages++; - new[i].next = ptealloclk.free; - ptealloclk.free = new; - } - - new = ptealloclk.free; - ptealloclk.free = new->next; - unlock(&ptealloclk); + new = smalloc(sizeof(Pte)); new->first = &new->pages[PTEPERTAB]; new->last = new->pages; - return new; } @@ -410,11 +382,7 @@ freepte(Segment *s, Pte *p) *pg = 0; } } - - lock(&ptealloclk); - p->next = ptealloclk.free; - ptealloclk.free = p; - unlock(&ptealloclk); + free(p); } /* Multiplex a hardware lock for per page manipulations */ diff --git a/port/portdat.h b/port/portdat.h index 44b4b39fc63e7b768711c8bcb22033470b6ac54b..354a01549b6a4550bd1373bb6bfb7c5000cf1850 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -15,6 +15,7 @@ typedef struct IOQ IOQ; typedef struct KIOQ KIOQ; typedef struct List List; typedef struct Mount Mount; +typedef struct Mnt Mnt; typedef struct Mhead Mhead; typedef struct Netinf Netinf; typedef struct Netprot Netprot; @@ -158,7 +159,7 @@ struct Chan union { void *aux; Qid pgrpid; /* for #p/notepg */ - int mntindex; /* for devmnt */ + Mnt *mntptr; /* for devmnt */ }; Chan *mchan; /* channel to mounted server */ Qid mqid; /* qid of root of mount point */ @@ -608,6 +609,7 @@ struct Queue struct Stream { QLock; /* structure lock */ + Stream *next; short inuse; /* number of processes in stream */ short opens; /* number of processes with stream open */ ushort hread; /* number of reads after hangup */ diff --git a/port/portfns.h b/port/portfns.h index 69fb0b475927abf7dfe3f61c1743f8d5c28b2913..82a07cb265ec36198055ef6e5a6288b5add2a728 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -15,7 +15,6 @@ int canqlock(QLock*); void chandevinit(void); void chandevreset(void); void chanfree(Chan*); -void chaninit(void); void checkalarms(void); void clock(Ureg*); Chan* clone(Chan*, Chan*); @@ -75,7 +74,6 @@ int freebroken(void); void freechan(Chan*); void freepte(Segment*, Pte*); void freesegs(int); -void freewaitq(Waitq*); Block* getb(Blist*); int getc(IOQ*); void getcolor(ulong, ulong*, ulong*, ulong*); @@ -139,7 +137,6 @@ Pgrp* newpgrp(void); Proc* newproc(void); void newqinfo(Qinfo*); Segment* newseg(int, ulong, ulong); -Waitq* newwaitq(void); char* nextelem(char*, char*); void nexterror(void); int nodelims(Stream*); diff --git a/port/proc.c b/port/proc.c index ca1f45f62c5fba105c76aaa9763875ce9e5f14f1..f8b2c7ce140ecb5f0e3aacc58f1d47772b1addba 100644 --- a/port/proc.c +++ b/port/proc.c @@ -65,6 +65,7 @@ schedinit(void) /* never returns */ else if(p->state == Moribund) { p->pid = 0; + p->state = Dead; /* * Holding locks from pexit: * procalloc, debug, palloc @@ -79,8 +80,6 @@ schedinit(void) /* never returns */ unlock(&palloc); qunlock(&p->debug); unlock(&procalloc); - - p->state = Dead; } p->mach = 0; } @@ -399,7 +398,6 @@ postnote(Proc *p, int dolock, char *n, int flag) up = u; USED(k); - if(flag!=NUser && (up->notify==0 || up->notified)) up->nnote = 0; /* force user's hand */ @@ -527,7 +525,7 @@ pexit(char *exitstr, int freemem) if((p = c->parent) == 0) panic("boot process died"); - wq = newwaitq(); + wq = smalloc(sizeof(Waitq)); readnum(0, wq->w.pid, NUMSIZE, c->pid, NUMSIZE); utime = c->time[TUser] + c->time[TCUser]; stime = c->time[TSys] + c->time[TCSys]; @@ -545,7 +543,8 @@ pexit(char *exitstr, int freemem) lock(&p->exl); /* My parent still alive, processes are limited to 128 Zombies to - * prevent badly written daemon consuming all the wait records */ + * prevent a badly written daemon lots of wait records + */ if(p->pid == c->parentpid && p->state != Broken && p->nwait < 128) { p->nchild--; p->time[TCUser] += utime; @@ -560,7 +559,7 @@ pexit(char *exitstr, int freemem) } else { unlock(&p->exl); - freewaitq(wq); + free(wq); } } @@ -580,7 +579,7 @@ pexit(char *exitstr, int freemem) for(f = c->waitq; f; f = next) { next = f->next; - freewaitq(f); + free(f); } /* @@ -637,15 +636,13 @@ pwait(Waitmsg *w) if(w) memmove(w, &wq->w, sizeof(Waitmsg)); cpid = atoi(wq->w.pid); - freewaitq(wq); + free(wq); return cpid; } Proc* proctab(int i) { -if((i < 0) || (i >= conf.nproc)) - panic("proctab(%d)\n", i); return &procalloc.arena[i]; } @@ -660,7 +657,8 @@ procdump(void) if(p->state != Dead){ print("%d:%s %s upc %lux %s ut %ld st %ld r %lux qpc %lux\n", p->pid, p->text, p->user, p->pc, - statename[p->state], p->time[0], p->time[1], p->r, p->qlockpc); + statename[p->state], p->time[0], + p->time[1], p->r, p->qlockpc); } } } @@ -754,10 +752,12 @@ procctl(Proc *p) case Proc_exitme: spllo(); /* pexit has locks in it */ pexit("Killed", 1); + case Proc_traceme: if(u->nnote == 0) return; /* No break */ + case Proc_stopme: p->procctl = 0; state = p->psstate; @@ -800,39 +800,3 @@ exhausted(char *resource) sprint(buf, "no free %s", resource); error(buf); } - -Waitq * -newwaitq(void) -{ - Waitq *wq, *e, *f; - - for(;;) { - lock(&waitqalloc); - if(wq = waitqalloc.free) { - waitqalloc.free = wq->next; - unlock(&waitqalloc); - return wq; - } - unlock(&waitqalloc); - - wq = (Waitq*)VA(kmap(newpage(0, 0, 0))); - e = &wq[(BY2PG/sizeof(Waitq))-1]; - for(f = wq; f < e; f++) - f->next = f+1; - - lock(&waitqalloc); - e->next = waitqalloc.free; - waitqalloc.free = wq; - unlock(&waitqalloc); - } - return 0; /* not reached */ -} - -void -freewaitq(Waitq *wq) -{ - lock(&waitqalloc); - wq->next = waitqalloc.free; - waitqalloc.free = wq; - unlock(&waitqalloc); -} diff --git a/ss/dat.h b/ss/dat.h index cbf74fa221a5b204f0b6a5470a7f19c581bbbc63..62d3396563de243d845d39e9945c42d3b9b7c9be 100644 --- a/ss/dat.h +++ b/ss/dat.h @@ -59,30 +59,19 @@ struct Conf { int nmach; /* processors */ int nproc; /* processes */ - int npgrp; /* process groups */ ulong npage0; /* total physical pages of memory, bank 0 */ ulong npage1; /* total physical pages of memory, bank 1 */ ulong base0; /* base of bank 0 */ ulong base1; /* base of bank 1 */ ulong npage; /* total physical pages of memory */ - ulong nseg; /* number of segments */ ulong nimage; /* number of page cache image headers */ - ulong npagetab; /* number of pte tables */ ulong nswap; /* number of swap blocks */ ulong upages; /* number of user pages */ - int nalarm; /* alarms */ - int nchan; /* channels */ int nenv; /* distinct environment values */ int nenvchar; /* environment text storage */ int npgenv; /* environment files per process group */ - int nmtab; /* mounted-upon channels per process group */ - int nmount; /* mounts */ - int nmntdev; /* mounted devices (devmnt.c) */ - int nmntbuf; /* buffers for devmnt.c messages */ - int nmnthdr; /* headers for devmnt.c messages */ int nstream; /* streams */ int nqueue; /* stream queues */ - int nblock; /* stream blocks */ int nsrv; /* public servers (devsrv.c) */ int nbitmap; /* bitmap structs (devbit.c) */ int nbitbyte; /* bytes of bitmap data (devbit.c) */ @@ -91,8 +80,6 @@ struct Conf int nurp; /* max urp conversations */ int nasync; /* number of async protocol modules */ int npipe; /* number of pipes */ - int nservice; /* number of services */ - int nfsyschan; /* number of filsys open channels */ int copymode; /* 0 is copy on write, 1 is copy on reference */ ulong ipif; /* Ip protocol interfaces */ ulong ip; /* Ip conversations per interface */ diff --git a/ss/main.c b/ss/main.c index 24a457a5c3016d4f75d088357836910e1840aaba..c95dd8f4860873d0e053f142d000656159b7a01f 100644 --- a/ss/main.c +++ b/ss/main.c @@ -35,7 +35,6 @@ main(void) intrinit(); procinit0(); initseg(); - chaninit(); chandevreset(); streaminit(); userinit(); @@ -206,28 +205,16 @@ confinit(void) conf.upages = 1400; - mul = 1; - if(conf.npage1 > 0) - mul = 2; + mul = conf.upages/700; + conf.nproc = 50*mul; - conf.npgrp = 12*mul; - conf.nseg = conf.nproc*4; - conf.npagetab = conf.nseg*2; conf.nswap = 4096; conf.nimage = 50; - conf.nalarm = 1000; - conf.nchan = 200*mul; conf.nenv = 100*mul; conf.nenvchar = 8000*mul; conf.npgenv = 200*mul; - conf.nmtab = 50*mul; - conf.nmount = 80*mul; - conf.nmntdev = 10*mul; - conf.nmntbuf = conf.nmntdev+3; - conf.nmnthdr = 2*conf.nmntdev; conf.nstream = 40 + 32*mul; conf.nqueue = 5 * conf.nstream; - conf.nblock = 24 * conf.nstream; conf.nsrv = 16*mul; /* was 32 */ conf.nbitmap = 300*mul; conf.nbitbyte = 300*1024*mul; @@ -236,8 +223,6 @@ confinit(void) conf.nurp = 32; conf.nasync = 1; conf.npipe = conf.nstream/2; - conf.nservice = 3*mul; /* was conf.nproc/5 */ - conf.nfsyschan = 31 + conf.nchan/20; conf.copymode = 0; /* copy on write */ conf.ipif = 8; conf.ip = 64; diff --git a/ss/trap.c b/ss/trap.c index 92d1d4b46fe20c4903be1883ffc1f040b6fcdf18..d18c596aee509ceec3bc69b2b06e1d8b27676130 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -376,16 +376,16 @@ syscall(Ureg *aur) ret = -1; if(!waserror()){ if(r7 >= sizeof systab/BY2WD){ - pprint("bad sys call number %d pc %lux\n", r7, ((Ureg*)UREGADDR)->pc); + pprint("bad sys call number %d pc %lux\n", r7, ur->pc); msg = "sys: bad sys call"; - Bad: postnote(u->p, 1, msg, NDebug); error(Ebadarg); } if(sp & (BY2WD-1)){ - pprint("odd sp in sys call pc %lux sp %lux\n", ((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp); + pprint("odd sp in sys call pc %lux sp %lux\n", ur->pc, ur->sp); msg = "sys: odd stack"; - goto Bad; + postnote(u->p, 1, msg, NDebug); + error(Ebadarg); } if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(1+MAXSYSARG)*BY2WD)) validaddr(sp, ((1+MAXSYSARG)*BY2WD), 0); @@ -393,6 +393,7 @@ syscall(Ureg *aur) ret = (*systab[r7])((ulong*)(sp+1*BY2WD)); poperror(); } + ur->pc += 4; ur->npc = ur->pc+4; u->nerrlab = 0;