Bird
0
0

Which of the following is the correct way to declare a task using static allocation in FreeRTOS?

easy📝 Syntax Q12 of 15
FreeRTOS - Memory Management
Which of the following is the correct way to declare a task using static allocation in FreeRTOS?
AxTaskCreateStatic(TaskFunction, "Task", 100, NULL, 1, stackBuffer, &taskBuffer);
BxTaskCreate(TaskFunction, "Task", 100, NULL, 1, NULL);
CxTaskCreateDynamic(TaskFunction, "Task", 100, NULL, 1, &taskHandle);
DxTaskCreateStatic(TaskFunction, "Task", 100, NULL, 1, NULL, NULL);
Step-by-Step Solution
Solution:
  1. Step 1: Identify static allocation function

    FreeRTOS provides xTaskCreateStatic for static allocation, requiring stack and task buffers.
  2. Step 2: Check parameters

    xTaskCreateStatic(TaskFunction, "Task", 100, NULL, 1, stackBuffer, &taskBuffer); correctly passes stackBuffer and taskBuffer pointers. xTaskCreate uses dynamic allocation. There is no xTaskCreateDynamic function. Passing NULL buffers is incorrect.
  3. Final Answer:

    xTaskCreateStatic(TaskFunction, "Task", 100, NULL, 1, stackBuffer, &taskBuffer); -> Option A
  4. Quick Check:

    Static task creation needs buffers [OK]
Quick Trick: Use xTaskCreateStatic with buffers for static tasks [OK]
Common Mistakes:
  • Using xTaskCreate instead of xTaskCreateStatic
  • Passing NULL for buffers in static allocation
  • Confusing dynamic and static creation functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes