Lock gflock;
G* gfree;
+ uint32 gcwaiting; // gc is waiting to run
int32 stopwait;
Note stopnote;
uint32 sysmonwait;
int32 runtime·gomaxprocs;
uint32 runtime·needextram;
bool runtime·iscgo;
-uint32 runtime·gcwaiting;
M runtime·m0;
G runtime·g0; // idle goroutine for m0
G* runtime·allg;
for(i = 0; i < 5; i++) {
// this should tell the scheduler to not start any new goroutines
runtime·sched.stopwait = 0x7fffffff;
- runtime·atomicstore((uint32*)&runtime·gcwaiting, 1);
+ runtime·atomicstore((uint32*)&runtime·sched.gcwaiting, 1);
// this should stop running goroutines
if(!preemptall())
break; // no running goroutines
runtime·lock(&runtime·sched);
runtime·sched.stopwait = runtime·gomaxprocs;
- runtime·atomicstore((uint32*)&runtime·gcwaiting, 1);
+ runtime·atomicstore((uint32*)&runtime·sched.gcwaiting, 1);
preemptall();
// stop current P
m->p->status = Pgcstop;
newprocs = 0;
} else
procresize(runtime·gomaxprocs);
- runtime·gcwaiting = 0;
+ runtime·sched.gcwaiting = 0;
p1 = nil;
while(p = pidleget()) {
return;
}
runtime·lock(&runtime·sched);
- if(runtime·gcwaiting) {
+ if(runtime·sched.gcwaiting) {
p->status = Pgcstop;
if(--runtime·sched.stopwait == 0)
runtime·notewakeup(&runtime·sched.stopnote);
{
P *p;
- if(!runtime·gcwaiting)
+ if(!runtime·sched.gcwaiting)
runtime·throw("gcstopm: not waiting for gc");
if(m->spinning) {
m->spinning = false;
int32 i;
top:
- if(runtime·gcwaiting) {
+ if(runtime·sched.gcwaiting) {
gcstopm();
goto top;
}
}
// random steal from other P's
for(i = 0; i < 2*runtime·gomaxprocs; i++) {
- if(runtime·gcwaiting)
+ if(runtime·sched.gcwaiting)
goto top;
p = runtime·allp[runtime·fastrand1()%runtime·gomaxprocs];
if(p == m->p)
stop:
// return P and block
runtime·lock(&runtime·sched);
- if(runtime·gcwaiting) {
+ if(runtime·sched.gcwaiting) {
runtime·unlock(&runtime·sched);
goto top;
}
runtime·throw("schedule: holding locks");
top:
- if(runtime·gcwaiting) {
+ if(runtime·sched.gcwaiting) {
gcstopm();
goto top;
}
m->mcache = nil;
m->p->m = nil;
runtime·atomicstore(&m->p->status, Psyscall);
- if(runtime·gcwaiting) {
+ if(runtime·sched.gcwaiting) {
runtime·lock(&runtime·sched);
if (runtime·sched.stopwait > 0 && runtime·cas(&m->p->status, Psyscall, Pgcstop)) {
if(--runtime·sched.stopwait == 0)
delay = 10*1000;
runtime·usleep(delay);
if(runtime·debug.schedtrace <= 0 &&
- (runtime·gcwaiting || runtime·atomicload(&runtime·sched.npidle) == runtime·gomaxprocs)) { // TODO: fast atomic
+ (runtime·sched.gcwaiting || runtime·atomicload(&runtime·sched.npidle) == runtime·gomaxprocs)) { // TODO: fast atomic
runtime·lock(&runtime·sched);
- if(runtime·atomicload(&runtime·gcwaiting) || runtime·atomicload(&runtime·sched.npidle) == runtime·gomaxprocs) {
+ if(runtime·atomicload(&runtime·sched.gcwaiting) || runtime·atomicload(&runtime·sched.npidle) == runtime·gomaxprocs) {
runtime·atomicstore(&runtime·sched.sysmonwait, 1);
runtime·unlock(&runtime·sched);
runtime·notesleep(&runtime·sched.sysmonnote);
runtime·sched.nmidle, runtime·sched.runqsize);
if(detailed) {
runtime·printf(" gcwaiting=%d nmidlelocked=%d nmspinning=%d stopwait=%d sysmonwait=%d\n",
- runtime·gcwaiting, runtime·sched.nmidlelocked, runtime·sched.nmspinning,
+ runtime·sched.gcwaiting, runtime·sched.nmidlelocked, runtime·sched.nmspinning,
runtime·sched.stopwait, runtime·sched.sysmonwait);
}
// We must be careful while reading data from P's, M's and G's.