What is an RTOS and how is it different from a general-purpose OS?
Short answer: A Real-Time Operating System guarantees that tasks respond within a bounded, predictable time. Its goal is determinism (meeting deadlines every time), not maximum average throughput. Compared with Linux or Windows, an RTOS has a small priority-based pre-emptive scheduler, bounded interrupt and context-switch latency, a footprint of a few KB, and usually no MMU-based process isolation: all tasks share one address space.
| RTOS (FreeRTOS, Zephyr) | General-purpose OS (Linux) | |
|---|---|---|
| Scheduling | fixed priorities, highest ready task always runs | fairness (CFS/EEVDF), throughput |
| Latency | bounded, microseconds | usually low, but unbounded worst case (PREEMPT_RT improves it) |
| Footprint | 5–50 KB flash, a few KB RAM | MBs of RAM, storage |
| Memory protection | none or MPU-based | MMU, full process isolation |
| Boot time | milliseconds | seconds |
| Drivers, networking, filesystems | small or add-on | huge ecosystem |
| Typical hardware | Cortex-M, Cortex-R, small RISC-V | Cortex-A, x86 |
What makes it deterministic
- The scheduler's work is O(1) (ready lists per priority, bitmap lookup).
- Kernel critical sections are short and bounded.
- No paging, no swapping, usually no dynamic allocation after start-up.
- Interrupt handling and the API have documented worst-case behaviour.
Examples: FreeRTOS (and SafeRTOS for certification), Zephyr, Eclipse ThreadX (formerly Azure RTOS), embOS, RTX, Micrium µC/OS, NuttX (POSIX-like); and larger commercial ones: VxWorks, QNX (microkernel), INTEGRITY, PikeOS (with partitioning for safety).
Interview line: "Real-time does not mean fast. It means correct results on time, every time, with a provable worst case."