summaryrefslogtreecommitdiffstats
path: root/src/libthread/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread/sched.c')
-rw-r--r--src/libthread/sched.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libthread/sched.c b/src/libthread/sched.c
index 9ad7298b..bdb9ad6b 100644
--- a/src/libthread/sched.c
+++ b/src/libthread/sched.c
@@ -171,7 +171,7 @@ needstack(int howmuch)
}
}
-void
+int
_sched(void)
{
Proc *p;
@@ -186,8 +186,8 @@ Resched:
// psstate(t->state), &t->sched, &p->sched);
if(_setlabel(&t->sched)==0)
_gotolabel(&p->sched);
- _threadstacklimit(t->stk);
- return;
+ _threadstacklimit(t->stk, t->stk+t->stksize);
+ return p->nsched++;
}else{
t = runthread(p);
if(t == nil){
@@ -277,10 +277,15 @@ _threadidle(void)
unlock(&p->readylock);
}
-void
+int
yield(void)
{
- _sched();
+ Proc *p;
+ int nsched;
+
+ p = _threadgetproc();
+ nsched = p->nsched;
+ return _sched() - nsched;
}
void