Index: src/pkg/co/sysconf_linux.go |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/src/pkg/co/sysconf_linux.go |
@@ -0,0 +1,33 @@ |
+// Copyright 2011 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 co |
+ |
+import ( |
+ "bytes" |
+ "io/ioutil" |
+ "os" |
+) |
+ |
+func sysInitOS() { |
+ f, err := os.Open("/proc/cpuinfo") |
+ if err != nil { |
+ print("co.SysConf: failed to open /proc/cpuinfo (", err.String(), ")\n") |
+ return |
+ } |
+ info, err := ioutil.ReadAll(f) |
+ if err != nil { |
+ print("co.SysConf: failed to read /proc/cpuinfo (", err.String(), ")\n") |
+ return |
+ } |
+ siblings := sysParam(info, "siblings") |
+ assignMax(&siblings, 1) |
+ cores := sysParam(info, "cpu cores") |
+ assignMax(&cores, 1) |
+ sysConf[ConfThreadCount] = bytes.Count(info, bytes.NewBufferString("processor").Bytes()) |
+ sysConf[ConfProcessorCount] = sysConf[ConfThreadCount] / siblings |
+ sysConf[ConfCoreCount] = sysConf[ConfProcessorCount] * cores |
+ sysConf[ConfNumaNodeCount] = sysConf[ConfProcessorCount] |
+ sysConf[ConfCacheLineSize] = sysParam(info, "cache_alignment") |
+} |