Files
plan9port/src/libthread/rendez.c
rsc 06bb4ed20d Rewrite to remove dependence on rendezvous and its bizarre
data structures.  Makes it easier to use pthreads too.
Still need to add code for non-pthreads systems.

Just a checkpoint to switch work to another machine.
2004-09-17 00:38:29 +00:00

39 lines
565 B
C

#include "threadimpl.h"
int _threadhighnrendez;
int _threadnrendez;
void
_threadsleep(_Procrend *r)
{
Thread *t;
t = _threadgetproc()->thread;
r->arg = t;
t->nextstate = Rendezvous;
t->inrendez = 1;
unlock(r->l);
_sched();
t->inrendez = 0;
lock(r->l);
}
void
_threadwakeup(_Procrend *r)
{
Thread *t;
t = r->arg;
while(t->state == Running)
sleep(0);
lock(&t->proc->lock);
if(t->state == Dead){
unlock(&t->proc->lock);
return;
}
assert(t->state == Rendezvous && t->inrendez);
t->state = Ready;
_threadready(t);
unlock(&t->proc->lock);
}