Bird
0
0

Analyze the following code:

medium📝 Predict Output Q4 of 15
FreeRTOS - Task Creation and Management
Analyze the following code:
TaskHandle_t xHandle = NULL;
xTaskCreate(TaskFunction, "Task1", 1000, NULL, 1, &xHandle);
vTaskDelete(xHandle);

What is the state of xHandle after vTaskDelete(xHandle); is executed?
AxHandle still holds the deleted task's handle, which is now invalid.
BxHandle is automatically set to NULL by FreeRTOS.
CxHandle points to a new task created automatically.
DxHandle becomes a pointer to the idle task.
Step-by-Step Solution
Solution:
  1. Step 1: Understand vTaskDelete effect

    The task is deleted, but the handle variable is not modified by FreeRTOS.
  2. Step 2: Handle validity

    After deletion, the handle points to invalid memory and should not be used.
  3. Final Answer:

    xHandle still holds the deleted task's handle, which is now invalid. -> Option A
  4. Quick Check:

    vTaskDelete does not clear handle [OK]
Quick Trick: vTaskDelete does not reset task handles [OK]
Common Mistakes:
  • Assuming FreeRTOS sets handle to NULL
  • Expecting a new task to be created automatically
  • Confusing handle with idle task pointer

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes