Bird
0
0

Why does xTaskCreate() require a pointer to a TaskHandle_t variable instead of returning the handle directly?

hard📝 Conceptual Q10 of 15
FreeRTOS - Task Creation and Management
Why does xTaskCreate() require a pointer to a TaskHandle_t variable instead of returning the handle directly?
ABecause returning handles directly is not supported in C
BTo prevent tasks from accessing their own handles
CTo save memory by not copying the handle
DTo allow the function to return a status and provide the handle via pointer
Step-by-Step Solution
Solution:
  1. Step 1: Understand function return and output parameters

    xTaskCreate() returns a status code indicating success or failure.
  2. Step 2: Reason why handle is passed by pointer

    Since the return value is used for status, the task handle is returned via a pointer parameter to provide both pieces of information.
  3. Final Answer:

    To allow the function to return a status and provide the handle via pointer -> Option D
  4. Quick Check:

    Status via return, handle via pointer parameter [OK]
Quick Trick: Return status, pass handle pointer to get task handle [OK]
Common Mistakes:
  • Thinking handles cannot be returned in C
  • Assuming handle is returned directly
  • Confusing memory saving with design choice

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes