mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: more reliable preemption
Currently preemption signal g->stackguard0==StackPreempt can be lost if it is received when preemption is disabled (e.g. m->lock!=0). This change duplicates the preemption signal in g->preempt and restores g->stackguard0 when preemption is enabled. Update #543. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/10792043
This commit is contained in:
parent
a83748596c
commit
5887f142a3
7 changed files with 28 additions and 2 deletions
|
|
@ -250,7 +250,7 @@ runtime·newstack(void)
|
|||
// We are interested in preempting user Go code, not runtime code.
|
||||
if(oldstatus != Grunning || m->locks || m->mallocing || m->gcing) {
|
||||
// Let the goroutine keep running for now.
|
||||
// TODO(dvyukov): remember but delay the preemption.
|
||||
// gp->preempt is set, so it will be preempted next time.
|
||||
gp->stackguard0 = gp->stackguard;
|
||||
gp->status = oldstatus;
|
||||
runtime·gogo(&gp->sched); // never return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue