| plan 9 kernel history: overview | file list | diff list |
1991/0727/port/proc.c (diff list | history)
| 1991/0721/sys/src/9/port/proc.c:238,243 – 1991/0727/sys/src/9/port/proc.c:238,244 (short | long | prev | next) | ||
|
New sleep and wakeup: replace wokeup with notepending.
Also set p->r early in sleep to avoid missing postnote. (BUG fix? I don't think so.)
rsc Mon Mar 20 17:14:14 2006 | ||
| 1990/0722 | p->fpstate = FPinit; | |
| 1991/0425 | p->kp = 0; | |
| 1991/0705 | p->procctl = 0; | |
| 1991/0727 | p->notepending = 0; | |
| 1990/0227 | memset(p->seg, 0, sizeof p->seg); lock(&pidalloc); p->pid = ++pidalloc.pid; | |
| 1991/0721/sys/src/9/port/proc.c:282,293 – 1991/0727/sys/src/9/port/proc.c:283,297 | ||
| 1990/0227 | * at interrupt time. lock is mutual exclusion */ s = splhi(); | |
| 1991/0727 | p = u->p; p->r = r; /* early so postnote knows */ | |
| 1990/0227 | lock(r); /* * if condition happened, never mind */ | |
| 1991/0727 | if((*f)(arg)){ p->r = 0; | |
| 1990/0227 | unlock(r); splx(s); return; | |
| 1991/0721/sys/src/9/port/proc.c:297,307 – 1991/0727/sys/src/9/port/proc.c:301,308 | ||
| 1990/0227 | * now we are committed to * change state and call scheduler */ | |
| 1990/03013 | print("double sleep %d %d\n", r->p->pid, p->pid); | |
| 1990/0227 |
| |
| 1991/0721/sys/src/9/port/proc.c:310,319 – 1991/0727/sys/src/9/port/proc.c:311,324 | ||
| 1990/0227 | void sleep(Rendez *r, int (*f)(void*), void *arg) { | |
| 1991/0727 | Proc *p; p = u->p; | |
| 1990/0227 | sleep1(r, f, arg); | |
| 1991/0727 | if(p->notepending == 0) sched(); /* notepending may go true while asleep */ if(p->notepending){ p->notepending = 0; | |
| 1990/11211 | error(Eintr); | |
| 1990/0227 | } } | |
| 1991/0721/sys/src/9/port/proc.c:322,334 – 1991/0727/sys/src/9/port/proc.c:327,343 | ||
| 1990/0227 | tsleep(Rendez *r, int (*f)(void*), void *arg, int ms) { Alarm *a; | |
| 1991/0727 | Proc *p; | |
| 1990/0227 | ||
| 1991/0727 | p = u->p; | |
| 1990/0227 | sleep1(r, f, arg); | |
| 1991/0727 | if(p->notepending == 0){ a = alarm(ms, twakeme, r); sched(); /* notepending may go true while asleep */ cancel(a); } if(p->notepending){ p->notepending = 0; | |
| 1990/11211 | error(Eintr); | |
| 1990/0227 | } } | |
| 1991/0721/sys/src/9/port/proc.c:397,402 – 1991/0727/sys/src/9/port/proc.c:406,412 | ||
| 1991/0109 | kunmap(k); | |
| 1990/0227 | return 0; | |
| 1990/0617 | } | |
| 1991/0727 | p->notepending = 1; | |
| 1990/0227 | strcpy(up->note[up->nnote].msg, n); up->note[up->nnote++].flag = flag; | |
| 1991/0109 | if(up != u) | |
| 1991/0721/sys/src/9/port/proc.c:404,418 – 1991/0727/sys/src/9/port/proc.c:414,427 | ||
| 1990/0227 | if(dolock) unlock(&p->debug); | |
| 1991/0705 |
| |
| 1990/0227 |
| |
| 1991/0727 | if(r = p->r){ /* assign = */ /* wake up; can't call wakeup itself because we're racing with it */ | |
| 1990/0227 | s = splhi(); lock(r); | |
| 1991/0727 | if(p->r==r && r->p==p){ /* check we won the race */ | |
| 1990/0227 | r->p = 0; if(p->state != Wakeme) panic("postnote wakeup: not Wakeme"); | |