9

I have a eight core machine. How can I find out how many cores are used by processes that I see in htop?

Timo
  • 6,332
theTuxRacer
  • 1,063

3 Answers3

8

In htop, press F2 or Sto enter setup, then use the arrows to navigate the Columns->Available Columns menu, select PROCESSOR and Enterto add a processor column. Then q to get back to the main screen.

Caleb
  • 70,105
  • 3
    This is great, but I believe this only shows WHICH core is being used, it is important to note that each item is still only running on 1 core at a time. The author asked how many cores were in use, not which one. – Caleb Apr 16 '11 at 14:20
  • For which cores are in use, you can use taskset -pc [pid] – Andrew Lambert Apr 16 '11 at 22:22
2

You can use ps -o pid,psr,comm -p <pid>[1], it displays on which core the process runs right now. Do this multiple times, and you get all cores.

For example:

while true; do echo -ne "`ps -o pid,psr,comm -p <pid>`"; done

[1] http://ask.xmodulo.com/cpu-core-process-is-running.html

LoLei
  • 121
1

I think most of the processes you will see in htop or ps are going to be individual threads or process that each run on one core, but you might notice many apps have several processes going to take advantage of the extra cores.

Caleb
  • 70,105