diff options
| author | Rick Hudson <rlh@golang.org> | 2014-09-03 12:06:36 -0400 |
|---|---|---|
| committer | Rick Hudson <rlh@golang.org> | 2014-09-03 12:06:36 -0400 |
| commit | 56bd176e1d5f0145936128c0dc1f931cc5a84c0b (patch) | |
| tree | 19819821b463bc0b875143c633cdbdbe80f1f099 /src/pkg/runtime/stack.c | |
| parent | f44073785a99c2b6656156fe42055f81d29f5e1a (diff) | |
| download | go-56bd176e1d5f0145936128c0dc1f931cc5a84c0b.tar.xz | |
runtime: Start and stop individual goroutines at gc safepoints
Code to bring goroutines to a gc safepoint one at a time,
do some work such as scanning, and restart the
goroutine, and then move on to the next goroutine.
Currently this code does not do much useful work
but this infrastructure will be critical to future
concurrent GC work.
Fixed comments reviewers.
LGTM=rsc
R=golang-codereviews, rsc, dvyukov
CC=golang-codereviews
https://golang.org/cl/131580043
Diffstat (limited to 'src/pkg/runtime/stack.c')
| -rw-r--r-- | src/pkg/runtime/stack.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c index 62ec5993a8..6a57ab08cf 100644 --- a/src/pkg/runtime/stack.c +++ b/src/pkg/runtime/stack.c @@ -936,6 +936,14 @@ runtime·newstack(void) runtime·throw("runtime: g is running but p is not"); if(oldstatus == Gsyscall && g->m->locks == 0) runtime·throw("runtime: stack growth during syscall"); + if(oldstatus == Grunning && gp->preemptscan) { + runtime·gcphasework(gp); + runtime·casgstatus(gp, Gwaiting, Grunning); + gp->stackguard0 = gp->stackguard; + gp->preempt = false; + gp->preemptscan = false; // Tells the GC premption was successful. + runtime·gogo(&gp->sched); // never return + } // Be conservative about where we preempt. // We are interested in preempting user Go code, not runtime code. |
