From 857d0b48dbdf8b41dc5fe4823cd81a8a5298c1eb Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 17 Mar 2016 14:08:32 -0400 Subject: [PATCH] runtime: document sudog Change-Id: I85c0bcf02842cc32dbc9bfdcea27efe871173574 Reviewed-on: https://go-review.googlesource.com/20774 Reviewed-by: Brad Fitzpatrick --- src/runtime/runtime2.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 89774791eb..a54dc552c1 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -210,6 +210,16 @@ type gobuf struct { bp uintptr // for GOEXPERIMENT=framepointer } +// sudog represents a g in a wait list, such as for sending/receiving +// on a channel. +// +// sudog is necessary because the g ↔ synchronization object relation +// is many-to-many. A g can be on many wait lists, so there may be +// many sudogs for one g; and many gs may be waiting on the same +// synchronization object, so there may be many sudogs for one object. +// +// sudogs are allocated from a special pool. Use acquireSudog and +// releaseSudog to allocate and free them. type sudog struct { // The following fields are protected by the hchan.lock of the // channel this sudog is blocking on. shrinkstack depends on -- 2.48.1