mirror of
https://github.com/golang/go
synced 2024-11-26 08:07:57 -07:00
slightly gratuitous reorg of scheduler code
* rename select (very loaded word) nextgoroutine * separate out "enter scheduler" (sys·gosched) from the scheduler itself (scheduler) R=r APPROVED=r DELTA=36 (17 added, 15 deleted, 4 changed) OCL=13772 CL=13774
This commit is contained in:
parent
234dd3d7e3
commit
4feda71b7d
@ -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);
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user