aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/stack.c
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-07-19 01:22:26 +0400
committerDmitriy Vyukov <dvyukov@google.com>2013-07-19 01:22:26 +0400
commitbc31bcccd3b94ec8dd324e523c4c7ae9180b937f (patch)
treeae43ea1cd52087133568592922685845539505ba /src/pkg/runtime/stack.c
parent58f12ffd79df8ae369afa7ec60ee26d72ce2d843 (diff)
downloadgo-bc31bcccd3b94ec8dd324e523c4c7ae9180b937f.tar.xz
runtime: preempt long-running goroutines
If a goroutine runs for more than 10ms, preempt it. Update #543. R=rsc CC=golang-dev https://golang.org/cl/10796043
Diffstat (limited to 'src/pkg/runtime/stack.c')
-rw-r--r--src/pkg/runtime/stack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pkg/runtime/stack.c b/src/pkg/runtime/stack.c
index 2ba29956b1..76e2ca62df 100644
--- a/src/pkg/runtime/stack.c
+++ b/src/pkg/runtime/stack.c
@@ -244,11 +244,11 @@ runtime·newstack(void)
if(gp->stackguard0 == (uintptr)StackPreempt) {
if(gp == m->g0)
runtime·throw("runtime: preempt g0");
- if(oldstatus == Grunning && (m->p == nil || m->p->status != Prunning))
+ if(oldstatus == Grunning && m->p == nil)
runtime·throw("runtime: g is running but p is not");
// Be conservative about where we preempt.
// We are interested in preempting user Go code, not runtime code.
- if(oldstatus != Grunning || m->locks || m->mallocing || m->gcing) {
+ if(oldstatus != Grunning || m->locks || m->mallocing || m->gcing || m->p->status != Prunning) {
// Let the goroutine keep running for now.
// gp->preempt is set, so it will be preempted next time.
gp->stackguard0 = gp->stackguard;