| plan 9 kernel history: overview | file list | diff list |
1991/0926/port/proc.c (diff list | history)
| 1991/0919/sys/src/9/port/proc.c:18,23 – 1991/0926/sys/src/9/port/proc.c:18,29 (short | long | prev | next) | ||
|
Remove Zombie, MMUing, Exiting, Inwait states.
rsc Mon Mar 20 17:14:17 2006 | ||
| 1990/0227 | Proc *free; }procalloc; | |
| 1991/0926 | struct { Lock; Waitq *free; }waitqalloc; | |
| 1991/0420 | typedef struct | |
| 1990/0227 | { Lock; | |
| 1991/0919/sys/src/9/port/proc.c:30,43 – 1991/0926/sys/src/9/port/proc.c:36,45 | ||
| 1990/0227 | char *statename[]={ /* BUG: generate automatically */ "Dead", "Moribund", | |
| 1991/0705 | "Stopped", | |
| 1991/0919/sys/src/9/port/proc.c:227,239 – 1991/0926/sys/src/9/port/proc.c:229,242 | ||
| 1990/0227 | lock(&procalloc); if(p = procalloc.free){ /* assign = */ procalloc.free = p->qnext; | |
| 1991/0926 | p->state = Scheding; p->psstate = "New"; | |
| 1990/0227 | unlock(&procalloc); p->mach = 0; p->qnext = 0; p->nchild = 0; | |
| 1991/0926 | p->nwait = 0; p->waitq = 0; | |
| 1991/0317 | p->pgrp = 0; | |
| 1991/0705 | p->egrp = 0; p->fgrp = 0; | |
| 1991/0919/sys/src/9/port/proc.c:492,497 – 1991/0926/sys/src/9/port/proc.c:495,501 | ||
| 1990/1101 | broken.p[broken.n++] = c; unlock(&broken); c->state = Broken; | |
| 1991/0926 | c->psstate = 0; | |
| 1990/1101 | sched(); /* until someone lets us go */ lock(&broken); for(b=0; b<NBROKEN; b++) | |
| 1991/0919/sys/src/9/port/proc.c:520,619 – 1991/0926/sys/src/9/port/proc.c:524,596 | ||
| 1990/1101 | void | |
| 1991/0717 | pexit(char *exitstr, int freemem) | |
| 1990/0227 | { | |
| 1990/03081 |
| |
| 1991/0705 |
| |
| 1990/03081 |
| |
| 1991/0110 |
| |
| 1990/0227 |
| |
| 1991/0926 | Proc *p, *c; | |
| 1991/0717 | Segment **s, **es, *os; | |
| 1991/0926 | Waitq *wq, *f, *next; | |
| 1990/0227 | ||
| 1991/0717 |
| |
| 1991/0110 |
| |
| 1991/0705 | ||
| 1990/03081 | c = u->p; | |
| 1991/0513 | c->alarm = 0; | |
| 1990/03081 |
| |
| 1991/0517 | ||
| 1991/0712 | if(c->fgrp) closefgrp(c->fgrp); | |
| 1991/0517 | ||
| 1990/0227 |
| |
| 1991/0705 |
| |
| 1991/0717 |
| |
| 1990/03081 |
| |
| 1991/0712 |
| |
| 1990/0227 |
| |
| 1990/03081 |
| |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1991/0926 | wq = newwaitq(); wq->w.pid = c->pid; wq->w.time[TUser] = TK2MS(c->time[TUser]); wq->w.time[TCUser] = TK2MS(c->time[TCUser]); wq->w.time[TSys] = TK2MS(c->time[TSys]); wq->w.time[TCSys] = TK2MS(c->time[TCSys]); wq->w.time[TReal] = TK2MS(MACHP(0)->ticks - c->time[TReal]); if(exitstr) strncpy(wq->w.msg, exitstr, ERRLEN); else wq->w.msg[0] = '\0'; | |
| 1990/0227 | ||
| 1990/03081 |
| |
| 1990/0227 |
| |
| 1991/0926 | /* Find my parent */ | |
| 1990/03081 | p = c->parent; | |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/03081 |
| |
| 1991/0318 |
| |
| 1991/0109 |
| |
| 1990/03081 |
| |
| 1990/0614 |
| |
| 1990/03081 |
| |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1991/0926 | 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); | |
| 1990/0227 | } | |
| 1990/1101 |
| |
| 1991/0705 |
| |
| 1991/0717 |
| |
| 1990/03081 |
| |
| 1991/0705 |
| |
| 1990/0227 |
| |
| 1991/0926 | else { unlock(&p->exl); freewaitq(wq); | |
| 1990/0227 | } | |
| 1990/03081 |
| |
| 1991/0926 | if(!freemem) addbroken(c); | |
| 1990/03081 | ||
| 1991/0926 | flushvirt(); es = &c->seg[NSEG]; for(s = c->seg; s < es; s++) if(os = *s) { *s = 0; putseg(os); } closepgrp(c->pgrp); closeegrp(c->egrp); close(u->dot); lock(&c->exl); /* Prevent my children from leaving waits */ c->pid = 0; unlock(&c->exl); for(f = c->waitq; f; f = next) { next = f->next; freewaitq(f); } | |
| 1991/0705 | /* * sched() cannot wait on these locks */ | |
| 1991/0919/sys/src/9/port/proc.c:626,671 – 1991/0926/sys/src/9/port/proc.c:603,648 | ||
| 1991/0705 | panic("pexit"); | |
| 1990/0227 | } | |
| 1991/0926 | int haswaitq(void *x) { Proc *p; p = (Proc *)x; return p->waitq != 0; } | |
| 1990/0227 | ulong pwait(Waitmsg *w) { | |
| 1991/0926 | Proc *p; | |
| 1990/0227 | ulong cpid; | |
| 1991/0926 | Waitq *wq; | |
| 1990/0227 | p = u->p; | |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1990/11211 |
| |
| 1990/0227 |
| |
| 1991/0926 | lock(&p->exl); if(p->nchild == 0 && p->waitq == 0) { unlock(&p->exl); error(Enochild); | |
| 1990/0227 | } | |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1991/0926 | unlock(&p->exl); sleep(&p->waitr, haswaitq, u->p); lock(&p->exl); wq = p->waitq; p->waitq = wq->next; p->nwait--; unlock(&p->exl); | |
| 1990/0227 | if(w) | |
| 1991/0109 |
| |
| 1990/0227 |
| |
| 1990/0324 |
| |
| 1990/0227 |
| |
| 1991/0926 | memmove(w, &wq->w, sizeof(Waitmsg)); cpid = wq->w.pid; freewaitq(wq); | |
| 1990/0227 | return cpid; } | |
| 1991/0919/sys/src/9/port/proc.c:706,711 – 1991/0926/sys/src/9/port/proc.c:683,689 | ||
| 1990/0227 | * Kernel stack */ p = newproc(); | |
| 1991/0926 | p->psstate = 0; | |
| 1990/1212 | p->kp = 1; | |
| 1990/0227 | p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); | |
| 1990/0617 | k = kmap(p->upage); | |
| 1991/0919/sys/src/9/port/proc.c:732,746 – 1991/0926/sys/src/9/port/proc.c:710,715 | ||
| 1990/0227 | * Sched */ if(setlabel(&p->sched)){ | |
| 1991/0919 |
| |
| 1990/0227 | p->state = Running; p->mach = m; m->proc = p; | |
| 1991/0919/sys/src/9/port/proc.c:765,770 – 1991/0926/sys/src/9/port/proc.c:734,740 | ||
| 1990/0227 | p->parent = 0; memset(p->time, 0, sizeof(p->time)); p->time[TReal] = MACHP(0)->ticks; | |
| 1991/0926 | ready(p); | |
| 1991/0529 | /* * since the bss/data segments are now shareable, * any mmu info about this process is now stale | |
| 1991/0919/sys/src/9/port/proc.c:771,778 – 1991/0926/sys/src/9/port/proc.c:741,746 | ||
| 1991/0529 | * and has to be discarded. */ | |
| 1990/0227 | flushmmu(); | |
| 1991/0919 |
| |
| 1991/0705 | } void | |
| 1991/0919/sys/src/9/port/proc.c:811,813 – 1991/0926/sys/src/9/port/proc.c:779,815 | ||
| 1991/0710 | gotolabel(&u->errlab[--u->nerrlab]); } | |
| 1991/0926 | 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); } } void freewaitq(Waitq *wq) { lock(&waitqalloc); wq->next = waitqalloc.free; waitqalloc.free = wq; unlock(&waitqalloc); } | |