Bird
0
0

Consider this FreeRTOS code snippet:

medium📝 Predict Output Q13 of 15
FreeRTOS - RTOS Fundamentals

Consider this FreeRTOS code snippet:

void vTaskFunction(void *pvParameters) {
    for (;;) {
        if (xSemaphoreTake(xSemaphore, 0) == pdTRUE) {
            // Critical section
        } else {
            vTaskDelay(pdMS_TO_TICKS(100));
        }
    }
}

What is the state of the task when vTaskDelay() is called?

ARunning
BReady
CBlocked
DSuspended
Step-by-Step Solution
Solution:
  1. Step 1: Understand vTaskDelay effect

    Calling vTaskDelay causes the task to enter Blocked state, waiting for the delay time to expire.
  2. Step 2: Confirm task state during delay

    While delayed, the task is not Ready or Running; it is Blocked until the timer expires.
  3. Final Answer:

    Blocked -> Option C
  4. Quick Check:

    vTaskDelay = Blocked state [OK]
Quick Trick: vTaskDelay puts task in Blocked state [OK]
Common Mistakes:
  • Thinking delay means Ready
  • Confusing Blocked with Suspended
  • Assuming task runs during delay

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes