Featured image of post Introduction and Comparison of Common Real-Time OS

Introduction and Comparison of Common Real-Time OS

Comparison of several common RTOS

Introduction

A Real-Time Operating System (RTOS) is an operating system designed specifically for real-time applications, emphasizing “responding to events within a specific time limit (deadline)”. Imagine a scenario in the industrial field where a part of a machine suddenly malfunctions and needs to stop all motor operations in a very short time. If a traditional operating system like Linux is used, depending on the OS kernel scheduling policy, the action of stopping the motor may be slightly delayed. In contrast, an RTOS can have more flexible thread preemption, allowing emergency situations to be handled faster.

Essentially, the kernel usage of RTOS is similar. Basically, they can achieve multiple thread creation, round-robin execution, priority preemption, mutex locks, kernel-level interrupts, etc. More advanced ones have dynamic memory management and multi-core support. The main differences between these RTOS lie in the support for peripheral modules and the surrounding development ecosystem. The following introduces several currently mainstream common RTOS:

FreeRTOS

FreeRTOS is maintained by Real Time Engineers Ltd. and Amazon. It is completely open source and widely used globally. FreeRTOS can be said to be the most common RTOS. Its success lies in being open source early, integrated by various IDEs early, and its shadow can be seen in the SDKs of various chips. I first contacted it in the Arduino IDE. FreeRTOS appeared in the Arduino library list very early. It is simple enough to use, without complex settings, and multi-threading can be implemented with a line or two of code, making it easy for beginners to enter the world of RTOS. Its backer is Amazon, and later it also integrated a lot of AWS IoT-related functions. Since it was open sourced early, there are many surrounding modules.

AzureRTOS (Threadx)

ThreadX is a real-time operating system (RTOS) developed by Express Logic. It was subsequently acquired by Microsoft and released as a renamed version AzureRTOS and open sourced. From the name, it can be seen that formerly it should be paired with Microsoft’s Azure to do some IoT functions, but currently, no killer application seems to have been seen. Because it was open sourced relatively late, there are fewer surrounding packages, such as BLE and Wifi stacks, but I believe with native support from Microsoft, it should grow quickly. I encountered AzureRTOS because STM32 officially supports AzureRTOS natively. Interestingly, the STM32 development environment also supports FreeRTOS, but the support is far inferior to AzureRTOS.

Zephyr

Zephyr is an open-source real-time operating system (RTOS) led by the Linux Foundation. Although Zephyr has been around for a long time, it has only suddenly become popular in recent years. It features cross-platform compatibility and a complete development toolchain, with useful tools like West and architectures designed for cross-platform like DeviceTree. It can be said that to use Zephyr, you have to use this entire toolchain together to make it useful. However, it seems that due to the toolchain and compatibility reasons, although various chip manufacturers claim support, the support doesn’t seem to be that good, especially when it comes to very low-level hardware settings (like clock tree settings), it becomes particularly troublesome. if there is no such requirement, it is quite easy to use, and many settings and initializations are omitted for you. I encountered Zephyr because I used Nordic’s Bluetooth SoC. The latest nrf connect SDK is basically built on Zephyr, and Zephyr’s communication-related packages are also very complete, making it very suitable for Nordic chips.

RT-Thread

RT-Thread is an open-source real-time operating system (RTOS) led by a Chinese team. It is quite popular in China’s embedded system open source community and has good support for Chinese-made MCUs (especially some RISC-V chips), but it is rarely seen used elsewhere. Like Zephyr, there are many tools available. I haven’t used it myself yet, but what impressed me was that the RT-Thread community has a tool that can generate STM32 bootloader with one click. However, to use it, you need to register an account, and it is limited to registration with a Chinese phone number…, which is not very friendly to developers outside of China.

Comparison

Differences between several RTOS

NameAzureRTOS (ThreadX)FreeRTOSZephyrRT-Thread
Maintainer- Originally developed by Express Logic, now managed by Azure (Microsoft)
- Open sourced after being bought by Microsoft
- Maintained by AWS (Amazon) and large community
- Open source project with broad community support
- Hosted by Linux Foundation
- Numerous major industry sponsors and contributors (e.g., Intel, Nordic, etc.)
- Chinese embedded manufacturers and RT-Thread community
License- MIT License (Open Source Version)- MIT License
- Completely open source, commercially usable
- Apache 2.0 License
- Completely open source
- LGPL License
- Commercially usable, but must comply with LGPL terms
Key Features- Small memory footprint
- High performance preemptive multitasking
- Integrated debugging functions, other peripheral control modules
- Modular design, highly customizable kernel
- Cooperative and preemptive multitasking
- Detailed documentation and huge community, high support
- Good cross-platform compatibility
- Complete tracking and analysis tools
- Integration with Percepio Tracealyzer
- Lightweight design and microkernel architecture
- High efficiency, fast boot speed
- Focus on modularity and ease of use
Barrier to Entry- Medium barrier
- Provides specialized APIs and toolchains
- Native support for STM32, less support for other chips
- Low barrier
- Comprehensive documentation and huge community
- Relatively easy for beginners, low maintenance cost
- High barrier
- Must be familiar with a complete set of development toolchains
- Rich community and corporate resources, difficulty depends on application depth
- Medium barrier
- Design is relatively simple and easy to understand
- Modularity allows flexible expansion, but requires basic understanding of RTOS principles
Community & Ecosystem- High industry support due to Microsoft Azure
- Open sourced later, relatively less community support
- Has an extremely wide user community
- Rich third-party packages and forum resources
- Company and open source community work together
- Large manufacturers invest resources in development and provide hardware support
- Documentation and package tools are maturing
- Huge user base in Asian market
- Community is growing, third-party resources are increasing year by year
Scope of Application- Consumer electronics, industrial equipment
- Highly resource-constrained or high-performance applications
- Widely used in various microcontrollers and embedded devices
- Suitable for small and medium projects or prototype development
- Products with high cross-platform compatibility
- Devices requiring integration of multiple communication protocols
- Small IoT devices, home appliances, industrial control, etc.
- Suitable for scenarios with limited resources and high real-time requirements
Examples- Highly integrated SoC platforms
- Network devices, medical instruments, consumer electronics
- Systems with limited resources but requiring stability
- IoT edge devices
- Small sensors, portable products
- Industrial automation control
- High-speed communication equipment
- Industrial equipment requiring complete tracking and debugging capabilities
- Precision instruments and high reliability applications
- Embedded microcontrollers
- Smart home and wearable devices
- Scenarios requiring fast boot and efficient scheduling

Differences in Kernel Features

NameAzureRTOS (ThreadX)FreeRTOSZephyrRT-Thread
Kernel Architecture- Lightweight, modular design
- Single-core real-time system
- Provides preemption-threshold
- Single-core design
- Enable/disable functions freely via config file
- Easy porting for MCU
- Microkernel-like concept
- Kconfig customizable/expandable at compile time
- Supports multi-core (SMP)
- Microkernel + Modular
- Expand via Packages
- Default kernel is lightweight, fast boot speed
Scheduling Mechanism- Preemptive multitasking
- Priority scheduling
- preemption-threshold reduces unnecessary preemption
- Preemptive or cooperative multitasking
- Time slicing optional
- Task notification improves performance
- Hybrid preemptive/cooperative
- Supports task migration under multi-core
- Flexible setting of time slice and preemption policy
- Preemptive based on priority
- Low switching overhead
- Suitable for time-critical applications
Interrupt Management- Provides fast interrupt response
- Can use IPC primitives in ISR
- Suggests complex logic be placed in Thread
- Complete interrupt priority setting specifications
- Provides “FromISR” API to interact with kernel
- Avoid high priority interrupts blocking RTOS services
- Methods correspond to different architectures
- Allows complex processing in the latter half of ISR
- Supports irq_offload
- Concise interrupt entry/exit
- Can wake up tasks or IPC in ISR
- Suggests handling heavy tasks after interrupt or in Task
Task Communication & Sync- Provides Semaphore, Mutex, Event Flags, Message Queue
- Block Pool / Byte Pool as underlying resources
- Has Queue, Semaphore, Mutex, Event Group, Task Notification
- Queue is the core communication channel
- Provides diverse mechanisms like Queue, FIFO, LIFO, Pipe, Mailbox, Semaphore, Mutex
- High-level communication like Signals/Events
- Provides Semaphore, Mutex, Event, Mailbox, Message Queue
- Modular API, easy to expand
Memory Management- Block Pool (fixed size)
- Byte Pool (flexible allocation)
- Suitable for small systems
- Multiple heap implementations (heap1~heap5)
- Choose static or dynamic allocation based on needs
- Must pay attention to allocating Semaphore / Mutex to ensure multi-task safety
- Multiple allocation strategies like slab, mempool, heap
- Fine-tuning via Kconfig
- Requires good configuration at compile stage
- Mempool, heap dichotomy
- Default lightweight dynamic allocation algorithm
- Can be paired with custom or high-level alloc algorithms
Debug & Trace- Can use tools like TraceX
- High integration, visualizing Thread, Event, IPC
- FreeRTOS+Trace, many third-party IDE tracking tools
- Deep integration with Percepio Tracealyzer
- Unified Tracing subsystem
- Can connect to Tracealyzer, LTTng, SystemView, etc.
- Rich tracing support
- RT-Thread Studio or other plugins
- Provides simple log system and online debug mechanism
- Community also has tracing solutions similar to FreeRTOS Trace
Portability & Scalability- Officially supports most ARM, RISC-V, MIPS
- Community gradually expanding after Microsoft acquisition
- Ported to almost all MCUs
- Large number of third-party packages and drivers
- Can extend cloud functions via AWS FreeRTOS
- Native support for many major hardware manufacturers (Intel, NXP, Nordic…)
- Kconfig + Devicetree similar to Linux
- Corporate support and community equal weight
- Widely used in Asia (especially China)
- High integration with domestic MCUs, RISC-V platforms
- Packages allow flexible function expansion

Summary

Summarizing the four RTOS mentioned above:

  1. AzureRTOS (ThreadX): Known for high efficiency and small footprint, excels in executing in harsh resource-constrained environments, also has good debugging tools and business cases, good support for STM32.
  2. FreeRTOS: Has a huge open source community and flexible scalability, suitable for a wide range of microcontrollers and embedded applications, common in academic or commercial projects, suitable for beginners.
  3. Zephyr: Strongly promoted by the Linux Foundation and multiple companies, extensive hardware support, and powerful tracking and analysis tools, suitable for medium to large embedded applications requiring high reliability and detailed monitoring.
  4. RT-Thread: Lightweight architecture, clear modularity, fast boot speed, suitable for IoT and other scenarios requiring high real-time performance and resource efficiency.