My question concerns the way to calculate the CPU time a program takes. The idle task counter is here for that matter, but what is the frequency of the counter? And what is a convenient way to calculate/output the CPU %
To get CPU usage, today there is no tool to get percentage. The only way is to use idle task counter.
The counter is there only to get information, if in 60 minutes it is at zero or at millions. It even is not implemented as thread-safe, so it can happen that the value is not correct (counter incrementing is not done in atomic instruction). But in more than 99.999% cases, you get the right value from the counter.
If you rely on the counter value and you want to get time or percentage information, there is not any easy workaround to get it. That's because counter is running without any synchronization. The speed of the counter is determined only by dissassembling _mqx_idle_task code and to find out how many instruction does it take to increment by one. Note that number of instructions depends on your compiler settings. Then, you can compute how much time does it take to execute these instructions.
The Task Aware Debugger seems to have tools that will do this an much more.. Have not personally used it, but I have read up on it at www.freescale.com/mqx
As a concept, you can access the KERNAL_DATA_STRUCT->IDLE_LOOPX (there are 3 uint_32's with different resolutions you can use depending on the accuracy you want).
To work out the speed it ticks at, I would simply run a time slice thread that runs every X seconds and save the start ticks and end ticks (not processor ticks, the IDLE_LOOPX ticks). With that, you can calibrate a value for no load and work from there.
It should be very easy to work out the resolution of each timer. If you do it, will you share the results? Or maybe the MQX guys will tell us the resolution of the IDLE_LOOP counters for the dev boards...
Dam, I could have just worked it out in the time this post this response...
If we don't know the frequency, is there a counter at same frequency that never stops? This way we could have 2 values to calculate the CPU time %.
Anyway, i'll share any results if I get some.
CarlFST60L wrote:To work out the speed it ticks at, I would simply run a time slice thread that runs every X seconds and save the start ticks and end ticks (not processor ticks, the IDLE_LOOPX ticks). With that, you can calibrate a value for no load and work from there.
Yeah, I think it's a good way to procede.
I'll let you know if I got something.
Yes, this is because the MRAM is connected through the external bus and it has slower access times so it requires a wait state cycle to be inserted in the bus transfer. It's a performance tradeoff that is made in order to get a lot of extra non-volitile byte-writeable memory.
The internal Flash however is on the internal bus and its interleaved so it's very efficient. It can read a longword in 1 or 2 cycles.
Did anyone ever write a module to calculte CPU load?
Retrieving data ...