Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

vTaskGetRunTimeStats with always 100% on the same task

Posted by jpgl82 on December 18, 2013

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

Posted by davedoors on December 18, 2013

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

Posted by jpgl82 on December 18, 2013

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

Posted by rtel on December 18, 2013

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

Posted by jpgl82 on December 19, 2013

Hi:) I'm using LPC4357 and as for the macros I set them like this:


 #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

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:


void vTaskGetRunTimeStats( char *pcWriteBuffer )

has a variable:


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..

If the ulTotalTime == 0 will never calculate the stats for each task

Thank you for the help


vTaskGetRunTimeStats with always 100% on the same task

Posted by rtel on December 19, 2013

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

Posted by jpgl82 on December 20, 2013

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:)


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner