diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-03-26 16:50:58 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-03-26 16:50:58 +0200 |
commit | 519725bb3c075ee2462c929f5997cb068e18466a (patch) | |
tree | 5b162e8488ad147a645048c073577821b4a2bee9 /src/pkg/runtime/proc.c | |
parent | 842623c5dd2819d980ca9c58048d6bc6ed82475f (diff) | |
download | golang-upstream-weekly/2012.03.22.tar.gz |
Imported Upstream version 2012.03.22upstream-weekly/2012.03.22
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r-- | src/pkg/runtime/proc.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index de7090c52..962f748ce 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(); @@ -730,6 +734,12 @@ runtime·mstart(void) m->g0->sched.pc = (void*)-1; // make sure it is never used runtime·asminit(); runtime·minit(); + + // Install signal handlers; after minit so that minit can + // prepare the thread to be able to handle the signals. + if(m == &runtime·m0) + runtime·initsig(); + schedule(nil); } @@ -1158,6 +1168,11 @@ runtime·malg(int32 stacksize) G *newg; byte *stk; + if(StackTop < sizeof(Stktop)) { + runtime·printf("runtime: SizeofStktop=%d, should be >=%d\n", (int32)StackTop, (int32)sizeof(Stktop)); + runtime·throw("runtime: bad stack.h"); + } + newg = runtime·malloc(sizeof(G)); if(stacksize >= 0) { if(g == m->g0) { |