| plan 9 kernel history: overview | file list | diff list |
1996/0426/port/proc.c (diff list | history)
| 1990/0227/sys/src/9/port/proc.c:231,237 – 1990/03013/sys/src/9/port/proc.c:231,237 (short | long) | ||
|
Print both pids involved in double-sleep.
rsc Mon Mar 20 17:13:58 2006 | ||
| 1990/0227 | */ p = u->p; if(r->p) | |
| 1990/03013 | print("double sleep %d %d\n", r->p->pid, p->pid); | |
| 1990/0227 | p->r = r; p->wokeup = 0; p->state = Wakeme; | |
| 1990/03013/sys/src/9/port/proc.c:165,170 – 1990/03081/sys/src/9/port/proc.c:165,172 (short | long) | ||
|
Use c to as current process instead of u->p. Add explicit process hierarchy a la Unix.
rsc Mon Mar 20 17:13:58 2006 | ||
| 1990/0227 | unlock(&procalloc); p->mach = 0; p->qnext = 0; | |
| 1990/03081 | p->kid = 0; p->sib = 0; | |
| 1990/0227 | p->nchild = 0; p->child = 0; p->exiting = 0; | |
| 1990/03013/sys/src/9/port/proc.c:339,351 – 1990/03081/sys/src/9/port/proc.c:341,354 | ||
| 1990/0227 | { char status[64]; ulong mypid; | |
| 1990/03081 | Proc *p, *c, *k, *l; | |
| 1990/0227 | Waitmsg w; int n; | |
| 1990/03081 | Chan *ch; | |
| 1990/0227 | ulong *up, *ucp, *wp; | |
| 1990/03081 | c = u->p; mypid = c->pid; | |
| 1990/0227 | if(s) strcpy(status, s); else | |
| 1990/03013/sys/src/9/port/proc.c:352,403 – 1990/03081/sys/src/9/port/proc.c:355,406 | ||
| 1990/0227 | status[0] = 0; if(freemem){ freesegs(-1); | |
| 1990/03081 | closepgrp(c->pgrp); | |
| 1990/0227 | close(u->dot); } for(n=0; n<=u->maxfd; n++) | |
| 1990/03081 | if(ch = u->fd[n]) /* assign = */ close(ch); | |
| 1990/0227 | /* * Any of my children exiting? */ | |
| 1990/03081 | while(c->nchild){ lock(&c->wait.queue); if(canlock(&c->wait.use)){ /* no child is exiting */ c->exiting = 1; unlock(&c->wait.use); unlock(&c->wait.queue); | |
| 1990/0227 | break; }else{ /* must wait for child */ | |
| 1990/03081 | unlock(&c->wait.queue); | |
| 1990/0227 | pwait(0); } } | |
| 1990/03081 | c->time[TReal] = MACHP(0)->ticks - c->time[TReal]; | |
| 1990/0227 | /* * Tell my parent */ | |
| 1990/03081 | p = c->parent; | |
| 1990/0227 | if(p == 0) goto out; qlock(&p->wait); lock(&p->wait.queue); | |
| 1990/03081 | if(p->pid==c->parentpid && !p->exiting){ | |
| 1990/0227 | w.pid = mypid; strcpy(w.msg, status); wp = &w.time[TUser]; | |
| 1990/03081 | up = &c->time[TUser]; ucp = &c->time[TCUser]; | |
| 1990/0227 | *wp++ = (*up++ + *ucp++)*MS2HZ; *wp++ = (*up++ + *ucp )*MS2HZ; *wp = (*up )*MS2HZ; | |
| 1990/03081 | p->child = c; | |
| 1990/0227 | /* * Pass info through back door, to avoid huge Proc's */ | |
| 1990/03081 | p->waitmsg = (Waitmsg*)(c->upage->pa|(((ulong)&w)&(BY2PG-1))|KZERO); c->state = Exiting; | |
| 1990/0227 | if(p->state == Inwait) ready(p); unlock(&p->wait.queue); | |
| 1990/03013/sys/src/9/port/proc.c:408,422 – 1990/03081/sys/src/9/port/proc.c:411,471 | ||
| 1990/0227 | } out: if(!freemem){ | |
| 1990/03081 | c->state = Broken; | |
| 1990/0227 | sched(); /* until someone lets us go */ freesegs(-1); | |
| 1990/03081 | closepgrp(c->pgrp); | |
| 1990/0227 | close(u->dot); } | |
| 1990/03081 | /* * Rearrange inheritance hierarchy * 1. my children's pop is now my pop */ lock(&c->kidlock); p = c->pop; if(k = c->kid) /* assign = */ do{ k->pop = p; k = k->sib; }while(k != c->kid); /* * 2. cut me from pop's tree */ if(p == 0) /* init process only; fix pops */ goto done; lock(&p->kidlock); k = p->kid; while(k->sib != c) k = k->sib; if(k == c) p->kid = 0; else{ if(p->kid == c) p->kid = c->sib; k->sib = c->sib; } /* * 3. pass my children (pop's grandchildren) to pop */ if(k = c->kid){ /* assign = */ if(p->kid == 0) p->kid = k; else{ l = k->sib; k->sib = p->kid->sib; p->kid->sib = l; } } unlock(&p->kidlock); done: unlock(&c->kidlock); | |
| 1990/0227 | lock(&procalloc); /* sched() can't do this */ | |
| 1990/03081 | lock(&c->debug); /* sched() can't do this */ c->state = Moribund; | |
| 1990/0227 | sched(); /* never returns */ } | |
| 1990/03081/sys/src/9/port/proc.c:167,172 – 1990/0309/sys/src/9/port/proc.c:167,173 (short | long) | ||
|
Initialize p->pop in newproc.
rsc Mon Mar 20 17:13:58 2006 | ||
| 1990/0227 | p->qnext = 0; | |
| 1990/03081 | p->kid = 0; p->sib = 0; | |
| 1990/0309 | p->pop = 0; | |
| 1990/0227 | p->nchild = 0; p->child = 0; p->exiting = 0; | |
| 1990/0309/sys/src/9/port/proc.c:195,208 – 1990/03091/sys/src/9/port/proc.c:195,209 (short | long) | ||
|
Allocate process locks all at once rather than on-demand at possibly bad times.
(See power/lock.c)
Code rearrangement: wakeme, twakeme.
| ||
| 1990/0227 | Proc *p; int i; | |
| 1990/03091 | for(i=0; i<conf.nproc-1; i++,p++){ lock(p); /* allocate now, not during wakeup */ unlock(p); | |
| 1990/0227 | p->qnext = p+1; | |
| 1990/03091 | } | |
| 1990/0227 | p->qnext = 0; } | |
| 1990/0309/sys/src/9/port/proc.c:288,293 – 1990/03091/sys/src/9/port/proc.c:289,307 | ||
| 1990/0227 | splx(s); } | |
| 1990/03091 | void wakeme(Alarm *a) { ready((Proc*)(a->arg)); cancel(a); } void twakeme(Alarm *a) { wakeup((Rendez*)(a->arg)); } | |
| 1990/0227 | int postnote(Proc *p, int dolock, char *n, int flag) { | |
| 1990/0309/sys/src/9/port/proc.c:322,340 – 1990/03091/sys/src/9/port/proc.c:336,341 | ||
| 1990/0227 | splx(s); } return 1; | |
| 1990/03091/sys/src/9/port/proc.c:199,209 – 1990/0310/sys/src/9/port/proc.c:199,206 (short | long) | ||
|
Remove lock allocation loop after all.
rsc Mon Mar 20 17:13:59 2006 | ||
| 1990/0227 | procalloc.arena = procalloc.free; p = procalloc.free; | |
| 1990/03091 |
| |
| 1990/0310 | for(i=0; i<conf.nproc-1; i++,p++) | |
| 1990/0227 | p->qnext = p+1; | |
| 1990/03091 |
| |
| 1990/0227 | p->qnext = 0; } | |
| 1990/0310/sys/src/9/port/proc.c:518,533 – 1990/0312/sys/src/9/port/proc.c:518,540 (short | long) | ||
|
Print segments in debugging process list.
rsc Mon Mar 20 17:14:00 2006 | ||
| 1990/0227 | #include <ureg.h> DEBUG() { | |
| 1990/0312 | int i, j; | |
| 1990/0227 | Proc *p; | |
| 1990/0312 | Orig *o; | |
| 1990/0227 | print("DEBUG\n"); for(i=0; i<conf.nproc; i++){ p = procalloc.arena+i; | |
| 1990/0312 | if(p->state != Dead){ | |
| 1990/0227 | print("%d:%s upc %lux %s ut %ld st %ld\n", p->pid, p->text, p->pc, statename[p->state], p->time[0], p->time[1]); | |
| 1990/0312 | for(j=0; j<NSEG; j++){ o = p->seg[j].o; if(o) print(" s%d %d %d\n", j, o->nmod, o->npte); } } | |
| 1990/0227 | } } | |
| 1990/0312/sys/src/9/port/proc.c:364,377 – 1990/0322/sys/src/9/port/proc.c:364,376 (short | long) | ||
|
Merge Proc.wait.use and Proc.wait.queue into single lock Proc.wait.
rsc Mon Mar 20 17:14:00 2006 | ||
| 1990/0227 | * Any of my children exiting? */ | |
| 1990/03081 | while(c->nchild){ | |
| 1990/0322 | lock(&c->wait); if(c->wait.locked == 0){ /* no child is exiting */ | |
| 1990/03081 | c->exiting = 1; | |
| 1990/0322 | unlock(&c->wait); | |
| 1990/0227 | break; }else{ /* must wait for child */ | |
| 1990/03081 |
| |
| 1990/0322 | unlock(&c->wait); | |
| 1990/0227 | pwait(0); } } | |
| 1990/0312/sys/src/9/port/proc.c:384,390 – 1990/0322/sys/src/9/port/proc.c:383,389 | ||
| 1990/0227 | if(p == 0) goto out; qlock(&p->wait); | |
| 1990/0322 | lock(&p->wait); | |
| 1990/03081 | if(p->pid==c->parentpid && !p->exiting){ | |
| 1990/0227 | w.pid = mypid; strcpy(w.msg, status); | |
| 1990/0312/sys/src/9/port/proc.c:402,411 – 1990/0322/sys/src/9/port/proc.c:401,410 | ||
| 1990/03081 | c->state = Exiting; | |
| 1990/0227 | if(p->state == Inwait) ready(p); | |
| 1990/0322 | unlock(&p->wait); | |
| 1990/0227 | sched(); }else{ | |
| 1990/0322 | unlock(&p->wait); | |
| 1990/0227 | qunlock(&p->wait); } out: | |
| 1990/0312/sys/src/9/port/proc.c:476,496 – 1990/0322/sys/src/9/port/proc.c:475,501 | ||
| 1990/0227 | p = u->p; again: | |
| 1990/0322 | while(canlock(&p->wait)){ if(p->wait.locked){ /* child is exiting; wait for him */ unlock(&p->wait); break; } | |
| 1990/0227 | if(p->nchild == 0){ | |
| 1990/0322 | unlock(&p->wait); | |
| 1990/0227 | qunlock(&p->wait); error(0, Enochild); } p->state = Inwait; | |
| 1990/0322 | unlock(&p->wait); | |
| 1990/0227 | qunlock(&p->wait); sched(); } | |
| 1990/0322 | lock(&p->wait); /* wait until child is finished */ | |
| 1990/0227 | c = p->child; if(c == 0){ print("pwait %d\n", p->pid); p->state = Inwait; | |
| 1990/0322 | unlock(&p->wait); | |
| 1990/0227 | sched(); goto again; } | |
| 1990/0312/sys/src/9/port/proc.c:502,508 – 1990/0322/sys/src/9/port/proc.c:507,513 | ||
| 1990/0227 | p->time[TCSys] += c->time[TSys] + c->time[TCSys]; p->time[TCReal] += c->time[TReal]; p->nchild--; | |
| 1990/0322 | unlock(&p->wait); | |
| 1990/0227 | qunlock(&p->wait); ready(c); return cpid; | |
| 1990/0322/sys/src/9/port/proc.c:364,376 – 1990/0324/sys/src/9/port/proc.c:364,377 (short | long) | ||
|
Split Proc.wait back into Proc.wait.use and Proc.wait.queue.
(BUG FIX?)
rsc Mon Mar 20 17:14:01 2006 | ||
| 1990/0227 | * Any of my children exiting? */ | |
| 1990/03081 | while(c->nchild){ | |
| 1990/0322 |
| |
| 1990/0324 | lock(&c->wait.queue); if(canlock(&c->wait.use)){ /* no child is exiting */ | |
| 1990/03081 | c->exiting = 1; | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&c->wait.use); unlock(&c->wait.queue); | |
| 1990/0227 | break; }else{ /* must wait for child */ | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&c->wait.queue); | |
| 1990/0227 | pwait(0); } } | |
| 1990/0322/sys/src/9/port/proc.c:383,389 – 1990/0324/sys/src/9/port/proc.c:384,390 | ||
| 1990/0227 | if(p == 0) goto out; qlock(&p->wait); | |
| 1990/0322 |
| |
| 1990/0324 | lock(&p->wait.queue); | |
| 1990/03081 | if(p->pid==c->parentpid && !p->exiting){ | |
| 1990/0227 | w.pid = mypid; strcpy(w.msg, status); | |
| 1990/0322/sys/src/9/port/proc.c:401,410 – 1990/0324/sys/src/9/port/proc.c:402,411 | ||
| 1990/03081 | c->state = Exiting; | |
| 1990/0227 | if(p->state == Inwait) ready(p); | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&p->wait.queue); | |
| 1990/0227 | sched(); }else{ | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&p->wait.queue); | |
| 1990/0227 | qunlock(&p->wait); } out: | |
| 1990/0322/sys/src/9/port/proc.c:475,501 – 1990/0324/sys/src/9/port/proc.c:476,496 | ||
| 1990/0227 | p = u->p; again: | |
| 1990/0322 |
| |
| 1990/0324 | while(canlock(&p->wait.use)){ | |
| 1990/0227 | if(p->nchild == 0){ | |
| 1990/0322 |
| |
| 1990/0227 | qunlock(&p->wait); error(0, Enochild); } p->state = Inwait; | |
| 1990/0322 |
| |
| 1990/0227 | qunlock(&p->wait); sched(); } | |
| 1990/0322 |
| |
| 1990/0324 | lock(&p->wait.queue); /* wait until child is finished */ | |
| 1990/0227 | c = p->child; if(c == 0){ print("pwait %d\n", p->pid); p->state = Inwait; | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&p->wait.queue); | |
| 1990/0227 | sched(); goto again; } | |
| 1990/0322/sys/src/9/port/proc.c:507,513 – 1990/0324/sys/src/9/port/proc.c:502,508 | ||
| 1990/0227 | p->time[TCSys] += c->time[TSys] + c->time[TCSys]; p->time[TCReal] += c->time[TReal]; p->nchild--; | |
| 1990/0322 |
| |
| 1990/0324 | unlock(&p->wait.queue); | |
| 1990/0227 | qunlock(&p->wait); ready(c); return cpid; | |
| 1990/0324/sys/src/9/port/proc.c:518,524 – 1990/0330/sys/src/9/port/proc.c:518,524 (short | long) | ||
|
Remove segments from debugging process list.
rsc Mon Mar 20 17:14:01 2006 | ||
| 1990/0227 | #include <ureg.h> DEBUG() { | |
| 1990/0312 |
| |
| 1990/0330 | int i; | |
| 1990/0227 | Proc *p; | |
| 1990/0312 | Orig *o; | |
| 1990/0227 | ||
| 1990/0324/sys/src/9/port/proc.c:529,539 – 1990/0330/sys/src/9/port/proc.c:529,534 | ||
| 1990/0227 | print("%d:%s upc %lux %s ut %ld st %ld\n", p->pid, p->text, p->pc, statename[p->state], p->time[0], p->time[1]); | |
| 1990/0312 |
| |
| 1990/0227 | } } | |
| 1990/0330/sys/src/9/port/proc.c:539,546 – 1990/0424/sys/src/9/port/proc.c:539,546 (short | long) | ||
|
Code rearrangement: move lastvar declaration in kproc.
rsc Mon Mar 20 17:14:02 2006 | ||
| 1990/0227 | Proc *p; int n; ulong upa; | |
| 1990/0424 | int lastvar; /* used to compute stack address */ | |
| 1990/0227 | /* * Kernel stack | |
| 1990/0424/sys/src/9/port/proc.c:410,417 – 1990/0509/sys/src/9/port/proc.c:410,444 (short | long) | ||
|
Keep at most NBROKEN Broken processes around.
rsc Mon Mar 20 17:14:02 2006 | ||
| 1990/0227 | } out: if(!freemem){ | |
| 1990/0509 | /* * weird thing: keep at most NBROKEN around */ #define NBROKEN 4 static struct{ Lock; int n; Proc *p[NBROKEN]; }broken; int b; lock(&broken); if(broken.n == NBROKEN){ ready(broken.p[0]); memcpy(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1)); --broken.n; } broken.p[broken.n++] = c; unlock(&broken); | |
| 1990/03081 | c->state = Broken; | |
| 1990/0227 | sched(); /* until someone lets us go */ | |
| 1990/0509 | lock(&broken); for(b=0; b<NBROKEN; b++) if(broken.p[b] == c){ broken.n--; memcpy(&broken.p[b], &broken.p[b+1], sizeof(Proc*)*(NBROKEN-(b+1))); break; } unlock(&broken); | |
| 1990/0227 | freesegs(-1); | |
| 1990/03081 | closepgrp(c->pgrp); | |
| 1990/0227 | close(u->dot); | |
| 1990/0509/sys/src/9/port/proc.c:391,399 – 1990/0614/sys/src/9/port/proc.c:391,399 (short | long) | ||
|
Store time in milliseconds, not ticks (BUG FIX?)
rsc Mon Mar 20 17:14:02 2006 | ||
| 1990/0227 | wp = &w.time[TUser]; | |
| 1990/03081 | up = &c->time[TUser]; ucp = &c->time[TCUser]; | |
| 1990/0227 |
| |
| 1990/0614 | *wp++ = TK2MS(*up++ + *ucp++); *wp++ = TK2MS(*up++ + *ucp ); *wp = TK2MS(*up ); | |
| 1990/03081 | p->child = c; | |
| 1990/0227 | /* * Pass info through back door, to avoid huge Proc's | |
| 1990/0614/sys/src/9/port/proc.c:303,320 – 1990/0617/sys/src/9/port/proc.c:303,325 (short | long) | ||
|
Use kmap in postnote to access Proc.upage.
rsc Mon Mar 20 17:14:03 2006 | ||
| 1990/0227 | postnote(Proc *p, int dolock, char *n, int flag) { User *up; | |
| 1990/0617 | KMap *k; | |
| 1990/0227 | int s; Rendez *r; if(dolock) lock(&p->debug); | |
| 1990/0617 | k = kmap(p->upage); up = (User*)VA(k); | |
| 1990/0227 | if(flag!=NUser && (up->notify==0 || up->notified)) up->nnote = 0; /* force user's hand */ | |
| 1990/0617 | else if(up->nnote == NNOTE-1){ kunmap(k); | |
| 1990/0227 | return 0; | |
| 1990/0617 | } | |
| 1990/0227 | strcpy(up->note[up->nnote].msg, n); up->note[up->nnote++].flag = flag; | |
| 1990/0617 | kunmap(k); | |
| 1990/0227 | if(dolock) unlock(&p->debug); if(r = p->r){ /* assign = */ | |
| 1990/0614/sys/src/9/port/proc.c:398,404 – 1990/0617/sys/src/9/port/proc.c:403,409 | ||
| 1990/0227 | /* * Pass info through back door, to avoid huge Proc's */ | |
| 1990/03081 |
| |
| 1990/0617 | p->waitmsg = (((ulong)&w)&(BY2PG-1)); | |
| 1990/03081 | c->state = Exiting; | |
| 1990/0227 | if(p->state == Inwait) ready(p); | |
| 1990/0614/sys/src/9/port/proc.c:499,504 – 1990/0617/sys/src/9/port/proc.c:504,510 | ||
| 1990/0227 | pwait(Waitmsg *w) { Proc *c, *p; | |
| 1990/0617 | KMap *k; | |
| 1990/0227 | ulong cpid; p = u->p; | |
| 1990/0614/sys/src/9/port/proc.c:515,521 – 1990/0617/sys/src/9/port/proc.c:521,526 | ||
| 1990/0324 | lock(&p->wait.queue); /* wait until child is finished */ | |
| 1990/0227 | c = p->child; if(c == 0){ | |
| 1990/0324 | unlock(&p->wait.queue); | |
| 1990/0227 | sched(); | |
| 1990/0614/sys/src/9/port/proc.c:522,530 – 1990/0617/sys/src/9/port/proc.c:527,537 | ||
| 1990/0227 | goto again; } p->child = 0; | |
| 1990/0617 | k = kmap(c->upage); | |
| 1990/0227 | if(w) | |
| 1990/0617 | *w = *(Waitmsg*)(p->waitmsg|VA(k)); cpid = ((Waitmsg*)(p->waitmsg|VA(k)))->pid; kunmap(k); | |
| 1990/0227 | p->time[TCUser] += c->time[TUser] + c->time[TCUser]; p->time[TCSys] += c->time[TSys] + c->time[TCSys]; p->time[TCReal] += c->time[TReal]; | |
| 1990/0614/sys/src/9/port/proc.c:566,573 – 1990/0617/sys/src/9/port/proc.c:573,581 | ||
| 1990/0227 | Proc *p; int n; ulong upa; | |
| 1990/0424 | int lastvar; /* used to compute stack address */ | |
| 1990/0617 | User *up; KMap *k; | |
| 1990/0227 | /* * Kernel stack | |
| 1990/0614/sys/src/9/port/proc.c:574,590 – 1990/0617/sys/src/9/port/proc.c:582,599 | ||
| 1990/0227 | */ p = newproc(); p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); | |
| 1990/0617 | k = kmap(p->upage); upa = VA(k); up = (User*)upa; up->p = p; | |
| 1990/0227 | /* * Save time: only copy u-> data and useful stack */ | |
| 1990/0617 | memcpy(up, u, sizeof(User)); | |
| 1990/0227 | n = USERADDR+BY2PG - (ulong)&lastvar; n = (n+32) & ~(BY2WD-1); /* be safe & word align */ | |
| 1990/0617 | memcpy((void*)(upa+BY2PG-n), (void*)(USERADDR+BY2PG-n), n); | |
| 1990/0227 | /* * Refs | |
| 1990/0614/sys/src/9/port/proc.c:593,598 – 1990/0617/sys/src/9/port/proc.c:602,608 | ||
| 1990/0227 | for(n=0; n<=up->maxfd; n++) up->fd[n] = 0; up->maxfd = 0; | |
| 1990/0617 | kunmap(k); | |
| 1990/0227 | /* * Sched | |
| 1990/0617/sys/src/9/port/proc.c:184,189 – 1990/0619/sys/src/9/port/proc.c:184,190 (short | long) | ||
|
Set u->p->state = Wakeme before sleeping for more procs in newproc. (BUG FIX)
rsc Mon Mar 20 17:14:03 2006 | ||
| 1990/0227 | print("no procs\n"); if(u == 0) panic("newproc"); | |
| 1990/0619 | u->p->state = Wakeme; | |
| 1990/0227 | alarm(1000, wakeme, u->p); sched(); goto loop; | |
| 1990/0619/sys/src/9/port/proc.c:561,569 – 1990/0629/sys/src/9/port/proc.c:561,569 (short | long) | ||
|
Print p->r pointer in process dump.
rsc Mon Mar 20 17:14:03 2006 | ||
| 1990/0227 | for(i=0; i<conf.nproc; i++){ p = procalloc.arena+i; | |
| 1990/0312 | if(p->state != Dead){ | |
| 1990/0227 |
| |
| 1990/0629 | print("%d:%s upc %lux %s ut %ld st %ld r %lux\n", | |
| 1990/0227 | p->pid, p->text, p->pc, statename[p->state], | |
| 1990/0629 | p->time[0], p->time[1], p->r); | |
| 1990/0312 | } | |
| 1990/0227 | } } | |
| 1990/0629/sys/src/9/port/proc.c:561,568 – 1990/0704/sys/src/9/port/proc.c:561,568 (short | long) | ||
|
Print user names in process dump.
rsc Mon Mar 20 17:14:04 2006 | ||
| 1990/0227 | for(i=0; i<conf.nproc; i++){ p = procalloc.arena+i; | |
| 1990/0312 | if(p->state != Dead){ | |
| 1990/0629 |
| |
| 1990/0227 |
| |
| 1990/0704 | print("%d:%s %s upc %lux %s ut %ld st %ld r %lux\n", p->pid, p->text, p->pgrp->user, p->pc, statename[p->state], | |
| 1990/0629 | p->time[0], p->time[1], p->r); | |
| 1990/0312 | } | |
| 1990/0227 | } | |
| 1990/0704/sys/src/9/port/proc.c:171,176 – 1990/0722/sys/src/9/port/proc.c:171,177 (short | long) | ||
|
Reset p->fpstate in newproc (BUG FIX?). Use kernel pgrp for all kprocs (was using u->p's).
rsc Mon Mar 20 17:14:04 2006 | ||
| 1990/0227 | p->nchild = 0; p->child = 0; p->exiting = 0; | |
| 1990/0722 | p->fpstate = FPinit; | |
| 1990/0227 | memset(p->pidonmach, 0, sizeof p->pidonmach); memset(p->seg, 0, sizeof p->seg); lock(&pidalloc); | |
| 1990/0704/sys/src/9/port/proc.c:577,582 – 1990/0722/sys/src/9/port/proc.c:578,584 | ||
| 1990/0424 | int lastvar; /* used to compute stack address */ | |
| 1990/0617 | User *up; KMap *k; | |
| 1990/0722 | static Pgrp *kpgrp; | |
| 1990/0227 | /* * Kernel stack | |
| 1990/0704/sys/src/9/port/proc.c:614,625 – 1990/0722/sys/src/9/port/proc.c:616,631 | ||
| 1990/0227 | p->mach = m; m->proc = p; spllo(); | |
| 1990/0722 | if(kpgrp == 0){ kpgrp = newpgrp(); strcpy(kpgrp->user, "bootes"); } p->pgrp = kpgrp; incref(kpgrp); sprint(p->text, "%s.%.6s", name, u->p->pgrp->user); | |
| 1990/0227 | p->nchild = 0; p->parent = 0; memset(p->time, 0, sizeof(p->time)); | |
| 1990/0722/sys/src/9/port/proc.c:299,304 – 1990/0726/sys/src/9/port/proc.c:299,305 (short | long) | ||
|
Cancel alarm after wakeup. (BUG FIX?)
rsc Mon Mar 20 17:14:04 2006 | ||
| 1990/03091 | twakeme(Alarm *a) { wakeup((Rendez*)(a->arg)); | |
| 1990/0726 | cancel(a); | |
| 1990/03091 | } | |
| 1990/0227 | int | |
| 1990/0726/sys/src/9/port/proc.c:299,305 – 1990/0728/sys/src/9/port/proc.c:299,304 (short | long) | ||
|
Don't cancel alarm after wakeup. (BUG FIX?)
rsc Mon Mar 20 17:14:05 2006 | ||
| 1990/03091 | twakeme(Alarm *a) { wakeup((Rendez*)(a->arg)); | |
| 1990/0726 |
| |
| 1990/03091 | } | |
| 1990/0227 | int | |
| 1990/0728/sys/src/9/port/proc.c:77,83 – 1990/0731/sys/src/9/port/proc.c:77,83 (short | long) | ||
|
Add pc argument to m->intr function.
rsc Mon Mar 20 17:14:05 2006 | ||
| 1990/0227 | { Proc *p; ulong tlbvirt, tlbphys; | |
| 1990/0731 | void (*f)(ulong, ulong); | |
| 1990/0227 | if(u){ splhi(); | |
| 1990/0728/sys/src/9/port/proc.c:93,99 – 1990/0731/sys/src/9/port/proc.c:93,99 | ||
| 1990/0227 | } if(f = m->intr){ /* assign = */ m->intr = 0; | |
| 1990/0731 | (*f)(m->cause, m->pc); | |
| 1990/0227 | } spllo(); p = runproc(); | |
| 1990/0731/sys/src/9/port/proc.c:59,64 – 1990/0801/sys/src/9/port/proc.c:59,65 (short | long) | ||
|
Add unusepage of Proc.upage when freeing process. (BUG FIX?)
rsc Mon Mar 20 17:14:05 2006 | ||
| 1990/0227 | else if(p->state == Moribund){ p->pid = 0; unlock(&p->debug); | |
| 1990/0801 | unusepage(p->upage, 1); | |
| 1990/0227 | p->upage->ref--; /* procalloc already locked */ p->qnext = procalloc.free; | |
| 1990/0801/sys/src/9/port/proc.c:343,349 – 1990/1101/sys/src/9/port/proc.c:343,402 (short | long) | ||
|
Move broken process code into new addbroken. Add freebroken.
rsc Mon Mar 20 17:14:05 2006 | ||
| 1990/0227 | return 1; } | |
| 1990/1101 | /* * weird thing: keep at most NBROKEN around */ #define NBROKEN 4 struct{ Lock; int n; Proc *p[NBROKEN]; }broken; | |
| 1990/0227 | void | |
| 1990/1101 | addbroken(Proc *c) { int b; lock(&broken); if(broken.n == NBROKEN){ ready(broken.p[0]); memcpy(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1)); --broken.n; } broken.p[broken.n++] = c; unlock(&broken); c->state = Broken; sched(); /* until someone lets us go */ lock(&broken); for(b=0; b<NBROKEN; b++) if(broken.p[b] == c){ broken.n--; memcpy(&broken.p[b], &broken.p[b+1], sizeof(Proc*)*(NBROKEN-(b+1))); break; } unlock(&broken); } int freebroken(void) { int n; lock(&broken); n = broken.n; while(broken.n > 0){ ready(broken.p[0]); memcpy(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1)); --broken.n; } unlock(&broken); return n; } void | |
| 1990/0227 | pexit(char *s, int freemem) { char status[64]; | |
| 1990/0801/sys/src/9/port/proc.c:418,452 – 1990/1101/sys/src/9/port/proc.c:471,477 | ||
| 1990/0227 | } out: if(!freemem){ | |
| 1990/0509 |
| |
| 1990/03081 |
| |
| 1990/0227 |
| |
| 1990/0509 |
| |
| 1990/1101 | addbroken(c); | |
| 1990/0227 | freesegs(-1); | |
| 1990/03081 | closepgrp(c->pgrp); | |
| 1990/0227 | close(u->dot); | |
| 1990/1101/sys/src/9/port/proc.c:250,256 – 1990/11211/sys/src/9/port/proc.c:250,256 (short | long) | ||
|
Remove Chan* argument to error.
rsc Mon Mar 20 17:30:32 2006 | ||
| 1990/0227 | sched(); if(u->p->wokeup){ u->p->wokeup = 0; | |
| 1990/11211 | error(Eintr); | |
| 1990/0227 | } } | |
| 1990/1101/sys/src/9/port/proc.c:265,271 – 1990/11211/sys/src/9/port/proc.c:265,271 | ||
| 1990/0227 | cancel(a); if(u->p->wokeup){ u->p->wokeup = 0; | |
| 1990/11211 | error(Eintr); | |
| 1990/0227 | } } | |
| 1990/1101/sys/src/9/port/proc.c:540,546 – 1990/11211/sys/src/9/port/proc.c:540,546 | ||
| 1990/0324 | while(canlock(&p->wait.use)){ | |
| 1990/0227 | if(p->nchild == 0){ qunlock(&p->wait); | |
| 1990/11211 | error(Enochild); | |
| 1990/0227 | } p->state = Inwait; qunlock(&p->wait); | |
| 1990/11211/sys/src/9/port/proc.c:166,174 – 1990/1124/sys/src/9/port/proc.c:166,171 (short | long) | ||
|
Remove process hierarchy.
rsc Mon Mar 20 17:14:06 2006 | ||
| 1990/0227 | unlock(&procalloc); p->mach = 0; p->qnext = 0; | |
| 1990/03081 |
| |
| 1990/0309 |
| |
| 1990/0227 | p->nchild = 0; p->child = 0; p->exiting = 0; | |
| 1990/11211/sys/src/9/port/proc.c:477,526 – 1990/1124/sys/src/9/port/proc.c:474,480 | ||
| 1990/0227 | close(u->dot); } | |
| 1990/03081 |
| |
| 1990/0227 | lock(&procalloc); /* sched() can't do this */ | |
| 1990/03081 | lock(&c->debug); /* sched() can't do this */ | |
| 1990/1124/sys/src/9/port/proc.c:52,58 – 1990/1211/sys/src/9/port/proc.c:52,58 (short | long) | ||
|
Add invalidateu function, save, restore, clearmmucache.
rsc Mon Mar 20 17:14:06 2006 | ||
| 1990/0227 | if(u){ m->proc = 0; p = u->p; | |
| 1990/1211 | invalidateu(); /* safety first */ | |
| 1990/0227 | u = 0; if(p->state == Running) ready(p); | |
| 1990/1124/sys/src/9/port/proc.c:76,81 – 1990/1211/sys/src/9/port/proc.c:76,82 | ||
| 1990/0227 | void sched(void) { | |
| 1990/1211 | uchar procstate[64]; /* sleeze for portability */ | |
| 1990/0227 | Proc *p; ulong tlbvirt, tlbphys; | |
| 1990/0731 | void (*f)(ulong, ulong); | |
| 1990/1124/sys/src/9/port/proc.c:82,92 – 1990/1211/sys/src/9/port/proc.c:83,95 | ||
| 1990/0227 | if(u){ splhi(); | |
| 1990/1211 | save(procstate, sizeof(procstate)); | |
| 1990/0227 | if(setlabel(&u->p->sched)){ /* woke up */ p = u->p; p->state = Running; p->mach = m; m->proc = p; | |
| 1990/1211 | restore(p, procstate); | |
| 1990/0227 | spllo(); return; } | |
| 1990/1124/sys/src/9/port/proc.c:132,138 – 1990/1211/sys/src/9/port/proc.c:135,141 | ||
| 1990/0227 | loop: while(runq.head == 0) | |
| 1990/1211 | for(i=0; i<10; i++) /* keep out of shared memory for a while */ | |
| 1990/0227 | ; splhi(); lock(&runq); | |
| 1990/1124/sys/src/9/port/proc.c:573,578 – 1990/1211/sys/src/9/port/proc.c:576,582 | ||
| 1990/0227 | /* * Save time: only copy u-> data and useful stack */ | |
| 1990/1211 | clearmmucache(); | |
| 1990/0617 | memcpy(up, u, sizeof(User)); | |
| 1990/0227 | n = USERADDR+BY2PG - (ulong)&lastvar; n = (n+32) & ~(BY2WD-1); /* be safe & word align */ | |
| Too many diffs (26 > 25). Stopping. | ||