Bird
0
0

Consider the following code snippet:

medium📝 Predict Output Q13 of 15
FreeRTOS - Task Priorities

Consider the following code snippet:

TaskHandle_t xTask1;
// Assume xTask1 is created with priority 2
vTaskPrioritySet(xTask1, 5);
UBaseType_t newPriority = uxTaskPriorityGet(xTask1);
printf("%u", newPriority);

What will be printed?

A0
B2
C5
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Understand priority change

    The call vTaskPrioritySet(xTask1, 5) changes the task's priority from 2 to 5.
  2. Step 2: Check the priority retrieval

    uxTaskPriorityGet(xTask1) returns the current priority, which is now 5.
  3. Final Answer:

    5 -> Option C
  4. Quick Check:

    Priority updated to 5, so output is 5 [OK]
Quick Trick: Priority changes immediately, so get returns new value [OK]
Common Mistakes:
  • Assuming priority stays the same after set
  • Confusing priority with task handle
  • Thinking printf prints task handle

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes