htop icon indicating copy to clipboard operation
htop copied to clipboard

[Question or Bug] Should not CPU number start at 1, rather than 0?

Open rubyFeedback opened this issue 2 years ago • 1 comments

Lately I got a CPU with 12 cores on my new machines.

When I start htop, however, I see that on the top line it begins to start count at #0. So my first CPU is ... zero.

I never realised this. I looked at my older computer and it begins at 0 too.

Isn't this incorrect? Do we have a CPU #0 or is this because of the C language where we all start to count at 0?

Here is my reasoning:

  • If I have 4 CPU cores. I start at: 1, then 2, then 3, then 4.

If I start at 0, then I end up with ... 3. But that seems wrong? Or am I missing some explanation about this?

rubyFeedback avatar Sep 09 '22 16:09 rubyFeedback

Most system utilities that display CPU information number the cores from 0 through N-1. Thus a CPU with 12 cores will display as having cores 0 through 11 in e.g. /proc/cpuinfo. htop simply mirrors what is already common display practice.

If you rather want to have your cores numbered starting from 1 you'll find a setting for this in the Display Options (reachable by F2).

NB: Counting from 0, 1, 2, 3 gives you 4 numbers you just enumerated. ;-)

BenBE avatar Sep 09 '22 21:09 BenBE