aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2012-03-05 16:40:27 -0500
committerRuss Cox <rsc@golang.org>2012-03-05 16:40:27 -0500
commitaa1aaee7fd96a76e595add58b9889b4cd6703d3a (patch)
tree5acb6660fcdc1a8c7bc204adde4c6d2c4a3dca89 /src/pkg/runtime/proc.c
parent610b5b2fd8a31ac3855088a0ea2aece8d88d7521 (diff)
downloadgo-aa1aaee7fd96a76e595add58b9889b4cd6703d3a.tar.xz
runtime: wait for main goroutine before setting GOMAXPROCS.
Fixes #3182. R=golang-dev, dvyukov, rsc CC=golang-dev, remy https://golang.org/cl/5732057
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index de7090c527..88e2b61388 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -200,7 +200,9 @@ runtime·schedinit(void)
n = maxgomaxprocs;
runtime·gomaxprocs = n;
}
- setmcpumax(runtime·gomaxprocs);
+ // wait for the main goroutine to start before taking
+ // GOMAXPROCS into account.
+ setmcpumax(1);
runtime·singleproc = runtime·gomaxprocs == 1;
canaddmcpu(); // mcpu++ to account for bootstrap m
@@ -225,6 +227,8 @@ runtime·main(void)
// by calling runtime.LockOSThread during initialization
// to preserve the lock.
runtime·LockOSThread();
+ // From now on, newgoroutines may use non-main threads.
+ setmcpumax(runtime·gomaxprocs);
runtime·sched.init = true;
scvg = runtime·newproc1((byte*)runtime·MHeap_Scavenger, nil, 0, 0, runtime·main);
main·init();