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/hashmap.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/pkg/runtime/hashmap.c') diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c index 870274ae91..5bcd8bf416 100644 --- a/src/pkg/runtime/hashmap.c +++ b/src/pkg/runtime/hashmap.c @@ -744,6 +744,9 @@ mapaccess(Hmap *h, byte *ak, byte *av, bool *pres) { byte *res; + if(gcwaiting) + gosched(); + res = nil; if(hash_lookup(h, ak, (void**)&res)) { *pres = true; @@ -812,6 +815,9 @@ mapassign(Hmap *h, byte *ak, byte *av) byte *res; int32 hit; + if(gcwaiting) + gosched(); + res = nil; if(av == nil) { hash_remove(h, ak, (void**)&res); @@ -908,6 +914,9 @@ mapiterinit(Hmap *h) void runtime·mapiternext(struct hash_iter *it) { + if(gcwaiting) + gosched(); + it->data = hash_next(it); if(debug) { prints("runtime·mapiternext: iter="); -- cgit v1.3