From e2c5e7270740c7a8f058aa0edcb75d2bab6bf95a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 1 Mar 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-03-01 --- gnot/l.s | 12 ++++++---- port/devmnt.c | 15 ++++++++++++- port/devwren.c | 57 ++++++++++++++++++++++++++--------------------- port/ipdat.h | 2 ++ port/proc.c | 3 --- port/stil.c | 19 +++++++++++++++- port/swap.c | 27 +++++++--------------- power/devhotrod.c | 34 ---------------------------- 8 files changed, 82 insertions(+), 87 deletions(-) diff --git a/gnot/l.s b/gnot/l.s index e79672792464a766d215fdbb042dc4b44b686891..1fc9b2105350fbd33a20113734c82ce18e7b1cf2 100644 --- a/gnot/l.s +++ b/gnot/l.s @@ -193,7 +193,8 @@ TEXT illegal(SB), $0 MOVL ((8+8)*BY2WD)(A7), A0 MOVL A0, USP MOVEM (A7), $0x7FFF - ADDL $((8+8+1)*BY2WD+BY2WD), A7 + ADDL $((8+8+1)*BY2WD), A7 + MOVL $0, (A7)+ RTE TEXT systrap(SB), $0 @@ -210,7 +211,8 @@ TEXT systrap(SB), $0 MOVL ((1+8+8)*BY2WD)(A7), A0 MOVL A0, USP MOVL ((1+8+6)*BY2WD)(A7), A6 - ADDL $((1+8+8+1)*BY2WD+BY2WD), A7 + ADDL $((1+8+8+1)*BY2WD), A7 + MOVL $0, (A7)+ RTE TEXT buserror(SB), $0 @@ -228,7 +230,8 @@ TEXT buserror(SB), $0 MOVL ((8+8)*BY2WD)(A7), A0 MOVL A0, USP MOVEM (A7), $0x7FFF - ADDL $((8+8+1)*BY2WD+BY2WD), A7 + ADDL $((8+8+1)*BY2WD), A7 + MOVL $0, (A7)+ RTE TEXT tacintr(SB), $0 /* level 1 */ @@ -307,7 +310,8 @@ retintr: MOVL ((8+8)*BY2WD)(A7), A0 MOVL A0, USP MOVEM (A7), $0x7FFF - ADDL $((8+8+1)*BY2WD+BY2WD), A7 + ADDL $((8+8+1)*BY2WD), A7 + MOVL $0, (A7)+ RTE GLOBL duarttimer+0(SB),$4 diff --git a/port/devmnt.c b/port/devmnt.c index 05ba90538eb1b7de2c209120d84270bfa22a6eea..9ecd15517e043a4fc452b3b073cda11acec981f5 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -73,6 +73,8 @@ enum Tagspace = 1, Flushspace = 64, Flushtag = 512, + + ALIGN = 256, /* Vme block mode alignment */ }; void @@ -81,6 +83,8 @@ mntreset(void) Mnt *me, *md; Mntrpc *re, *rd; ushort tag, ftag; + ulong p; + int i; mntalloc.mntarena = ialloc(conf.nmntdev*sizeof(Mnt), 0); mntalloc.mntfree = mntalloc.mntarena; @@ -99,13 +103,22 @@ mntreset(void) 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 */ + p = (ulong)ialloc(0, 0); + if(p&(ALIGN-1)) + ialloc(ALIGN-(p&(ALIGN-1)), 0); + + i = MAXRPC+(ALIGN-1); + i &= ~(ALIGN-1); + for(rd = mntalloc.rpcfree; rd < re; rd++) { rd->list = rd+1; rd->request.tag = tag++; rd->flushbase = ftag; rd->flushtag = ftag; ftag += Flushspace; - rd->rpc = ialloc(MAXRPC, 0); + rd->rpc = ialloc(i, 0); } re[-1].list = 0; diff --git a/port/devwren.c b/port/devwren.c index f2e4e0a19eceaab1a15b8aaacdc4a8fe84260b7c..6b79728aac820a5e90897ad2f13ce5cc771fb213 100644 --- a/port/devwren.c +++ b/port/devwren.c @@ -33,9 +33,11 @@ struct Partition struct Drive { + QLock; ulong bytes; /* bytes per block */ int npart; /* actual number of partitions */ int drive; + int ready; /* true if ever ready */ Partition p[Npart]; }; @@ -263,31 +265,34 @@ wrenpart(int dev) ulong n; int i; - if(scsiready(dev)){ + dp = &wren[dev]; + if(waserror()){ + qunlock(dp); + nexterror(); + } + qlock(dp); + if(!dp->ready){ + scsiready(dev); scsisense(dev, buf); - if(scsiready(dev)) - print("scsi %d.%d not ready: sense 0x%2.2ux, code 0x%2.2ux\n", - dev>>3, dev&7, buf[2], buf[12]); + if (scsicap(dev, buf)) + error(Eio); + dp->drive = dev; + dp->ready = 1; + + /* + * we always have a partition for the whole disk + * and one for the partition table + */ + dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]); + pp = &dp->p[0]; + strcpy(pp->name, "disk"); + pp->start = 0; + pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1; + pp++; + strcpy(pp->name, "partition"); + pp->start = dp->p[0].end - 1; + pp->end = dp->p[0].end; } - if(scsicap(dev, buf)) - error(Eio); - dp = &wren[dev]; - dp->drive = dev; - - /* - * we always have a partition for the whole disk - * and one for the partition table - */ - dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]); - pp = &dp->p[0]; - strcpy(pp->name, "disk"); - pp->start = 0; - pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1; - pp++; - strcpy(pp->name, "partition"); - pp->start = dp->p[0].end - 1; - pp->end = dp->p[0].end; - dp->npart = 2; /* * read partition table from disk, null terminate @@ -304,10 +309,10 @@ wrenpart(int dev) /* * parse partition table. */ + pp = &dp->p[2]; n = getfields(rawpart, line, Npart+1, '\n'); if(strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0){ for(i = 1; i < n; i++){ - pp++; if(getfields(line[i], field, 3, ' ') != 3) break; strncpy(pp->name, field[0], NAMELEN); @@ -315,9 +320,11 @@ wrenpart(int dev) pp->end = strtoul(field[2], 0, 0); if(pp->start > pp->end || pp->start >= dp->p[0].end) break; - dp->npart++; + pp++; } } + dp->npart = pp - dp->p; poperror(); scsifree(b); + qunlock(dp); } diff --git a/port/ipdat.h b/port/ipdat.h index 3719b681ebd70ae8824be0ba8906431f3b48a540..e19f672e62f8bdec0098d06ec460b309e05444f6 100644 --- a/port/ipdat.h +++ b/port/ipdat.h @@ -115,6 +115,8 @@ struct Ilcb /* Control block */ int slowtime; /* Slow time counter */ int fasttime; /* Retransmission timer */ int acktime; /* Acknowledge timer */ + int querytime; /* Query timer */ + int deathtime; /* Time to kill connection */ int rtt; /* Average round trip time */ ulong rttack; /* The ack we are waiting for */ diff --git a/port/proc.c b/port/proc.c index a0c54de2f4cd665fa724b50d6376ea4e0e2299fa..19cfd83bcbfa47e1ab21c449f1e8308315f6e7f5 100644 --- a/port/proc.c +++ b/port/proc.c @@ -65,9 +65,6 @@ schedinit(void) /* never returns */ if(p->state == Running) ready(p); else if(p->state == Moribund) { - /* - * The Grim Reaper lays waste the bodies of the dead - */ p->pid = 0; /* * Holding locks from pexit: diff --git a/port/stil.c b/port/stil.c index c2ee5414c62a8b74dfe794137b42361d83083155..2b898a4bf27b7d86b7b9cd04b30d47a5138ce426 100644 --- a/port/stil.c +++ b/port/stil.c @@ -28,10 +28,12 @@ enum Fasttime = 4*Iltickms, Acktime = 2*Iltickms, Ackkeepalive = 6000*Iltickms, + Querytime = 60*Iltickms, /* time between queries */ + Keepalivetime = 10*Querytime, /* keep alive time */ Defaultwin = 20, }; -#define Starttimer(s) {(s)->timeout = 0; (s)->fasttime = Fasttime;} +#define Starttimer(s) {(s)->timeout = 0; (s)->fasttime = Fasttime; } /* Packet dropping putnext for testing */ #define DPUTNEXT(q, b) if((MACHP(0)->ticks&7) != 3)PUTNEXT(q, b);else{freeb(b);print(".");} @@ -299,6 +301,8 @@ ilrcvmsg(Ipconv *ipc, Block *bp) ic->recvd = 0; ic->rstart = nhgetl(ih->ilid); ic->slowtime = Slowtime; + ic->querytime = Keepalivetime; + ic->deathtime = Keepalivetime; ic->window = Defaultwin; ilprocess(new, ih, bp); @@ -326,6 +330,8 @@ _ilprocess(Ipconv *s, Ilhdr *h, Block *bp) ack = nhgetl(h->ilack); ic = &s->ilctl; + ic->querytime = Keepalivetime; + ic->deathtime = Keepalivetime; switch(ic->state) { default: panic("il unknown state"); @@ -711,6 +717,17 @@ ilackproc(void *a) ic->acktime -= Iltickms; if(ic->acktime <= 0) ilsendctl(s, 0, Ilack, ic->next, ic->recvd); + ic->querytime -= Iltickms; + if(ic->querytime <= 0){ + ic->deathtime -= Querytime; + if(ic->deathtime < 0){ + ic->state = Ilclosed; + ilhangup(s, etime); + break; + } + ilsendctl(s, 0, Ilquerey, ic->next, ic->recvd); + ic->querytime = Querytime; + } if(ic->unacked == 0) { ic->timeout = 0; break; diff --git a/port/swap.c b/port/swap.c index 132d09b2e344100a014073588db118cd97e66213..4a168de3dfe02b4cdd3dfcb2b2796557dceaccd1 100644 --- a/port/swap.c +++ b/port/swap.c @@ -15,7 +15,7 @@ int canflush(Proc *p, Segment*); enum { - Maxpages = 500, /* Max number of pageouts per segment pass */ + Maxpages = 300, /* Max number of pageouts per segment pass */ }; Image swapimage; @@ -109,16 +109,14 @@ pager(void *junk) if(waserror()) panic("pager: os error\n"); + u->p->psstate = "Idle"; + sleep(&swapalloc.r, needpages, 0); + u->p->psstate = "Pageout"; + for(p = proctab(0); p < ep; p++) { if(p->state == Dead || p->kp) continue; - u->p->psstate = "Idle"; - sleep(&swapalloc.r, needpages, 0); - u->p->psstate = "Pageout"; - - if(p->state == Dead || p->kp) - continue; if(swapimage.c) { for(i = 0; i < NSEG; i++) if(s = p->seg[i]) { @@ -235,17 +233,6 @@ pagepte(int type, Segment *s, Page **pg) *pg = 0; break; case SG_DATA: - /* Unmodified data may be reverted to a demand load record if it - * is not the last page in the DSEG - */ -/* BUG: needs to check the last page - if((outp->modref&PG_MOD) == 0) { - putpage(outp); - *pg = 0; - break; - } -*/ - /* NO break */ case SG_BSS: case SG_STACK: case SG_SHARED: @@ -284,15 +271,17 @@ executeio(void) for(i = 0; i < ioptr; i++) { out = iolist[i]; +#ifdef asdf if(out->ref > 2) { lockpage(out); - if(out->ref > 2) { /* Page was reclaimed, abort io */ + if(out->ref > 2) { out->ref -= 2; unlockpage(out); continue; } unlockpage(out); } +#endif k = kmap(out); kaddr = (char*)VA(k); qlock(&c->wrl); diff --git a/power/devhotrod.c b/power/devhotrod.c index edcc7d76fe7e7e6fcfcde2edb96b6cb37a884ed7..6903f7026d727515781b31ab6c07048c0b8dd4fc 100644 --- a/power/devhotrod.c +++ b/power/devhotrod.c @@ -181,40 +181,6 @@ hotrodopen(Chan *c, int omode) hotwait(hmp); delay(100); print("reset\n"); - -#ifdef ENABMEMTEST - /* - * Issue test - */ - mp = &u->khot; - mp->cmd = Utest; - mp->param[0] = MP2VME(testbuf); - mp->param[1] = NTESTBUF; - hmp = hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot); - hotwait(hmp); - delay(100); - print("testing addr %lux size %ld\n", mp->param[0], mp->param[1]); - if(mp->param[0] == MP2VME(testbuf)){ - print("no way jose\n"); - unlock(&hp->busy); - error(Egreg); - } - - for(;;){ - print("-"); - mem(hp->addr, &hp->addr->ram[(mp->param[0]-0x40000)/sizeof(ulong)], mp->param[1]); - } -#endif -#ifdef ENABBUSTEST - /* - * Issue test - */ - mp = &u->khot; - mp->cmd = Ubus; - hmp = hotsend(hp, &((User*)(u->p->upage->pa|KZERO))->khot); - hotwait(hmp); -for(;;) ; -#endif } c->mode = openmode(omode); c->flag |= COPEN;