vTaskGetRunTimeStats with always 100% on the same task
Hi all
I’m using the vTaskGetRunTimeStats() function to get the % time for each task. I have 7 tasks running.
When I use that function called by Task1 I get this:
Task1 100%
Task2 0%
Task3 0%
Task4 0%
Task5 0%
Task6 0%
Task7 0%
I was expecting something like:
Task1 10%
Task2 10%
Task3 25%
Task4 10%
Task5 15%
Task6 14%
Task7 16%
Why does Task1 is 100% and the others 0%?
Thank you in advance
vTaskGetRunTimeStats with always 100% on the same task
It is not clear if you are asking why Task1 takes 100% of the time or why your output shows it is taking 100% of time when it isn’t.
vTaskGetRunTimeStats with always 100% on the same task
Hi
My Task1 does not take 100% of the time….
Task1 probably takes 5 or 10% of the absolute time. But I keep receiving 100% for Task1 and 0% for the others, but that’s impossible..
vTaskGetRunTimeStats with always 100% on the same task
Please let us know which port and compiler you are using, and post the run time stats relevant macro definitions:
configGENERATERUNTIMESTATS
portCONFIGURETIMERFORRUNTIMESTATS()
and
portGETRUNTIMECOUNTERVALUE()
Regards.
vTaskGetRunTimeStats with always 100% on the same task
Hi:)
I’m using LPC4357 and as for the macros I set them like this:
1000 is my tick rate in Hz, so the counter value will be 1000 / 10 = 100
I’ve read:
“The run time statistics time base needs to have a higher resolution than the tick interrupt – otherwise the statistics may be too inaccurate to be truly useful. It is recommended to make the time base between 10 and 100 times faster than the tick interrupt.”
But my tick interrupt is 1 ms..
The function:
has a variable:
If the ulTotalTime == 0 will never calculate the stats for each task
Thank you for the help
#if ( configGENERATE_RUN_TIME_STATS == 1 )
#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() //dummy...
#endif
#ifndef portGET_RUN_TIME_COUNTER_VALUE
#define portGET_RUN_TIME_COUNTER_VALUE() (TICK_RATE_HZ / 10)
#endif
#endif
void vTaskGetRunTimeStats( char *pcWriteBuffer )
unsigned long ulTotalTime
/* Generate the (binary) data. */
xArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalTime );
/* For percentage calculations. */
ulTotalTime /= 100UL;
/* Avoid divide by zero errors. */
if( ulTotalTime > 0 )
etc..
vTaskGetRunTimeStats with always 100% on the same task
So are you incrementing ulTotalTime?
Ideally if you have a 1KHz tick you will need a time base of at least 10KHz. This can be achieved using a peripheral timer – you may even be able to hook into the timer used to generate the tick interrupts, then create a higher frequency timer by combining the number of overflows (which will be the number of tick interrupts) with the current timer value.
Regards.
vTaskGetRunTimeStats with always 100% on the same task
I’m not incrementing the ulTotalTime…I just showed on the code because it is an unsigned long, and therefore the value for that can’t ever be zero. And must always be at least above 100 ( for that /= 100UL; ).
But thank you for the suggestion 🙂 Is there any example available how to hook into the timer generate the interrupt ticks as you said?
Thanks:)