Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

require('os').cpus().length returns 24 .... can't understand how?

I have a windows desktop with this configuration: Intel Xeon(R) CPU E5645 @2.40GHz (2 processors)
with 24 GB RAM and 64-bit OS

When I run following code.

var cpuCount = require('os').cpus().length;

It returns cpuCount as 24

Can someone please explain what exactly does this mean? And how does it determine that I have 24 CPUs with just 2 processors.

like image 837
user3385957 Avatar asked Oct 16 '25 23:10

user3385957


1 Answers

http://ark.intel.com/products/48768/Intel-Xeon-Processor-E5645-12M-Cache-2_40-GHz-5_86-GTs-Intel-QPI?q=Xeon%20e5645

Advanced Technologies section. It says that your CPU supports Hyper-Threading

From the Wikipedia:

For each processor core that is physically present, the operating system addresses two virtual or logical cores ...

So, you have two processors with 6 physical cores each (but 12 logical or virtual):

(2 x 6) x 2 = 24

Also check out node.js docs:

os.cpus()

Returns an array of objects containing information about each CPU/core installed: model, speed (in MHz), and times (an object containing the number of milliseconds the CPU/core spent in: user, nice, sys, idle, and irq).

That's why array returned by require('os').cpus() contains 24 elements.

like image 139
schfkt Avatar answered Oct 19 '25 11:10

schfkt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!