Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(416)

Unified Diff: src/pkg/co/sysconf_linux.go

Issue 4850045: co: new package
Patch Set: diff -r d499fb951a9e https://go.googlecode.com/hg/ Created 12 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/co/sysconf_freebsd.go ('k') | src/pkg/co/sysconf_plan9.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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")
+}
« no previous file with comments | « src/pkg/co/sysconf_freebsd.go ('k') | src/pkg/co/sysconf_plan9.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b