R=rsc
DELTA=29 (28 added, 1 deleted, 0 changed)
OCL=32829
CL=32837
// 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. This call will go away when the scheduler improves.
+func GOMAXPROCS(n int)
g->lockedm = m;
}
+// delete when scheduler is stronger
+void
+runtime·GOMAXPROCS(int32 n)
+{
+ if(n < 1)
+ n = 1;
+
+ lock(&sched);
+ sched.gomaxprocs = n;
+ sched.mcpumax = n;
+ // handle fewer procs
+ while(sched.mcpu > sched.mcpumax) {
+ noteclear(&sched.stopped);
+ sched.waitstop = 1;
+ unlock(&sched);
+ notesleep(&sched.stopped);
+ lock(&sched);
+ }
+ // handle more procs
+ matchmg();
+ unlock(&sched);
+}
+
void
runtime·UnlockOSThread(void)
{
ret = m->id;
FLUSH(&ret);
}
-
"flag";
"fmt";
"math";
+ "runtime";
)
var n = flag.Int("n", 2000, "count")
func main() {
flag.Parse();
+ runtime.GOMAXPROCS(*nCPU);
N := *n;
u := make(Vec, N);
for i := 0; i < N; i++ {