Bird
0
0

Given the code snippet below, what will be the approximate delay between each "Task running" print?

medium📝 Predict Output Q13 of 15
FreeRTOS - Task Scheduling
Given the code snippet below, what will be the approximate delay between each "Task running" print?
TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();

for (;;) {
    vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(1000));
    printf("Task running\n");
}
AApproximately 1000 milliseconds, steady without drift
BExactly 1000 milliseconds between prints
CVariable delay, sometimes less than 1000 milliseconds
DNo delay, prints continuously
Step-by-Step Solution
Solution:
  1. Step 1: Understand vTaskDelayUntil behavior

    It delays the task until the next fixed interval based on the last wake time, keeping timing steady.
  2. Step 2: Analyze the delay duration

    The delay is set to 1000 ms converted to ticks, so the task runs approximately every 1000 ms without accumulating drift.
  3. Final Answer:

    Approximately 1000 milliseconds, steady without drift -> Option A
  4. Quick Check:

    vTaskDelayUntil = steady periodic delay [OK]
Quick Trick: vTaskDelayUntil keeps intervals steady, not exact but no drift [OK]
Common Mistakes:
  • Assuming exact millisecond precision
  • Confusing with vTaskDelay which causes drift
  • Thinking delay varies randomly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes