aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorDaniel Morsing <daniel.morsing@gmail.com>2017-08-02 19:01:17 +0100
committerDaniel Morsing <daniel.morsing@gmail.com>2017-08-15 19:18:00 +0000
commit32b94f13cf35e619a0dae6e1e381adc7e182d283 (patch)
tree64d58aca0d055ac7ced3b9a611d5ed36e9980d6c /src/runtime/runtime2.go
parent89d74f54168619cf1f36b6868626fbb1237c1deb (diff)
downloadgo-32b94f13cf35e619a0dae6e1e381adc7e182d283.tar.xz
runtime: move selectdone into g
Writing to selectdone on the stack of another goroutine meant a pretty subtle dance between the select code and the stack copying code. Instead move the selectdone variable into the g struct. Change-Id: Id246aaf18077c625adef7ca2d62794afef1bdd1b Reviewed-on: https://go-review.googlesource.com/53390 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 21b1758af9..e4b4f91b5e 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -272,11 +272,14 @@ type sudog struct {
// channel this sudog is blocking on. shrinkstack depends on
// this for sudogs involved in channel ops.
- g *g
- selectdone *uint32 // CAS to 1 to win select race (may point to stack)
- next *sudog
- prev *sudog
- elem unsafe.Pointer // data element (may point to stack)
+ g *g
+
+ // isSelect indicates g is participating in a select, so
+ // g.selectDone must be CAS'd to win the wake-up race.
+ isSelect bool
+ next *sudog
+ prev *sudog
+ elem unsafe.Pointer // data element (may point to stack)
// The following fields are never accessed concurrently.
// For channels, waitlink is only accessed by g.
@@ -367,6 +370,7 @@ type g struct {
cgoCtxt []uintptr // cgo traceback context
labels unsafe.Pointer // profiler labels
timer *timer // cached timer for time.Sleep
+ selectDone uint32 // are we participating in a select and did someone win the race?
// Per-G GC state