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

Delta Between Two Patch Sets: src/pkg/co/sysconf_linux.go

Issue 4850045: co: new package
Left Patch Set: diff -r 6f83246236f3 https://go.googlecode.com/hg/ Created 12 years, 7 months ago
Right Patch Set: diff -r d499fb951a9e https://go.googlecode.com/hg/ Created 12 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/co/sysconf_freebsd.go ('k') | src/pkg/co/sysconf_plan9.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package co 5 package co
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt"
10 "io/ioutil" 9 "io/ioutil"
11 "os" 10 "os"
12 ) 11 )
13 12
14 func sysInitOS() { 13 func sysInitOS() {
15 » f, err := os.Open("/proc/cpuingo") 14 » f, err := os.Open("/proc/cpuinfo")
16 if err != nil { 15 if err != nil {
17 » » fmt.Fprintf(os.Stderr, "co.SysConf: failed to open /proc/cpuinfo (%s)\n", err) 16 » » print("co.SysConf: failed to open /proc/cpuinfo (", err.String() , ")\n")
18 return 17 return
19 } 18 }
20 » info, err := ioutil.RealAll(f) 19 » info, err := ioutil.ReadAll(f)
21 if err != nil { 20 if err != nil {
22 » » fmt.Fprintf(os.Stderr, "co.SysConf: failed to read /proc/cpuinfo (%s)\n", err) 21 » » print("co.SysConf: failed to read /proc/cpuinfo (", err.String() , ")\n")
23 return 22 return
24 } 23 }
25 siblings := sysParam(info, "siblings") 24 siblings := sysParam(info, "siblings")
25 assignMax(&siblings, 1)
26 cores := sysParam(info, "cpu cores") 26 cores := sysParam(info, "cpu cores")
27 » sysConf[ConfThreadCount] = bytes.Count(info, "processor") 27 » assignMax(&cores, 1)
28 » sysConf[ConfThreadCount] = bytes.Count(info, bytes.NewBufferString("proc essor").Bytes())
28 sysConf[ConfProcessorCount] = sysConf[ConfThreadCount] / siblings 29 sysConf[ConfProcessorCount] = sysConf[ConfThreadCount] / siblings
29 sysConf[ConfCoreCount] = sysConf[ConfProcessorCount] * cores 30 sysConf[ConfCoreCount] = sysConf[ConfProcessorCount] * cores
30 sysConf[ConfNumaNodeCount] = sysConf[ConfProcessorCount] 31 sysConf[ConfNumaNodeCount] = sysConf[ConfProcessorCount]
31 sysConf[ConfCacheLineSize] = sysParam(info, "cache_alignment") 32 sysConf[ConfCacheLineSize] = sysParam(info, "cache_alignment")
32 } 33 }
LEFTRIGHT

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