diff options
Diffstat (limited to 'libgo/go/runtime/debug.go')
-rw-r--r-- | libgo/go/runtime/debug.go | 20 |
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. // |