wakeup()

wakeup()

概要

実装

  850: /*
  851:  *  Expects that only one process can call wakeup for any given Rendez.
  852:  *  We hold both locks to ensure that r->p and p->r remain consistent.
  853:  *  Richard Miller has a better solution that doesn't require both to
  854:  *  be held simultaneously, but I'm a paranoid - presotto.
  855:  */
  856: Proc*
  857: wakeup(Rendez *r)
  858: {
  859:         Proc *p;
  860:         int s;
  861: 
  862:         s = splhi();
  863: 
  864:         lock(r);
  865:         p = r->p;
  866: 
  867:         if(p != nil){
  868:                 lock(&p->rlock);
  869:                 if(p->state != Wakeme || p->r != r)
  870:                         panic("wakeup: state");
  871:                 r->p = nil;
  872:                 p->r = nil;
  873:                 ready(p);
  • このRendezで待っているプロセスがいたら,実行可能状態に遷移させる.
  • 詳細はready()を参照
  874:                 unlock(&p->rlock);
  875:         }
  876:         unlock(r);
  877: 
  878:         splx(s);
  879: 
  880:         return p;
  881: }