Bird
0
0

What output will the following code produce?

medium📝 Predict Output Q5 of 15
FreeRTOS - Task Priorities

What output will the following code produce?

TaskHandle_t xTask = xTaskCreate(..., 4, ...);
UBaseType_t priority = uxTaskPriorityGet(xTask);
printf("Task priority: %u", priority);

ATask priority: 4
BTask priority: 0
CTask priority: Undefined
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Understand task creation

    The task is created with priority 4.
  2. Step 2: Use uxTaskPriorityGet()

    This function returns the priority assigned to the task handle.
  3. Step 3: Print output

    The printed priority will be 4 as assigned.
  4. Final Answer:

    Task priority: 4 -> Option A
  5. Quick Check:

    Priority matches creation parameter [OK]
Quick Trick: Priority returned matches creation priority [OK]
Common Mistakes:
  • Assuming default priority 0 if not checked
  • Confusing priority with task ID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes