rameshjanjyam (2) [Avatar] Offline
#1
as per listing 6.6 I have used NumCPU() function to find out the number of cpus on my machine. here is my code

package main

import "runtime"
import "fmt"

func main() {
fmt.Println(runtime.NumCPU())
}


This outputs "4".

but my mac hardware overview displays the below information
processor name: intel core i7
Number of processors: 1
Total number of cores: 2

form where does that 4 come from which is displayed by running that go program.
Bill Kennedy (68) [Avatar] Offline
#2
Re: runtime.NumCPU() displaying incorrect information
You are not running in a VM at all?

I will have to ask why you are not getting a valid value.
Nylar (1) [Avatar] Offline
#3
Re: runtime.NumCPU() displaying incorrect information
I think the reason that it is reporting 4 instead of 2 is because it is counting the number of logical CPUs.

http://golang.org/pkg/runtime/#NumCPU

NumCPU returns the number of logical CPUs on the local machine.
Bill Kennedy (68) [Avatar] Offline
#4
Re: runtime.NumCPU() displaying incorrect information
Ok, I will make that more clear in the chapter. Thanks.