Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q14 of 15
FreeRTOS - Task Priorities

Identify the error in this code snippet:

TaskHandle_t xHandle;
UBaseType_t uxPriority = uxTaskPriorityGet(xHandle);
printf("Priority: %u\n", uxPriority);
AxHandle is uninitialized before use.
BuxTaskPriorityGet() cannot be called with a TaskHandle_t.
Cprintf format specifier is incorrect.
DuxPriority should be a pointer.
Step-by-Step Solution
Solution:
  1. Step 1: Check variable initialization

    xHandle is declared but not assigned any value before use.
  2. Step 2: Understand consequences of uninitialized handle

    Passing an uninitialized handle to uxTaskPriorityGet() leads to undefined behavior or incorrect priority reading.
  3. Final Answer:

    xHandle is uninitialized before use. -> Option A
  4. Quick Check:

    Always initialize task handles before use [OK]
Quick Trick: Initialize task handle before getting priority [OK]
Common Mistakes:
  • Ignoring uninitialized variables
  • Misunderstanding function parameter types
  • Assuming pointer needed for uxPriority

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes