Bird
0
0

You want to monitor stack usage for multiple tasks and log warnings if any task's free stack falls below 50 words. Which approach is best?

hard📝 Best Practice Q15 of 15
FreeRTOS - Memory Management
You want to monitor stack usage for multiple tasks and log warnings if any task's free stack falls below 50 words. Which approach is best?
ACall uxTaskGetStackHighWaterMark(NULL) once and assume all tasks are safe
BIncrease total heap size instead of monitoring stack
COnly monitor the highest priority task's stack usage
DLoop through all task handles, call uxTaskGetStackHighWaterMark(), compare to 50, log if below
Step-by-Step Solution
Solution:
  1. Step 1: Understand monitoring multiple tasks

    Each task has its own stack; checking all ensures no task is overlooked.
  2. Step 2: Implement threshold check per task

    Looping through tasks and comparing free stack to 50 words allows targeted warnings.
  3. Step 3: Evaluate other options

    Checking only current or highest priority task misses others; increasing heap doesn't solve stack issues.
  4. Final Answer:

    Loop through all task handles, call uxTaskGetStackHighWaterMark(), compare to 50, log if below -> Option D
  5. Quick Check:

    Check all tasks individually for stack [OK]
Quick Trick: Check each task's stack individually for accurate monitoring [OK]
Common Mistakes:
  • Assuming one check covers all tasks
  • Ignoring lower priority tasks
  • Confusing heap size with stack size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes