diff options
author | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
commit | 8528da672cc093d4dd06732819abc1f7b6b5a46e (patch) | |
tree | 334be80d4a4c85b77db6f6fdb67cbf0528cba5f5 /src/runtime/debug.go | |
parent | 73bcb69f272cbf34ddcc9daa56427a8683b5a95d (diff) | |
download | go-8528da672cc093d4dd06732819abc1f7b6b5a46e.tar.gz |
build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
Diffstat (limited to 'src/runtime/debug.go')
-rw-r--r-- | src/runtime/debug.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/runtime/debug.go b/src/runtime/debug.go new file mode 100644 index 000000000..bb4bd60ed --- /dev/null +++ b/src/runtime/debug.go @@ -0,0 +1,56 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +import "unsafe" + +// Breakpoint executes a breakpoint trap. +func Breakpoint() + +// LockOSThread wires the calling goroutine to its current operating system thread. +// Until the calling goroutine exits or calls UnlockOSThread, it will always +// execute in that thread, and no other goroutine can. +func LockOSThread() + +// UnlockOSThread unwires the calling goroutine from its fixed operating system thread. +// If the calling goroutine has not called LockOSThread, UnlockOSThread is a no-op. +func UnlockOSThread() + +// GOMAXPROCS sets the maximum number of CPUs that can be executing +// simultaneously and returns the previous setting. If n < 1, it does not +// change the current setting. +// The number of logical CPUs on the local machine can be queried with NumCPU. +// This call will go away when the scheduler improves. +func GOMAXPROCS(n int) int { + g := getg() + g.m.scalararg[0] = uintptr(n) + onM(gomaxprocs_m) + n = int(g.m.scalararg[0]) + g.m.scalararg[0] = 0 + return n +} + +func gomaxprocs_m() // proc.c + +// NumCPU returns the number of logical CPUs on the local machine. +func NumCPU() int { + return int(ncpu) +} + +// NumCgoCall returns the number of cgo calls made by the current process. +func NumCgoCall() int64 { + var n int64 + for mp := (*m)(atomicloadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink { + n += int64(mp.ncgocall) + } + return n +} + +// NumGoroutine returns the number of goroutines that currently exist. +func NumGoroutine() int { + return int(gcount()) +} + +func gcount() int32 |