0
0
FreeRTOSprogramming~10 mins

What is an RTOS in FreeRTOS - Visual Explanation

Choose your learning style9 modes available
Concept Flow - What is an RTOS
Start: System powered on
RTOS Kernel starts
Create Tasks
Scheduler runs
Tasks run based on priority
Tasks wait, run, or sleep
RTOS manages timing and resources
System runs smoothly with multitasking
System shutdown or reset
This flow shows how an RTOS starts, creates tasks, schedules them by priority, manages timing, and keeps the system running smoothly.
Execution Sample
FreeRTOS
void main() {
  vTaskCreate(Task1, "Task1", 1000, NULL, 1, NULL);
  vTaskCreate(Task2, "Task2", 1000, NULL, 2, NULL);
  vTaskStartScheduler();
}
This code creates two tasks with different priorities and starts the RTOS scheduler to run them.
Execution Table
StepActionDetailsResult
1System powers onHardware and RTOS kernel initializeRTOS kernel ready
2Create Task1Priority 1, stack size 1000Task1 added to ready list
3Create Task2Priority 2, stack size 1000Task2 added to ready list
4Start SchedulerRTOS scheduler begins runningScheduler picks highest priority task
5Run Task2Priority 2 is higher than 1Task2 runs first
6Task2 blocks or yieldsTask2 waits for event or timeScheduler switches to Task1
7Run Task1Priority 1 task runsTask1 executes
8Tasks switch based on eventsRTOS manages timing and resourcesMultitasking continues
9System runs continuouslyRTOS handles task switchingSmooth multitasking
10System shutdown or resetRTOS stopsSystem powers off or restarts
💡 System stops when powered off or reset
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5After Step 6Final
Task1 StateNot createdReadyReadyReadyReadyRunningWaiting or Running
Task2 StateNot createdNot createdReadyReadyRunningBlocked or YieldedWaiting or Running
Scheduler StateIdleIdleIdleRunningRunningRunningRunning
Key Moments - 3 Insights
Why does Task2 run before Task1 even though Task1 was created first?
Because Task2 has a higher priority (2) than Task1 (1), the scheduler runs the highest priority task first as shown in execution_table step 5.
What happens when a running task blocks or yields?
The scheduler switches to another ready task, as seen in step 6 where Task2 blocks and Task1 starts running.
Does the RTOS run tasks one after another or at the same time?
The RTOS runs tasks one at a time very quickly by switching between them, creating the effect of multitasking, explained in steps 7 and 8.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, which task runs first after the scheduler starts?
ATask1
BTask2
CBoth at the same time
DNo task runs
💡 Hint
Check step 5 in the execution_table where the scheduler picks the highest priority task.
At which step does Task2 stop running and Task1 start?
AStep 6
BStep 5
CStep 4
DStep 7
💡 Hint
Look at step 6 where Task2 blocks or yields and the scheduler switches to Task1.
If Task1 had higher priority than Task2, how would the execution_table change at step 5?
ATask2 would still run first
BBoth tasks run simultaneously
CTask1 would run first
DScheduler would not run any task
💡 Hint
Priority determines which task runs first as shown in step 5.
Concept Snapshot
RTOS (Real-Time Operating System) manages multiple tasks by priority.
It creates tasks, then runs the highest priority task first.
Tasks can run, wait, or sleep; RTOS switches tasks quickly.
Scheduler controls which task runs to keep system responsive.
Used in systems needing timely, predictable task management.
Full Transcript
An RTOS is a special operating system that helps a device run many tasks smoothly by managing their order and timing. When the system starts, the RTOS kernel initializes and creates tasks with assigned priorities. The scheduler then runs the highest priority task first. If that task waits or blocks, the scheduler switches to the next ready task. This switching happens very fast, making it seem like tasks run at the same time. The RTOS keeps the system responsive and predictable, which is important for real-time applications. The example code shows creating two tasks with different priorities and starting the scheduler. The execution table traces how tasks run step-by-step, showing Task2 runs first because it has higher priority. When Task2 blocks, Task1 runs. This cycle continues until the system shuts down or resets.