6

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

5

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.

  • 2
    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
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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.