mirror of
https://github.com/golang/go
synced 2024-11-24 22:00:09 -07:00
runtime: fix scheduling race
Affects programs using cgo or runtime.LockOSThread. Fixes #2100. R=rsc, dvyukov CC=golang-dev https://golang.org/cl/4810059
This commit is contained in:
parent
31442a6737
commit
9bc58accce
@ -486,8 +486,16 @@ nextgandunlock(void)
|
|||||||
// We can only run one g, and it's not available.
|
// We can only run one g, and it's not available.
|
||||||
// Make sure some other cpu is running to handle
|
// Make sure some other cpu is running to handle
|
||||||
// the ordinary run queue.
|
// the ordinary run queue.
|
||||||
if(runtime·sched.gwait != 0)
|
if(runtime·sched.gwait != 0) {
|
||||||
matchmg();
|
matchmg();
|
||||||
|
// m->lockedg might have been on the queue.
|
||||||
|
if(m->nextg != nil) {
|
||||||
|
gp = m->nextg;
|
||||||
|
m->nextg = nil;
|
||||||
|
schedunlock();
|
||||||
|
return gp;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Look for work on global queue.
|
// Look for work on global queue.
|
||||||
while(haveg() && canaddmcpu()) {
|
while(haveg() && canaddmcpu()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user