From 4feda71b7d2ed4c39655d5ba693d7a90e9aa8f49 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 2 Aug 2008 22:34:04 -0700 Subject: [PATCH] =?UTF-8?q?slightly=20gratuitous=20reorg=20of=20scheduler?= =?UTF-8?q?=20code=20=09*=20rename=20select=20(very=20loaded=20word)=20nex?= =?UTF-8?q?tgoroutine=20=09*=20separate=20out=20"enter=20scheduler"=20(sys?= =?UTF-8?q?=C2=B7gosched)=20=09=20=20from=20the=20scheduler=20itself=20(sc?= =?UTF-8?q?heduler)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R=r APPROVED=r DELTA=36 (17 added, 15 deleted, 4 changed) OCL=13772 CL=13774 --- src/runtime/proc.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/runtime/proc.c b/src/runtime/proc.c index bef497c9a72..232ee1b03c6 100644 --- a/src/runtime/proc.c +++ b/src/runtime/proc.c @@ -90,7 +90,7 @@ tracebackothers(G *me) } G* -select(void) +nextgoroutine(void) { G *gp; @@ -113,33 +113,35 @@ select(void) return nil; } +void +scheduler(void) +{ + G* gp; + + gosave(&m->sched); + gp = nextgoroutine(); + if(gp == nil) { +// prints("sched: no more work\n"); + sys·exit(0); + } + m->curg = gp; + g = gp; + gogo(&gp->sched); +} + void gom0init(void) { - gosave(&m->sched); - sys·gosched(); + scheduler(); } void sys·gosched(void) { - G* gp; - - if(g != m->g0) { - if(gosave(&g->sched)) - return; - g = m->g0; - gogo(&m->sched); - } - gp = select(); - if(gp == nil) { -// prints("sched: no more work\n"); - sys·exit(0); - } - - m->curg = gp; - g = gp; - gogo(&gp->sched); + if(gosave(&g->sched)) + return; + g = m->g0; + gogo(&m->sched); } //