From 94cff37c0767c65886a482c5bae780cb4f8582e8 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 5 Aug 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-08-05 --- port/proc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/port/proc.c b/port/proc.c index 7dc888ae04eda6e11a1331b31d5aca2ce0c809ce..e16161a455a8a17fb110fda8239c7a71671ae12f 100644 --- a/port/proc.c +++ b/port/proc.c @@ -319,6 +319,10 @@ sleep(Rendez *r, int (*f)(void*), void *arg) sched(); /* notepending may go true while asleep */ if(p->notepending){ p->notepending = 0; + lock(r); + if(r->p == p) + r->p = 0; + unlock(r); error(Eintr); } } @@ -338,6 +342,10 @@ tsleep(Rendez *r, int (*f)(void*), void *arg, int ms) } if(p->notepending){ p->notepending = 0; + lock(r); + if(r->p == p) + r->p = 0; + unlock(r); error(Eintr); } } @@ -419,11 +427,11 @@ postnote(Proc *p, int dolock, char *n, int flag) s = splhi(); lock(r); if(p->r==r && r->p==p){ /* check we won the race */ - r->p = 0; - if(p->state != Wakeme) - panic("postnote wakeup: not Wakeme"); - p->r = 0; - ready(p); + if(p->state == Wakeme){ + r->p = 0; + p->r = 0; + ready(p); + } } unlock(r); splx(s);