Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
runtime: fix scheduling race
Browse files Browse the repository at this point in the history
Affects programs using cgo or runtime.LockOSThread.

Fixes #2100.

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/4810059
  • Loading branch information
hectorchu authored and rsc committed Jul 29, 2011
1 parent 31442a6 commit 9bc58ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pkg/runtime/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 9bc58ac

Please sign in to comment.