Bird
0
0

What will be the output of this FreeRTOS code snippet if both tasks print their names repeatedly?

medium📝 Predict Output Q4 of 15
FreeRTOS - Task Creation and Management
What will be the output of this FreeRTOS code snippet if both tasks print their names repeatedly?
void Task1(void *pvParameters) {
  for (;;) {
    printf("Task1 running\n");
    vTaskDelay(1000 / portTICK_PERIOD_MS);
  }
}

void Task2(void *pvParameters) {
  for (;;) {
    printf("Task2 running\n");
    vTaskDelay(500 / portTICK_PERIOD_MS);
  }
}
ABoth tasks print at the same rate
BTask1 prints twice as often as Task2
COnly Task1 prints because it has higher priority
DTask2 prints twice as often as Task1
Step-by-Step Solution
Solution:
  1. Step 1: Analyze vTaskDelay times

    Task1 delays 1000ms, Task2 delays 500ms, so Task2 wakes twice as often.
  2. Step 2: Understand print frequency

    Task2 prints every 500ms, Task1 every 1000ms, so Task2 prints twice as often.
  3. Final Answer:

    Task2 prints twice as often as Task1 -> Option D
  4. Quick Check:

    Delay time inversely affects print frequency [OK]
Quick Trick: Shorter delay means more frequent task execution [OK]
Common Mistakes:
  • Assuming same print rate despite different delays
  • Ignoring delay units and timing
  • Assuming priority affects print frequency here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes