Consider two FreeRTOS tasks running with different CPU times. The vTaskGetRunTimeStats() function fills a buffer with CPU usage stats. What will the output string contain?
char buffer[100]; vTaskGetRunTimeStats(buffer); printf("%s", buffer);
Remember CPU usage is proportional to the run time of each task relative to total run time.
The output string shows each task's CPU usage percentage. If Task1 ran 70% of the time and Task2 30%, the buffer will reflect that.
Which of the following best describes what vTaskGetRunTimeStats() reports?
Think about what CPU usage means in a multitasking system.
vTaskGetRunTimeStats() reports how much CPU time each task has used relative to total CPU time since the stats timer started.
You call vTaskGetRunTimeStats() but the output shows zero CPU usage for every task. What is the most likely cause?
Check your FreeRTOS configuration related to run time stats.
If configGENERATE_RUN_TIME_STATS is not enabled or the timer used to measure run time is not set up, the stats will always be zero.
Choose the code snippet that correctly calls vTaskGetRunTimeStats() and prints the CPU usage stats.
Check the function parameter type and how the buffer is passed.
vTaskGetRunTimeStats() requires a pointer to a char array buffer to fill with stats. Passing the buffer name (array) is correct.
You want to monitor CPU usage of tasks periodically in a FreeRTOS system. Which approach correctly uses vTaskGetRunTimeStats() to achieve this?
Think about how to safely and periodically collect stats without blocking or causing errors.
A dedicated monitoring task calling vTaskGetRunTimeStats() periodically is the correct way. Calling it once at start won't update usage. Calling inside tasks or ISRs is unsafe or incorrect.