0

Just for the fun I made a little programme to display the activity of my cpu on ubuntu. My program read and parse the /proc/cpuinfo file, and it works.

But there is the deal, I display the data and next to it I opened htop and the cpu usage is a little bit different. After some test with infinit loop I found that htop said that only one core is at 100% (seem logic) but cpuinfo said that all my 8 cores are at 100%. Is there any explanation why there is thoses differences ?

My pc run with an intel i7 10510U, on unbutu 18.04.

Thanks.

Thibaud
  • 1,059
  • 4
  • 14
  • 27
  • Can you show an example of data from your `/etc/cpuinfo` for one processor? My `/etc/cpuinfo` is nothing like `htop`. The `/etc/cpuinfo` on my Ubuntu just shows static detailed specifications for the processor. It doesn't show real time processor utilization, which is one of the things that `htop` does. – lurker May 08 '20 at 21:46
  • 2
    The only usage info in `/proc/cpuinfo` is the current clock frequency, not load. On Intel "client" chips like your laptop, all cores have their clock frequencies tied together so load on one raises the effective frequency of all of them. (Of course cores that are in low-power sleep don't have their clock ticking at all, which is why "single core turbo" is still a thing.) BTW, I assume you mean [i7-10510U](https://ark.intel.com/content/www/us/en/ark/products/196449/intel-core-i7-10510u-processor-8m-cache-up-to-4-90-ghz.html) comet lake; 4-digit 10xx chips are Ice Lake and don't end with U. – Peter Cordes May 08 '20 at 21:50
  • So if I understood, when a task is running all cpu frequency are raising because they are linked but it doesn't means they are all "working" that fast on a task ? If so how can I get the load of each core ? – Thibaud May 08 '20 at 21:59
  • 1
    Right. CPU frequency tells you nothing about process scheduling (except for indirect effects if tasks use enough CPU time back to back that the governor decides to raise the frequency). You find load info the same way `htop` does; from `/proc/stat` and other files. `htop` is open source, have a look. And at kernel docs for `/proc` – Peter Cordes May 08 '20 at 22:06
  • Thanks a lot you explain everything ! :) – Thibaud May 08 '20 at 22:08

0 Answers0