From 5328df6534b9fa2ca83cbbac013ef1e094e11907 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 9 Jan 2010 09:47:45 -0800 Subject: 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 https://golang.org/cl/184043 --- src/pkg/runtime/malloc.cgo | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/pkg/runtime/malloc.cgo') diff --git a/src/pkg/runtime/malloc.cgo b/src/pkg/runtime/malloc.cgo index e34393a85b..948257973e 100644 --- a/src/pkg/runtime/malloc.cgo +++ b/src/pkg/runtime/malloc.cgo @@ -27,10 +27,11 @@ mallocgc(uintptr size, uint32 refflag, int32 dogc) void *v; uint32 *ref; + if(gcwaiting && g != m->g0) + gosched(); if(m->mallocing) throw("malloc/free - deadlock"); m->mallocing = 1; - if(size == 0) size = 1; -- cgit v1.3