diff options
| author | Russ Cox <rsc@golang.org> | 2016-01-06 21:16:01 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2016-01-13 01:46:01 +0000 |
| commit | fac8202c3ffdddf5d2b35a2c3620c1eb56018b9b (patch) | |
| tree | ec9ed1a66478563127a9faa17fe8764705692c6a /src/runtime/runtime2.go | |
| parent | 1e066cad1ba23f4064545355b8737e4762dd6838 (diff) | |
| download | go-fac8202c3ffdddf5d2b35a2c3620c1eb56018b9b.tar.xz | |
runtime: make NumGoroutine and Stack agree not to include system goroutines
[Repeat of CL 18343 with build fixes.]
Before, NumGoroutine counted system goroutines and Stack (usually) didn't show them,
which was inconsistent and confusing.
To resolve which way they should be consistent, it seems like
package main
import "runtime"
func main() { println(runtime.NumGoroutine()) }
should print 1 regardless of internal runtime details. Make it so.
Fixes #11706.
Change-Id: If26749fec06aa0ff84311f7941b88d140552e81d
Reviewed-on: https://go-review.googlesource.com/18432
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index d9a449b68b..54c4686f79 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -408,9 +408,11 @@ const ( ) type schedt struct { - lock mutex + // accessed atomically. keep at top to ensure alignment on 32-bit systems. + goidgen uint64 + lastpoll uint64 - goidgen uint64 + lock mutex midle muintptr // idle m's waiting for work nmidle int32 // number of idle m's waiting for work @@ -418,6 +420,8 @@ type schedt struct { mcount int32 // number of m's that have been created maxmcount int32 // maximum number of m's allowed (or die) + ngsys uint32 // number of system goroutines; updated atomically + pidle puintptr // idle p's npidle uint32 nmspinning uint32 // See "Worker thread parking/unparking" comment in proc.go. @@ -445,7 +449,6 @@ type schedt struct { stopnote note sysmonwait uint32 sysmonnote note - lastpoll uint64 // safepointFn should be called on each P at the next GC // safepoint if p.runSafePointFn is set. |
