plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 65de82a30f67103eb9ec1cbc9ab62725b03e7423
parent f9aa99c72e86fa546a504d34ade4b3ca3164d9da
Author: rsc <devnull@localhost>
Date:   Wed,  9 Jun 2004 14:23:34 +0000

clean up children more often

Diffstat:
Msrc/libthread/sched.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/libthread/sched.c b/src/libthread/sched.c @@ -25,8 +25,8 @@ _schedinit(void *arg) { Proc *p; Thread *t; - extern void ignusr1(void), _threaddie(int); - ignusr1(); + extern void ignusr1(int), _threaddie(int); + ignusr1(1); signal(SIGTERM, _threaddie); p = arg; @@ -103,7 +103,8 @@ runthread(Proc *p) q = &p->ready; relock: lock(&p->readylock); - if(q->head == nil){ + if(p->nsched%128 == 0){ + /* clean up children */ e = errno; if((c = _threadwaitchan) != nil){ if(c->n <= c->s){ @@ -131,6 +132,8 @@ relock: free(w); } errno = e; + } + if(q->head == nil){ if(p->idle){ if(p->idle->state != Ready){ fprint(2, "everyone is asleep\n"); @@ -204,6 +207,7 @@ Resched: t->state = Running; t->nextstate = Ready; _gotolabel(&t->sched); + for(;;); } }