Idle time

Pavel Pisa ppisa4lists at pikron.com
Sun Oct 30 18:42:39 UTC 2005


On Sunday 30 October 2005 18:17, leonp at plris.com wrote:
> Hello, all.
>
> 	I should like to measure the CPU free time in my application which runs on
> MPC860.
> 	The obvious way seemed to me to look at the decrementer value each time I
> enter the idle task, while inside the idle task copy the decrementer value
> in the loop into intermediate variable. The difference will show how much
> time the CPU was in the idle task.
> 	The problem is, that I do not see any efficient way to do this. The "user
> extension" mechanism, if I understood it correctly, will add one routine to
> ALL task switches, thus I shall waste a lot (relatively) of time on a
> service function.
> 	If somebody can advice some more efficient decision, I shall be very glad.
>
> Thanks.

Hello Leon,

I have next two ideas, which could work.

Do busy loop in idle which would read time base
and remember value. If previous value is more
ancient, than time expected for loop, add the
time to the busy time accumulator

long long time_acc=0;

{
  long long old_time;
  long long new_time;
  
  old_time=get_time();

  do{
    new_time=get_time();
    if(new_time-old_time>max_expected_loop_time)
      time_acc+=new_time-old_time;
    old_time=new_time;
  }while(1);
}

Other simpler solution could be to measure number
of idle loops per second for idle system and use
it as base for ratio computation if system is loaded.

The 860 has no MMU and there should not be some big
jitter resulting from page lookup in the iddle loop.
It has cache, so the first idle loop round after some activity
could take little longer and idle loop trashes cache for
other threads. But both ideas should have many times
smaller overhead to the real application than some
extensions hooks.

Best wishes

                Pavel Pisa
        e-mail: pisa at cmp.felk.cvut.cz
        www:    http://cmp.felk.cvut.cz/~pisa
        work:   http://www.pikron.com



More information about the users mailing list