EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Idle time of a processor

Started by vivek March 1, 2008
How do i measure the idle time of a processor? I use RTX and ARM7.
On Fri, 29 Feb 2008 23:35:25 -0800 (PST), I said, "Pick a card, any
card" and vivek <gvivek2004@gmail.com> instead replied:

>How do i measure the idle time of a processor? I use RTX and ARM7.
A paradoxical question if I ever saw one. Using the processor itself means the processor is not idle any longer for the period of time that the measurement is being taken. Thus, to accurately do such a thing requires and external measuring device of some kind. An RTC would work. At the end of any routine, read the RTC and poke the result into a flash memory location at an even numbered address. At the start of any routine, read and poke the result into the next address. Continue this ad nauseam Using a specially written routine later, use the results to determine processor idle time after you read the first and last times to determine total time. That's one way. -- Ray
vivek wrote:
> How do i measure the idle time of a processor? I use RTX and ARM7.
I assume you mean the time that is left over, after the time taken by all the useful application tasks (threads), in a preemptively scheduled system. For this to make sense, you must first define a period or window of time for the measurement. For example, you could ask for the "idle time" in periods of one second, or 10 seconds, depending on the frequencies of your application tasks. A traditional method is to make the kernel's "idle task" (sometimes known as the "null task" or "background task") run a loop and count how many iterations of a loop it can finish in the given period (one second, say). If the number is zero, there is no (or very little) idle time in this period; larger numbers mean more idle time. Calibrate the scale by measuring the number in a totally idle system (no activations of application tasks). This method does not work if your kernel puts the processor in some kind of idle (stopped) state when there are no application tasks to run. Moreover, this method is imprecise, but then a requirement for a certain percentage of idle time is not a precise requirement. It is usually expected to show that the system is not close to overload, but there can be a large amount of overall "idle" time even if some short tasks are very close to missing their tight deadlines. A proper schedulability analysis or response-time analysis is better since it shows the amount of slack or margin for each task and deadline. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .
On Mar 1, 12:35=A0pm, vivek <gvivek2...@gmail.com> wrote:
> How do i measure the idle time of a processor? I use RTX and ARM7.
You may need to use some method that is external to the processor. You can try reading the clock ticks via some specific port. Mostly, this option should be available with the processor. Few design of watch dog timers are based on a similar concept. There must be some provision with the kind of processor you use to enable certain bits to get the idle time of the processor, else you can write your own routine to toggle certain bit whenever you are aware that there is no activitiy done by processor or if any activity is carried on by the processor. A simple routine based on the combination of few flags and 'if' condition should make it possible. Also, you have to take care whenever a task is getting invoked and other states of the different tasks as flags are involved here. You can also have a dummy low prirority task . Based on the number of times that low priority task is getting invoked, you can calculate the total duration of idleness of your processor. (Because, this low priority dummy task will get invoked only if the processor has finished up with its high priority tasks and it should be the idle time of the processor) . You need to track this task between the high priority tasks.So, if you draw a graph based on this simple calculations, you can find the idle time of the processor. However, we need to take care of the time spent for the interrupt handling as it is hidden in this scenario. Karthik Balaguru

vivek wrote:

> How do i measure the idle time of a processor? I use RTX and ARM7.
Besides the other suggestions a very old trick to determine the relative amount of time in the idle task can be very useful. Set an I/O bit at the start of the idle task and clear it when you exit. Filter the output pin with a small a low pass RC. Measure the voltage as the processor is running it is directly in proportion to the amount of time in the idle task. Regards -- Walter Banks Byte Craft Limited Tel. (519) 888-6911 http://www.bytecraft.com walter@bytecraft.com
On Sat, 01 Mar 2008 06:12:39 -0500, the renowned Walter Banks
<walter@bytecraft.com> wrote:

> > >vivek wrote: > >> How do i measure the idle time of a processor? I use RTX and ARM7. > >Besides the other suggestions a very old trick to determine the >relative amount of time in the idle task can be very useful. > >Set an I/O bit at the start of the idle task and clear it when >you exit. Filter the output pin with a small a low pass RC. >Measure the voltage as the processor is running it is directly >in proportion to the amount of time in the idle task. > >Regards
That, or sometimes you can just look at it with a 'scope and see/measure the duty cycle. Best regards, Spehro Pefhany -- "it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com
On 2008-03-01, vivek <gvivek2004@gmail.com> wrote:

> How do i measure the idle time of a processor? I use RTX and > ARM7.
Assuming you've read the RTX manuals and it doesn't provide such a measurement... A decent way to get a relative measurement is to increment a counter in loop in the idle task (assuming you're not putting the processor to sleep). Every second, print out the difference between the current value of the idle timer and the previous value. If you are putting the processor to sleep, then set a port pin before you go to sleep, and clear it when you wake up. Look at the pin with a 'scope. -- Grant Edwards grante Yow! I decided to be JOHN at TRAVOLTA instead!! visi.com
Walter Banks wrote:
> vivek wrote: > >> How do i measure the idle time of a processor? I use RTX and ARM7. > > Besides the other suggestions a very old trick to determine the > relative amount of time in the idle task can be very useful. > > Set an I/O bit at the start of the idle task and clear it when > you exit. Filter the output pin with a small a low pass RC. > Measure the voltage as the processor is running it is directly > in proportion to the amount of time in the idle task.
Considering that active time should vary considerably in most systems, this is probably as accurate as necessary. It is certainly simple. You can figure the acquisition time (for the idle value) to be about 3 to 4 time-constants. -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section. -- Posted via a free Usenet account from http://www.teranews.com
On Mar 1, 12:35=A0pm, vivek <gvivek2...@gmail.com> wrote:
> How do i measure the idle time of a processor? I use RTX and ARM7.
Another trick - You can have a counter incremented for active state and another counter for idle state. These states will be decided and the corresponding state counter incremented by generating an interrupt at some time interval. This interrupt would be checking the state of the processor and increment the corresponding counters. Karthik Balaguru

Memfault Beyond the Launch