aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.h
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-08-29 11:08:10 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-08-29 11:08:10 +0400
commit42486ffc5d435e01ca9491b64d3a52d39de169d7 (patch)
treeac32833280ed781ec93442594b7e7a13154fcc02 /src/pkg/runtime/runtime.h
parentef64d9ffcc237fde9bcaed1fd00c5036c4f489de (diff)
downloadgo-42486ffc5d435e01ca9491b64d3a52d39de169d7.tar.xz
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
Diffstat (limited to 'src/pkg/runtime/runtime.h')
-rw-r--r--src/pkg/runtime/runtime.h9
1 files changed, 9 insertions, 0 deletions
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