Commit 9bc58acc authored by Hector Chu's avatar Hector Chu Committed by Russ Cox

runtime: fix scheduling race

Affects programs using cgo or runtime.LockOSThread.

Fixes #2100.

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/4810059
parent 31442a67
......@@ -486,8 +486,16 @@ nextgandunlock(void)
// We can only run one g, and it's not available.
// Make sure some other cpu is running to handle
// the ordinary run queue.
if(runtime·sched.gwait != 0)
if(runtime·sched.gwait != 0) {
matchmg();
// m->lockedg might have been on the queue.
if(m->nextg != nil) {
gp = m->nextg;
m->nextg = nil;
schedunlock();
return gp;
}
}
} else {
// Look for work on global queue.
while(haveg() && canaddmcpu()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment