1 #include "threadimpl.h"
5 int _threadhighnrendez;
10 finish(Thread *t, ulong val)
16 while(t->state == Running)
19 if(t->state == Rendezvous){ /* not always true: might be Dead */
23 unlock(&t->proc->lock);
28 _threadrendezvous(ulong tag, ulong val)
33 lock(&_threadrgrp.lock);
35 l = &_threadrgrp.hash[tag%nelem(_threadrgrp.hash)];
36 for(t=*l; t; l=&t->rendhash, t=*l){
38 _threaddebug(DBGREND, "Rendezvous with thread %d.%d", t->proc->pid, t->id);
42 unlock(&_threadrgrp.lock);
47 /* Going to sleep here. */
48 t = _threadgetproc()->thread;
56 if(nrendez > _threadhighnrendez)
57 _threadhighnrendez = nrendez;
58 _threaddebug(DBGREND, "Rendezvous for tag %lud (m=%d)", t->rendtag, t->moribund);
59 unlock(&_threadrgrp.lock);
60 t->nextstate = Rendezvous;
63 _threaddebug(DBGREND, "Woke after rendezvous; val is %lud", t->rendval);
68 * This is called while holding _threadpq.lock and p->lock,
69 * so we can't lock _threadrgrp.lock. Instead our caller has
70 * to call _threadbreakrendez after dropping those locks.
73 _threadflagrendez(Thread *t)
80 _threadbreakrendez(void)
87 lock(&_threadrgrp.lock);
89 unlock(&_threadrgrp.lock);
93 for(i=0; i<nelem(_threadrgrp.hash); i++){
94 l = &_threadrgrp.hash[i];
103 unlock(&_threadrgrp.lock);