Hello,
I wish to measure the CPU utlization for a cortex processor running an RTOS (keil RTX). Without an RTOS, i can measure the idle time to come to some conclusion. But with RTOS, can someone guide me how to measure CPU utlization?
Thanks & Best Regards Vivek
If the task that reads out the sample and clears the counter misses one run, then the counter may measure during two time slices.
Thanks.
i repeated the test for different frequencies. But the counter variable measuring the idle time counts the same number.
With increase in frequency, i was expecting the code to count up to a larger number.
Are you busy-looping the counter increment? You may not use a timer to increment the value, since then you have hardware acceleration and doesn't compute the availability of CPU instructions.
Ok. Will it work if i disable the flash accelerator ?
Also i observe that when i use Keil simulator and when i actually debug on a target, i get different values for same set of measurement with everything else remaining same.
Will it work if i disable the flash accelerator ?
don't do that. your system will crawl...
Don't assume that the simulator will do a 100% perfect job of consuming CPU cycles at an identical speed to the real processor.
I can disable flash acceleration for just for measurement purpose and i can re-enable it later
Vivek,
How are you resetting the counter? Through a second task or an interrupt routine?
If either is true then I think that the increment may not be an atomic function. Thus you may be clearing the value part way through an increment.
For instance, the first task reads the value from memory into a register, second task interrupts and clears the value in memory, first task resumes and increments the value in the register and then finally stores it back in memory. So it is like the second task never cleared the memory.
It you are using an interrupt routine to clear it you will need an atomic increment routine using an SWI, or through disabling the interrupt. If you use two tasks then 2 SWI routines 1 for increment and 1 for clearing.
RTX has SWI routines in its own code I think for much the same reason.
I use an interrupt routine and I mask this interrupt when I increment the counter variable for this reason.
Stuart