Overview
This lecture introduces real-time operating systems (RTOS), focusing on their differences from general-purpose operating systems, key concepts, use cases, and an upcoming practical series using FreeRTOS on ESP32 microcontrollers.
Operating Systems Overview
- Operating systems (OS) manage scheduling of background tasks and user applications, making concurrent execution appear seamless.
- OS manage virtual resources like files, folders, and libraries for application access.
- Device drivers in OS allow interaction with hardware like keyboards and displays.
- General-purpose OS (e.g., Windows, Linux, macOS) prioritize human interaction, tolerating small delays or lag.
Real-Time Operating Systems (RTOS) Features
- RTOS guarantee timing deadlines, making them suitable for time-critical applications like medical devices or engine controllers.
- RTOS may provide basic device drivers or just a scheduler, requiring custom drivers for additional hardware.
- RTOS allow reliable concurrent execution of multiple tasks, unlike simple super loop architectures.
- FreeRTOS is a popular, free, and open-source RTOS for IoT devices.
Super Loop vs. RTOS Approaches
- The super loop architecture uses a simple infinite loop to execute tasks sequentially—good for simple microcontroller projects with few tasks.
- Interrupts can handle precise timing or immediate response needs within both super loop and RTOS setups.
- Super loops struggle with concurrent tasks and can lead to missed input or lag if individual tasks take too long.
Tasks, Threads, and Processes
- A "task" (in FreeRTOS) is similar to a "thread"—a unit of code execution with its own context.
- Processes are program instances that may contain multiple threads and usually share resources.
- FreeRTOS generally runs a single process with multiple tasks (threads).
Prioritization and Multitasking
- RTOS allow task prioritization, ensuring urgent tasks get more CPU time or execute sooner.
- On single-core microcontrollers, multitasking is achieved by time-slicing CPU time between tasks.
When to Use RTOS
- RTOS are valuable for projects needing concurrent tasks, strict timing, or complex features like wireless connectivity.
- They are better suited for microcontrollers with ample memory and processing power (e.g., ESP32) rather than simple 8/16-bit MCUs.
Practical Information and Series Setup
- FreeRTOS is maintained by Amazon and works out-of-the-box on ESP32 boards (which come with Arduino support).
- Using Arduino provides a common environment for all learners and easy code portability.
- The series will include demo projects, challenges, and covers FreeRTOS fundamentals like task management and inter-task communication.
Key Terms & Definitions
- Operating System (OS) — Software managing hardware, resources, and task scheduling.
- Real-Time Operating System (RTOS) — OS guaranteeing timely task completion for critical applications.
- Super Loop — Simple program structure using a continuous infinite loop to process tasks sequentially.
- Task/Thread — An independent unit of code execution with its own program counter and memory.
- Process — An executing program instance, possibly containing multiple threads.
- Interrupt — A hardware- or software-triggered event that preempts running code to execute a service routine.
Action Items / Next Steps
- Prepare an ESP32 development board with Arduino support.
- Get ready to start using FreeRTOS by following the next video to create a task that blinks an LED.