aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/debug.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-01-09 19:37:19 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-01-09 19:37:19 +0000
commit2193ad7fbf3e917a0ef5a2b48e13f84da1be44f1 (patch)
tree979f6f9c20889cbbef8a131ed63b6e7f4b7216f6 /libgo/go/runtime/debug.go
parentd1261ac6eb62f0c589ef314c61884ab445e5552b (diff)
downloadgcc-2193ad7fbf3e917a0ef5a2b48e13f84da1be44f1.zip
gcc-2193ad7fbf3e917a0ef5a2b48e13f84da1be44f1.tar.gz
gcc-2193ad7fbf3e917a0ef5a2b48e13f84da1be44f1.tar.bz2
runtime: copy more of scheduler from Go 1.7 runtime
This started by moving procresize from C to Go so that we can pass the right type to the memory allocator when allocating a p, which forced the gomaxprocs variable to move from C to Go, and everything else followed from that. Reviewed-on: https://go-review.googlesource.com/34916 From-SVN: r244236
Diffstat (limited to 'libgo/go/runtime/debug.go')
-rw-r--r--libgo/go/runtime/debug.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/libgo/go/runtime/debug.go b/libgo/go/runtime/debug.go
index 43f6e1e..55937ff 100644
--- a/libgo/go/runtime/debug.go
+++ b/libgo/go/runtime/debug.go
@@ -14,7 +14,25 @@ import (
// 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
+func GOMAXPROCS(n int) int {
+ if n > _MaxGomaxprocs {
+ n = _MaxGomaxprocs
+ }
+ lock(&sched.lock)
+ ret := int(gomaxprocs)
+ unlock(&sched.lock)
+ if n <= 0 || n == ret {
+ return ret
+ }
+
+ stopTheWorld("GOMAXPROCS")
+
+ // newprocs will be processed by startTheWorld
+ newprocs = int32(n)
+
+ startTheWorld()
+ return ret
+}
// NumCPU returns the number of logical CPUs usable by the current process.
//