From c4097c29512269f4547ebefb8abdc57a2892b479 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 11 May 2004 17:51:27 +0000 Subject: Fix small bugs. --- src/libthread/sched.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/libthread/sched.c') 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 -- cgit v1.2.3