diff options
author | Russ Cox <rsc@golang.org> | 2010-01-09 09:47:45 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-01-09 09:47:45 -0800 |
commit | 2db08122e36c137a36ab9768ffceae332c1695f1 (patch) | |
tree | 95bbb1afaaaabb0ad3401feb03cc930f8f9bd2d8 /src/pkg/runtime/proc.c | |
parent | 0ba4fada5796425dc0afa524f2537f4f6263e8da (diff) | |
download | golang-2db08122e36c137a36ab9768ffceae332c1695f1.tar.gz |
runtime: check for preemption due to garbage collection
in various already expensive routines.
helps keep cpu utilization up when GOMAXPROCS > 1,
but not a full solution.
http://groups.google.com/group/golang-nuts/t/7a9535c4136d3e2
R=r
CC=golang-dev
http://codereview.appspot.com/184043
Diffstat (limited to 'src/pkg/runtime/proc.c')
-rw-r--r-- | src/pkg/runtime/proc.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 6ac4090eb..6324b4be4 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -14,6 +14,8 @@ G g0; // idle goroutine for m0 static int32 debug = 0; +int32 gcwaiting; + // Go scheduler // // The go scheduler's job is to match ready-to-run goroutines (`g's) @@ -362,6 +364,7 @@ void stoptheworld(void) { lock(&sched); + gcwaiting = 1; sched.mcpumax = 1; while(sched.mcpu > 1) { noteclear(&sched.stopped); @@ -379,6 +382,7 @@ void starttheworld(void) { lock(&sched); + gcwaiting = 0; sched.mcpumax = sched.gomaxprocs; matchmg(); unlock(&sched); |