aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-03-01 11:48:17 -0500
committerRuss Cox <rsc@golang.org>2012-03-01 11:48:17 -0500
commitdc159fabff52e9dd3da0948438017373be741b22 (patch)
treefc460a7d337993f620e63cdf41bfcdaf22db4447 /src/pkg/runtime/proc.c
parent03769efe414863be778b80eac7425d5f382d87cf (diff)
downloadgo-dc159fabff52e9dd3da0948438017373be741b22.tar.xz
runtime: run init on main thread
Fixes #3125. R=golang-dev, r, minux.ma CC=golang-dev https://golang.org/cl/5714049
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r--src/pkg/runtime/proc.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index ddac048a00..de7090c527 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -209,8 +209,6 @@ runtime·schedinit(void)
mstats.enablegc = 1;
m->nomemprof--;
-
- scvg = runtime·newproc1((byte*)runtime·MHeap_Scavenger, nil, 0, 0, runtime·schedinit);
}
extern void main·init(void);
@@ -228,6 +226,7 @@ runtime·main(void)
// to preserve the lock.
runtime·LockOSThread();
runtime·sched.init = true;
+ scvg = runtime·newproc1((byte*)runtime·MHeap_Scavenger, nil, 0, 0, runtime·main);
main·init();
runtime·sched.init = false;
if(!runtime·sched.lockmain)
@@ -587,10 +586,11 @@ top:
mput(m);
}
- // Look for deadlock situation: one single active g which happens to be scvg.
- if(runtime·sched.grunning == 1 && runtime·sched.gwait == 0) {
- if(scvg->status == Grunning || scvg->status == Gsyscall)
- runtime·throw("all goroutines are asleep - deadlock!");
+ // Look for deadlock situation.
+ if((scvg == nil && runtime·sched.grunning == 0) ||
+ (scvg != nil && runtime·sched.grunning == 1 && runtime·sched.gwait == 0 &&
+ (scvg->status == Grunning || scvg->status == Gsyscall))) {
+ runtime·throw("all goroutines are asleep - deadlock!");
}
m->nextg = nil;