0
0
FreeRTOSprogramming~10 mins

Why RTOS over bare-metal in FreeRTOS - Visual Breakdown

Choose your learning style9 modes available
Concept Flow - Why RTOS over bare-metal
Start Program
Choose bare-metal?
YesSingle task runs
No task switching
Choose RTOS?
YesMultiple tasks run
Tasks switch by scheduler
Program ends
This flow shows the choice between bare-metal and RTOS: bare-metal runs one task at a time with no switching, RTOS runs multiple tasks with scheduler switching.
Execution Sample
FreeRTOS
void main() {
  while(1) {
    task1();
    task2();
  }
}

// RTOS runs tasks concurrently with scheduler
This code shows a bare-metal loop running tasks one after another; RTOS allows tasks to run concurrently with switching.
Execution Table
StepTask RunningScheduler ActionOutput/Effect
1task1No scheduler (bare-metal)task1 runs fully
2task2No scheduler (bare-metal)task2 runs fully
3task1No scheduler (bare-metal)task1 runs again
4task1Scheduler switches to task2 (RTOS)task1 runs part, then switches
5task2Scheduler switches to task1 (RTOS)task2 runs part, then switches
6task1Scheduler switches to task2 (RTOS)task1 runs part again
💡 Bare-metal runs tasks sequentially with no switching; RTOS switches tasks to run concurrently.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 4After Step 5Final
Current TaskNonetask1task2task1 (partial)task2 (partial)task1/task2 switching
Scheduler ActiveNoNoNoYesYesYes
Key Moments - 3 Insights
Why does bare-metal run tasks one after another without switching?
Because there is no scheduler to switch tasks, as shown in execution_table rows 1-3 where tasks run fully one by one.
How does RTOS allow multiple tasks to run seemingly at the same time?
RTOS uses a scheduler to switch tasks frequently, shown in execution_table rows 4-6 where tasks run partially and switch.
What happens if a task blocks or waits in bare-metal?
The whole program waits because no other task runs, unlike RTOS where scheduler can switch to other tasks.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what task is running at step 2?
Atask1
Btask2
CNo task
DScheduler
💡 Hint
Check the 'Task Running' column at step 2 in execution_table.
At which step does the scheduler start switching tasks?
AStep 4
BStep 3
CStep 1
DStep 7
💡 Hint
Look for 'Scheduler switches' in the 'Scheduler Action' column in execution_table.
If we remove the scheduler, how would the 'Current Task' variable change after step 5?
AIt would stay on task2 only
BIt would keep switching tasks
CIt would stay on task1 only
DIt would stop running tasks
💡 Hint
Refer to variable_tracker 'Scheduler Active' and 'Current Task' values and execution_table rows 1-3.
Concept Snapshot
Bare-metal runs one task fully before next.
No task switching or scheduler.
RTOS uses scheduler to switch tasks.
Allows multitasking and better responsiveness.
RTOS handles blocking tasks without stopping all.
Choose RTOS for complex, multitask needs.
Full Transcript
This visual trace compares bare-metal and RTOS task running. Bare-metal runs tasks one after another without switching, shown in steps 1-3. RTOS uses a scheduler to switch tasks frequently, allowing multitasking, shown in steps 4-6. Variables track current task and scheduler status. Key moments clarify why bare-metal lacks switching and how RTOS multitasks. Quiz questions check understanding of task running and scheduler action. Summary: bare-metal is simple sequential running; RTOS enables multitasking with scheduler.