rtel wrote on Friday, July 13, 2012:
where should the macro vTaskGetRunTimeStats() be called?
That function is used to generate a human readable table of gathered run time stats. You can call it from any task that needs this information. It is normally used to output the information to a web server or console for viewing by the user.
or only one time in one task and it will gather the statics about every other task?
vTaskGetRunTimeStats() does not gather the statistics, it only formats them into a human readable table. The kernel itself gathers the run time statistics if configGENERATE_RUN_TIME_STATS is set to 1. If configGENERATE_RUN_TIME_STATS is set to one then the kernel tries to call portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() once during start up, then portGET_RUN_TIME_COUNTER_VALUE() on each task switch. That is why you have to define the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() portGET_RUN_TIME_COUNTER_VALUE() to do the right thing for your hardware (you define them, but you don’t call them, the kernel calls them).
i understand that this macro must be used to configure the timer only but in the first example it was used to set the variable to 0 and the other macro portGET_RUN_TIME_COUNTER_VALUE to get the value of this variable. that is why, i am a little confused.
vTaskGetRunTimeStats() does not set anything to zero, in the example portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() sets a variable to zero (for that particular implementation) because it is called once at start up it does the initialisation. The other macro returns the value because it is called during a context switch to return the current time value.
Hope that helps.