Bird
0
0

Which FreeRTOS API call correctly creates a task that runs the function SensorTask with priority 3?

easy📝 Syntax Q3 of 15
FreeRTOS - RTOS Fundamentals
Which FreeRTOS API call correctly creates a task that runs the function SensorTask with priority 3?
AxTaskCreate(SensorTask(), "Sensor", 256, NULL, 3, NULL);
BxTaskCreate(&SensorTask, "Sensor", 256, NULL, 3, NULL);
CxTaskCreate(SensorTask, "Sensor", 256, NULL, 3, NULL);
DxTaskCreate(SensorTask, Sensor, 256, NULL, 3, NULL);
Step-by-Step Solution
Solution:
  1. Step 1: Understand xTaskCreate parameters

    The function prototype is BaseType_t xTaskCreate(TaskFunction_t pxTaskCode, const char * const pcName, configSTACK_DEPTH_TYPE usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask);
  2. Step 2: Analyze each option

    xTaskCreate(SensorTask, "Sensor", 256, NULL, 3, NULL); correctly passes the function pointer SensorTask, task name as string, stack size, NULL parameters, priority 3, and NULL for handle.
    xTaskCreate(&SensorTask, "Sensor", 256, NULL, 3, NULL); incorrectly uses address-of operator on function pointer.
    xTaskCreate(SensorTask(), "Sensor", 256, NULL, 3, NULL); calls the function instead of passing pointer.
    xTaskCreate(SensorTask, Sensor, 256, NULL, 3, NULL); passes a variable Sensor instead of string for task name.
  3. Final Answer:

    xTaskCreate(SensorTask, "Sensor", 256, NULL, 3, NULL); is correct.
  4. Quick Check:

    Function pointer without & or () and string name [OK]
Quick Trick: Pass function pointer and string name correctly [OK]
Common Mistakes:
  • Using & before function name
  • Calling function instead of passing pointer
  • Passing variable instead of string for task name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes