aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/proc.go')
-rw-r--r--src/pkg/runtime/proc.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/pkg/runtime/proc.go b/src/pkg/runtime/proc.go
index 32fe35e28c..6c295c7b18 100644
--- a/src/pkg/runtime/proc.go
+++ b/src/pkg/runtime/proc.go
@@ -29,6 +29,27 @@ const (
var parkunlock_c byte
+// start forcegc helper goroutine
+func init() {
+ go func() {
+ forcegc.g = getg()
+ forcegc.g.issystem = true
+ for {
+ lock(&forcegc.lock)
+ if forcegc.idle != 0 {
+ gothrow("forcegc: phase error")
+ }
+ atomicstore(&forcegc.idle, 1)
+ goparkunlock(&forcegc.lock, "force gc (idle)")
+ // this goroutine is explicitly resumed by sysmon
+ if debug.gctrace > 0 {
+ println("GC forced")
+ }
+ gogc(1)
+ }
+ }()
+}
+
// Gosched yields the processor, allowing other goroutines to run. It does not
// suspend the current goroutine, so execution resumes automatically.
func Gosched() {