user1120875
user1120875

Reputation: 21

Calculate process utilization in hyper-threading machine

I am trying to calculate a process utilization on my machine with Intel hyper-threading.

I have one problem when trying to do the calculation:

I am counting the loops my process is doing when running alone on the physical core and counting it when another process (identical one) is running on the other logical core (same physical core).

I see there is a diff in the amount of loops my process is doing. I guess it's related to the fact I am running in hyper-threading machine.

Is there a way to know what is the exact running time my process did so I will be able to add it to my calculation when I am trying to calculate the process utilization?

Upvotes: 1

Views: 873

Answers (1)

ugoren
ugoren

Reputation: 16449

You can only tell how much of the logical CPU's time a process takes. You can't tell how much it uses the physical CPU, and it isn't really defined.
HyperThreading (or, at least, the more modern SMT) doesn't work by dividing the physical CPU time between two threads. It works by assigning work to the execution units within the CPU (and there are several such units).
So it's possible for both threads to run at once - there are several integer execution units, and some others (memory, floating point).

Bottom line - if a thread takes 100% of the logical CPU, then it takes 100% CPU. That's all you can tell.

Upvotes: 2

Related Questions