Bird
0
0

What will be the output of the following code snippet?

medium📝 Predict Output Q4 of 15
FreeRTOS - Task Creation and Management
What will be the output of the following code snippet?
TaskHandle_t xHandle = NULL;
BaseType_t result = xTaskCreate(
  vTaskFunction, "Task1", 1000, NULL, 2, &xHandle);
if(result == pdPASS) {
  printf("Task created\n");
} else {
  printf("Task creation failed\n");
}
ANo output
BTask creation failed
CCompilation error
DTask created
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the xTaskCreate() call

    The task is created with valid parameters: function pointer, name, stack size, no parameters, priority 2, and valid task handle pointer.
  2. Step 2: Check the return value and output

    Since parameters are valid, xTaskCreate() returns pdPASS, so "Task created" is printed.
  3. Final Answer:

    Task created -> Option D
  4. Quick Check:

    Valid parameters produce pdPASS = "Task created" [OK]
Quick Trick: Valid parameters mean pdPASS and success message [OK]
Common Mistakes:
  • Assuming NULL task handle causes failure
  • Confusing priority with stack size
  • Ignoring return value check

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes