On my desktop, I have a little widget that tells me my current CPU usage. It also shows the usage for each of my two cores.
I always wondered, how does the CPU calc
Well, as far as I understand it there's a giant
while(true){}
loop that the operating systems spins up. Your process is managed from within that loop. It allows external code to be executed directly on the processor in chunks. Without exaggerating too much, this is an uber-simplification of what is actually going on.