| // 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. |
| // 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 { |
| semacquire(&worldsema, false) |
| gp.m.preemptoff = "GOMAXPROCS" |
| systemstack(stoptheworld) |
| // newprocs will be processed by starttheworld |
| systemstack(starttheworld) |
| // NumCPU returns the number of logical CPUs on the local machine. |
| // NumCgoCall returns the number of cgo calls made by the current process. |
| func NumCgoCall() int64 { |
| for mp := (*m)(atomicloadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink { |
| // NumGoroutine returns the number of goroutines that currently exist. |
| func NumGoroutine() int { |