Bird
0
0

Identify the error in this FreeRTOS task creation code:

medium📝 Debug Q14 of 15
FreeRTOS - Task Creation and Management
Identify the error in this FreeRTOS task creation code:
void vTaskCode(void *pvParameters) {
  while(1) {
    // Task code
  }
}

int main() {
  xTaskCreate(vTaskCode, "Task", 1000, NULL, 1, NULL);
  vTaskStartScheduler();
  return 0;
}
ATask handle parameter is NULL, so task cannot be managed later.
BThe task function should not have an infinite loop.
CStack size is too large and causes memory overflow.
DvTaskStartScheduler() is called before creating the task.
Step-by-Step Solution
Solution:
  1. Step 1: Check task creation parameters

    The last parameter is the task handle pointer; passing NULL means the task handle is not stored.
  2. Step 2: Understand implications of NULL task handle

    Without a task handle, the program cannot control or delete the task later, which is usually needed.
  3. Final Answer:

    Task handle parameter is NULL, so task cannot be managed later. -> Option A
  4. Quick Check:

    Task handle NULL means no task control [OK]
Quick Trick: Always provide a task handle pointer to manage tasks [OK]
Common Mistakes:
  • Thinking infinite loops are wrong in tasks
  • Believing stack size is always too large
  • Assuming scheduler starts before task creation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes