2003-09-30 17:47:42 +00:00
|
|
|
#include "threadimpl.h"
|
|
|
|
|
|
|
|
|
|
int _threadhighnrendez;
|
|
|
|
|
int _threadnrendez;
|
|
|
|
|
|
2004-09-17 00:38:29 +00:00
|
|
|
void
|
|
|
|
|
_threadsleep(_Procrend *r)
|
2003-09-30 17:47:42 +00:00
|
|
|
{
|
2004-09-17 00:38:29 +00:00
|
|
|
Thread *t;
|
2003-09-30 17:47:42 +00:00
|
|
|
|
|
|
|
|
t = _threadgetproc()->thread;
|
2004-09-17 00:38:29 +00:00
|
|
|
r->arg = t;
|
2003-11-24 22:39:06 +00:00
|
|
|
t->nextstate = Rendezvous;
|
2004-09-23 03:01:36 +00:00
|
|
|
t->asleep = 1;
|
2004-09-17 00:38:29 +00:00
|
|
|
unlock(r->l);
|
2003-09-30 17:47:42 +00:00
|
|
|
_sched();
|
2004-09-23 03:01:36 +00:00
|
|
|
t->asleep = 0;
|
2004-09-17 00:38:29 +00:00
|
|
|
lock(r->l);
|
2003-09-30 17:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2004-09-17 00:38:29 +00:00
|
|
|
_threadwakeup(_Procrend *r)
|
2003-09-30 17:47:42 +00:00
|
|
|
{
|
2004-09-17 00:38:29 +00:00
|
|
|
Thread *t;
|
2003-09-30 17:47:42 +00:00
|
|
|
|
2004-09-17 00:38:29 +00:00
|
|
|
t = r->arg;
|
|
|
|
|
while(t->state == Running)
|
|
|
|
|
sleep(0);
|
|
|
|
|
lock(&t->proc->lock);
|
|
|
|
|
if(t->state == Dead){
|
|
|
|
|
unlock(&t->proc->lock);
|
2003-09-30 17:47:42 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-09-23 03:01:36 +00:00
|
|
|
assert(t->state == Rendezvous && t->asleep);
|
2004-09-17 00:38:29 +00:00
|
|
|
t->state = Ready;
|
|
|
|
|
_threadready(t);
|
|
|
|
|
unlock(&t->proc->lock);
|
2003-09-30 17:47:42 +00:00
|
|
|
}
|
2004-11-08 16:03:20 +00:00
|
|
|
|