From 60cf3ab0d8cb7f519d16489d272fdf6e496b643f Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 5 Oct 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-10-05 --- pc/devfloppy.c | 2 +- pc/mmu.c | 13 +++++++++++-- pc/trap.c | 8 ++++++-- port/proc.c | 41 +++++++++++++++++++++-------------------- port/segment.c | 1 - 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/pc/devfloppy.c b/pc/devfloppy.c index 2bc9dc37b3add9ad02668e261810310282db235c..6809c2c30f86ec71af1bd7de9385881ac4f23fa5 100644 --- a/pc/devfloppy.c +++ b/pc/devfloppy.c @@ -633,7 +633,7 @@ floppysense(void) if(floppycmd() < 0) return -1; if(floppyresult() < 2){ -print("can't read sense response\n"); +/*print("can't read sense response\n");/**/ fl.confused = 1; return -1; } diff --git a/pc/mmu.c b/pc/mmu.c index 3f5bfe92c431455afb4967d0a0c95600f28ce126..33aef5a5956bca020d78a2c389bd3cfe18ea1d0d 100644 --- a/pc/mmu.c +++ b/pc/mmu.c @@ -297,6 +297,7 @@ putmmu(ulong va, ulong pa, Page *pg) ulong *pt; Proc *p; char err[64]; + int x; if(u==0) panic("putmmu"); @@ -313,8 +314,16 @@ putmmu(ulong va, ulong pa, Page *pg) * into it. */ if(p->mmutop == 0){ - p->mmutop = mmugetpage(0); - memmove((void*)p->mmutop->va, (void*)ktoppg.va, BY2PG); + /* + * N.B. The assignment to pg is neccessary. + * We can't assign to p->mmutop until after + * copying ktoppg into the new page since we might + * get scheded in this code and p->mmutop will be + * pointing to a bad map. + */ + pg = mmugetpage(0); + memmove((void*)pg->va, (void*)ktoppg.va, BY2PG); + p->mmutop = pg; } top = (ulong*)p->mmutop->va; diff --git a/pc/trap.c b/pc/trap.c index d0db2096aa93bd592f4672f665ade225d341d1ff..d9f75d4dfd7b578d6f57da9657723551678d9273 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -173,11 +173,15 @@ trap(Ureg *ur) { int v; int c; + static int spuriousfloppy; v = ur->trap; if(v>=256 || ivec[v] == 0){ - panic("bad trap type %d %lux %lux %lux\n", v, ur->pc, int0mask, int1mask); - return; + if(v == 10 && spuriousfloppy == 0){ + v = Floppyvec; + spuriousfloppy = 1; + }else + panic("bad trap type %d %lux %lux %lux\n", v, ur->pc, int0mask, int1mask); } /* diff --git a/port/proc.c b/port/proc.c index 5089e28b01a0fed757abb5c4facbc7f0ff06cf2d..af62434879631063a065d9e9c19e20b9a11d56ee 100644 --- a/port/proc.c +++ b/port/proc.c @@ -534,26 +534,27 @@ pexit(char *exitstr, int freemem) else wq->w.msg[0] = '\0'; - /* Find my parent */ - p = c->parent; - - lock(&p->exl); - /* My parent still alive */ - if(p->pid == c->parentpid && p->state != Broken && p->nwait < 128) { - p->nchild--; - p->time[TCUser] += c->time[TUser] + c->time[TCUser]; - p->time[TCSys] += c->time[TSys] + c->time[TCSys]; - - wq->next = p->waitq; - p->waitq = wq; - p->nwait++; - unlock(&p->exl); - - wakeup(&p->waitr); - } - else { - unlock(&p->exl); - freewaitq(wq); + if(c->kp == 0) { + /* Find my parent */ + p = c->parent; + lock(&p->exl); + /* My parent still alive */ + if(p->pid == c->parentpid && p->state != Broken && p->nwait < 128) { + p->nchild--; + p->time[TCUser] += c->time[TUser] + c->time[TCUser]; + p->time[TCSys] += c->time[TSys] + c->time[TCSys]; + + wq->next = p->waitq; + p->waitq = wq; + p->nwait++; + unlock(&p->exl); + + wakeup(&p->waitr); + } + else { + unlock(&p->exl); + freewaitq(wq); + } } if(!freemem) diff --git a/port/segment.c b/port/segment.c index 1b1571b62aac143373166ed5e5ae522c309c54c5..7ab3e89708ef2894df66271cafb7a1fb0876420b 100644 --- a/port/segment.c +++ b/port/segment.c @@ -346,7 +346,6 @@ ibrk(ulong addr, int seg) newtop = PGROUND(addr); newsize = (newtop-s->base)/BY2PG; if(newtop < s->top) { - print("down brk\n"); mfreeseg(s, newtop, (s->top-newtop)/BY2PG); qunlock(&s->lk); return 0;