Bird
0
0

What is wrong with this FreeRTOS task creation code snippet?

medium📝 Debug Q7 of 15
FreeRTOS - RTOS Fundamentals
What is wrong with this FreeRTOS task creation code snippet?
TaskHandle_t xHandle = NULL;
xTaskCreate(MyTask, "Task", 1000, NULL, 2, xHandle);
ATask priority 2 is invalid; it must be 0 or 1.
BThe stack size 1000 is too large for FreeRTOS.
CThe last parameter should be &xHandle, not xHandle.
DThe task name must be a pointer to a char array, not a string literal.
Step-by-Step Solution
Solution:
  1. Step 1: Understand xTaskCreate last parameter

    The last parameter is a pointer to a TaskHandle_t variable to receive the created task's handle.
  2. Step 2: Analyze the code

    Here, xHandle is passed directly instead of its address. It should be &xHandle to store the handle.
  3. Step 3: Check other options

    Stack size 1000 is valid depending on config.
    Priority 2 is valid.
    Task name as string literal is allowed.
  4. Final Answer:

    The last parameter should be &xHandle, not xHandle. is correct.
  5. Quick Check:

    Pass address of handle variable [OK]
Quick Trick: Use & operator for task handle parameter [OK]
Common Mistakes:
  • Passing handle variable instead of its address
  • Confusing stack size limits
  • Misunderstanding valid priority values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes