Bird
0
0

Consider two tasks in FreeRTOS: TaskA with priority 2 and TaskB with priority 3. TaskA is running when TaskB becomes ready. What will be the output if both tasks print their names when running?

medium📝 Predict Output Q13 of 15
FreeRTOS - Task Scheduling
Consider two tasks in FreeRTOS: TaskA with priority 2 and TaskB with priority 3. TaskA is running when TaskB becomes ready. What will be the output if both tasks print their names when running?
ATaskA prints first, then TaskB prints after TaskA finishes.
BTaskB prints immediately, preempting TaskA.
CBoth tasks print simultaneously.
DNo output because tasks block each other.
Step-by-Step Solution
Solution:
  1. Step 1: Identify task priorities and running state

    TaskA has priority 2 and is running; TaskB has higher priority 3 and becomes ready.
  2. Step 2: Apply preemptive scheduling rules

    TaskB will preempt TaskA immediately and run first, printing its name.
  3. Final Answer:

    TaskB prints immediately, preempting TaskA. -> Option B
  4. Quick Check:

    Higher priority task runs first = TaskB prints first [OK]
Quick Trick: Higher priority task prints first by preempting lower priority [OK]
Common Mistakes:
  • Assuming lower priority task finishes before switching
  • Thinking tasks run at the same time
  • Ignoring task priorities

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes