From 42486ffc5d435e01ca9491b64d3a52d39de169d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Fri, 29 Aug 2014 11:08:10 +0400 Subject: runtime: convert forcegc helper to Go Also fix a bunch of bugs: 1. Accesses to last_gc must be atomic (it's int64). 2. last_gc still can be 0 during first checks in sysmon, check for 0. 3. forcegc.g can be unitialized when sysmon accesses it: forcegc.g is initialized by main goroutine (forcegc.g = newproc1(...)), and main goroutine is unsynchronized with both sysmon and forcegc goroutine. Initialize forcegc.g in the forcegc goroutine itself instead. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, rsc https://golang.org/cl/136770043 --- src/pkg/runtime/runtime.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/pkg/runtime/runtime.h') diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index 4dfc4f2c42..21ccb76b3c 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -92,6 +92,7 @@ typedef struct ParForThread ParForThread; typedef struct CgoMal CgoMal; typedef struct PollDesc PollDesc; typedef struct DebugVars DebugVars; +typedef struct ForceGCState ForceGCState; /* * Per-CPU declaration. @@ -572,6 +573,13 @@ struct DebugVars int32 scavenge; }; +struct ForceGCState +{ + Mutex lock; + G* g; + uint32 idle; +}; + extern bool runtime·precisestack; extern bool runtime·copystack; @@ -774,6 +782,7 @@ extern uint32 runtime·cpuid_edx; extern DebugVars runtime·debug; extern uintptr runtime·maxstacksize; extern Note runtime·signote; +extern ForceGCState runtime·forcegc; /* * common functions and data -- cgit v1.3-5-g9baa