Bird
0
0

Identify the error in this shutdown sequence code snippet:

medium📝 Debug Q14 of 15
FreeRTOS - Design Patterns for RTOS
Identify the error in this shutdown sequence code snippet:
void ShutdownTask(void *pvParameters) {
  vTaskDelete(NULL);
  // Cleanup code here
}
ATask should call vTaskStartScheduler() before deletion
BvTaskDelete(NULL) deletes all tasks, causing crash
CMissing call to vTaskSuspendAll() before deletion
DCleanup code runs after task deletion, so it never executes
Step-by-Step Solution
Solution:
  1. Step 1: Understand vTaskDelete behavior

    vTaskDelete(NULL) deletes the current task immediately, stopping execution at that point.
  2. Step 2: Check code after deletion

    Cleanup code after vTaskDelete(NULL) will never run because the task is deleted before it.
  3. Final Answer:

    Cleanup code runs after task deletion, so it never executes -> Option D
  4. Quick Check:

    vTaskDelete stops task immediately, no code after runs [OK]
Quick Trick: Code after vTaskDelete(NULL) won't run [OK]
Common Mistakes:
  • Assuming cleanup runs after vTaskDelete
  • Thinking vTaskDelete(NULL) deletes all tasks
  • Confusing suspend with delete

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes