Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my Ubuntu 12.04, with psensor, I saw a percentage number updated for cpu usage. I wonder how this percentage caculated? Specifically, what is the numerator and denominator in the ratio?


share|improve this question
up vote 5 down vote accepted

The processor usage percent is calculated with "the amount of time that the processor is not on idle". I mean, this calc is made from a counter that register the usage of the "idle" running process. While another preocesses "rob" the processor power from the idle process, the idle processor consumer register is decreased by a factor; as the time line is fixed and constant, the (1-"%time in the idle taks") is the amount of processor load used for all processes running on a processor:

enter image description here

Defining CPU utilization

For our purposes, I define CPU utilization, U, as the amount of time not in the idle task, as shown in Equation 1.

The idle task is the task with the absolute lowest priority in a multitasking system. This task is also sometimes called the background task or background loop, shown in Listing 1. This logic traditionally has a while(1) type of loop. In other words, an infinite loop spins the CPU waiting for an indication that critical work needs to be done.

Listing 1: Simple example of a background loop

int main( void )

   while(1)      /* endless loop - spin in the background */
      ... do other non-time critical logic here.

This depiction is actually an oversimplification, as some "real" work is often done in the background task. However, the logic coded for execution during the idle task must have no hard real-time requirements because there's no guarantee when this logic will complete. In fact, one technique you can use in an overloaded system is to move some of the logic with less strict timing requirements out of the hard real-time tasks and into the idle task.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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