summaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorKeith Rarick <kr@xph.us>2010-12-07 18:06:31 -0500
committerKeith Rarick <kr@xph.us>2010-12-07 18:06:31 -0500
commit12807c6d23653d879910986bac9a58d33cb24478 (patch)
tree762b73f94c8951dd2a032b71935263d43d4dd37d /src/pkg/runtime
parent196467cf446bef66960afe5d907c9cef9712615a (diff)
downloadgo-12807c6d23653d879910986bac9a58d33cb24478.tar.gz
runtime: add Goroutines
R=rsc CC=golang-dev http://codereview.appspot.com/3508041 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/debug.go3
-rw-r--r--src/pkg/runtime/proc.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go
index b5f6571fa..3cc5472f6 100644
--- a/src/pkg/runtime/debug.go
+++ b/src/pkg/runtime/debug.go
@@ -26,6 +26,9 @@ func GOMAXPROCS(n int) int
// Cgocalls returns the number of cgo calls made by the current process.
func Cgocalls() int64
+// Goroutines returns the number of goroutines that currently exist.
+func Goroutines() int32
+
type MemStatsType struct {
// General statistics.
// Not locked during update; approximate.
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 31641ba98..ff8673a31 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -1192,3 +1192,10 @@ runtime·mid(uint32 ret)
ret = m->id;
FLUSH(&ret);
}
+
+void
+runtime·Goroutines(int32 ret)
+{
+ ret = runtime·sched.gcount;
+ FLUSH(&ret);
+}