Idle time

leonp at plris.com leonp at plris.com
Sun Oct 30 19:47:04 UTC 2005


On Sunday, 30 בOctober 2005 20:42, Pavel Pisa wrote:
> 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);
> }
May be I do not catch something in your code, but it seems to me that the "if" 
clause will work also in the case of task switch and then time_acc will be 
incorrect. I thought about the opposite case - if the time between loops is 
greater then max_expected_loop_time, then it means that there was task switch 
and we mast restart the time counting. But this is too inaccurate...


> 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.
Although the 860 do has the MMU, this, IMHO, is negligible, and I thought that 
this must work, but experiments showed that the error is too much, I was not 
able to understand why yet.


> Best wishes
>
>                 Pavel Pisa
>         e-mail: pisa at cmp.felk.cvut.cz
>         www:    http://cmp.felk.cvut.cz/~pisa
>         work:   http://www.pikron.com
Thank you for your reply. I will investigate the second case more deeply - if 
you think the same way, it must work...:-)
-- 
Dr.Leon M.Pollak
Director
PLR Information Systems Ltd.



More information about the users mailing list