Bird
0
0

You want to monitor CPU usage of tasks over time using vTaskGetRunTimeStats(). Which approach correctly ensures accurate and meaningful stats?

hard📝 Application Q15 of 15
FreeRTOS - Debugging and Monitoring
You want to monitor CPU usage of tasks over time using vTaskGetRunTimeStats(). Which approach correctly ensures accurate and meaningful stats?
AEnable run time stats, provide a large buffer, call periodically, and reset counters between calls
BCall <code>vTaskGetRunTimeStats()</code> once at startup with a small buffer
CDisable run time stats and manually count task switches
DCall <code>vTaskGetRunTimeStats()</code> inside each task to get its own CPU usage
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirements for accurate CPU stats

    Run time stats must be enabled, buffer must be large enough to hold all task info, and stats should be collected periodically to track changes over time.
  2. Step 2: Evaluate each option

    Enable run time stats, provide a large buffer, call periodically, and reset counters between calls describes the correct approach including resetting counters to avoid cumulative overflow. Call vTaskGetRunTimeStats() once at startup with a small buffer is insufficient (only once, small buffer). Disable run time stats and manually count task switches disables stats, losing automation. Call vTaskGetRunTimeStats() inside each task to get its own CPU usage is incorrect because stats are global, not per task.
  3. Final Answer:

    Enable run time stats, provide a large buffer, call periodically, and reset counters between calls -> Option A
  4. Quick Check:

    Enable + buffer + periodic calls + reset = accurate stats [OK]
Quick Trick: Enable stats, use big buffer, call regularly, reset counters [OK]
Common Mistakes:
  • Calling once only at startup
  • Disabling run time stats
  • Calling inside each task expecting per-task stats

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes