Bird
0
0

Examine the following FreeRTOS code snippet:

medium📝 Debug Q6 of 15
FreeRTOS - Task Scheduling
Examine the following FreeRTOS code snippet:
TickType_t lastWakeTime;
for (;;) {
    vTaskDelayUntil(lastWakeTime, pdMS_TO_TICKS(100));
}

What is the primary issue with this code?
AlastWakeTime is not initialized before use
BThe address of lastWakeTime is not passed to vTaskDelayUntil
CpdMS_TO_TICKS is used incorrectly
DThe delay period is too short for the system tick
Step-by-Step Solution
Solution:
  1. Step 1: Check vTaskDelayUntil() parameter requirements

    The first parameter must be a pointer to a TickType_t variable.
  2. Step 2: Analyze the code

    lastWakeTime is passed by value, not by address.
  3. Step 3: Identify the error

    Passing lastWakeTime instead of &lastWakeTime causes incorrect behavior.
  4. Final Answer:

    The address of lastWakeTime is not passed to vTaskDelayUntil -> Option B
  5. Quick Check:

    Check pointer usage in function call [OK]
Quick Trick: Always pass pointer to lastWakeTime in vTaskDelayUntil [OK]
Common Mistakes:
  • Passing variable instead of its address
  • Not initializing lastWakeTime before first call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes