Skip to content
systemcoding.dev
RTOS

FreeRTOS vs Zephyr vs NuttX vs ThreadX: Choosing an RTOS

Compare FreeRTOS, Zephyr, NuttX and ThreadX on licensing, scope, hardware support and learning curve, then pick the right RTOS with a decision table.

7 min read
Summarize in AI
Flat illustration of two options weighed side by side, with the GNU, Linux and C++ logos.

Choosing an RTOS is mostly choosing how much of the system you want someone else to have decided. FreeRTOS gives you a scheduler and a handful of primitives and leaves everything else to you. Zephyr gives you a scheduler, a driver model, a build system and a device description language, and expects you to adopt all of them. NuttX aims for a POSIX-flavored Unix on a microcontroller. ThreadX, now an Eclipse Foundation project, is a compact kernel with a long record in certified products. This post compares the four on the axes that decide projects, with the same task written four ways so the differences in API style are concrete. It sits next to the cornerstone guide on RTOS design for microcontrollers, which explains the shared concepts.

What each one actually is

FreeRTOS is a kernel library under the MIT license. The kernel is a few source files (tasks.c, queue.c, list.c, timers.c and optional ones), plus one port directory for your core and one heap implementation. Version numbers here refer to FreeRTOS Kernel V11.3.3. It does not include drivers, a filesystem or a network stack; those come from your vendor's SDK or from companion libraries.

Zephyr is a Linux Foundation project under the Apache 2.0 license, and it is a platform, not just a kernel. Zephyr 4.x ships a kernel, a driver model with a uniform API per device class, devicetree for describing hardware, Kconfig for selecting features, west for building, logging, a shell, networking, Bluetooth and more.

NuttX is an Apache Software Foundation project, also under Apache 2.0. Its goal is POSIX and ANSI compatibility with a small footprint, so it has a virtual filesystem, pthreads, poll, sockets and a /dev tree. Applications can be written against familiar Unix interfaces.

ThreadX is a small preemptive kernel with a design centered on predictable timing, originally commercial and now maintained as Eclipse ThreadX under the MIT license. It is often paired with companion components such as file, network and USB stacks from the same project.

The same task, four APIs

The blink-and-sleep task shows the style of each system. In FreeRTOS:

freertos_blink.cc
#include "FreeRTOS.h"
#include "task.h"

static void vBlinkTask(void *pvParameters)
{
    (void) pvParameters;
    for (;;)
    {
        led_toggle();
        vTaskDelay(pdMS_TO_TICKS(500));
    }
}

int main(void)
{
    board_init();
    xTaskCreate(vBlinkTask, "blink", 256, NULL, 2, NULL);
    vTaskStartScheduler();
    for (;;) { }
}

In Zephyr, the thread is declared statically and the hardware is looked up through devicetree:

zephyr_blink.cc
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);

static void blink(void *p1, void *p2, void *p3)
{
    gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE);
    for (;;)
    {
        gpio_pin_toggle_dt(&led);
        k_msleep(500);
    }
}

K_THREAD_DEFINE(blink_tid, 512, blink, NULL, NULL, NULL, 5, 0, 0);

In NuttX, you write a normal main-style entry and spawn it with task_create:

nuttx_blink.cc
#include <nuttx/config.h>
#include <sched.h>
#include <unistd.h>

static int blink_main(int argc, char *argv[])
{
    for (;;)
    {
        led_toggle();
        usleep(500 * 1000);
    }
    return 0;
}

int app_start(void)
{
    return task_create("blink", 100, 2048, blink_main, NULL);
}

In ThreadX, memory is yours to supply, and threads are created inside tx_application_define:

threadx_blink.cc
#include "tx_api.h"

static TX_THREAD blink_thread;
static ULONG blink_stack[512];

static void blink_entry(ULONG input)
{
    (void) input;
    for (;;)
    {
        led_toggle();
        tx_thread_sleep(50);
    }
}

void tx_application_define(void *first_unused_memory)
{
    (void) first_unused_memory;
    tx_thread_create(&blink_thread, "blink", blink_entry, 0,
                     blink_stack, sizeof(blink_stack),
                     5, 5, TX_NO_TIME_SLICE, TX_AUTO_START);
}

The ThreadX sleep argument is in ticks, so 50 ticks is 500 ms only if the tick is 10 ms, which is the default TX_TIMER_TICKS_PER_SECOND of 100. Each variant does the same job. What differs is who owns the hardware description, the build, the memory and the notion of a process.

Comparison

AspectFreeRTOSZephyrNuttXThreadX
LicenseMITApache 2.0Apache 2.0MIT
ScopeKernelFull platformPOSIX-style OSKernel plus companion stacks
Hardware descriptionYour headers or the vendor HALDevicetreeBoard configuration in KconfigYour BSP
Build systemAnythingCMake through westMake or CMake with KconfigAnything
Driver modelNoneUniform, per device classVFS with character and block driversNone
Priority numberingHigher number is higher priorityLower number is higher priority; negative values are cooperative threadsHigher number is higher priorityLower number is higher priority
Learning curveShallow for the kernel, deep around itSteep at the startModerate if you know POSIXShallow

The priority row is a classic trap when moving between systems. Read the documentation before porting a priority table.

How to choose

Start from the constraint that is hardest to change.

You must ship on a vendor SDK that already bundles one. Most silicon vendors ship FreeRTOS integration (STM32Cube, ESP-IDF's own FreeRTOS variant, NXP MCUXpresso). If the vendor stack is the center of your product, use the RTOS it expects.

You want the largest hardware and middleware catalog with one build. Zephyr supports a very wide range of boards and has maintained drivers, networking, Bluetooth and a test infrastructure. Accept the learning cost of devicetree and Kconfig up front, and it pays back on every new board.

You want Unix tools and portability from Linux code. NuttX lets you reuse POSIX code, shell commands and file-oriented drivers. It is popular in flight controller and some audio projects for that reason.

You need a small, predictable kernel with a certification history. ThreadX and FreeRTOS both have safety-certified variants, and the choice often follows which one your certifying body and silicon partner already support.

You are not sure. Pick FreeRTOS for a first project on a small part. It has the biggest body of tutorials and examples, and what you learn about tasks, queues and priorities transfers to every other RTOS.

Costs that do not show up in a feature table

A feature table says what each system can do. It does not say what each one costs you in the second month, and that is where projects are won or lost.

Time to the first blinking LED. With FreeRTOS on a board whose vendor SDK includes it, a working task appears within an hour, because the example projects already contain the port, the heap choice and the configuration header. Zephyr needs a toolchain install, the west workspace and an understanding of the board definition before the first build, which is a day for a newcomer. NuttX needs a configuration pass through its Kconfig menu. ThreadX sits in between and depends on the board support you start from.

Where the drivers come from. In FreeRTOS projects the drivers belong to the silicon vendor, so you inherit their quality, their licensing and their update schedule. In Zephyr the drivers live in the tree and follow one API per device class, so swapping an I2C sensor board for another touches a devicetree overlay and not the application. That uniformity is the strongest practical argument for Zephyr in a product family that will change its hardware.

Upgrades. A FreeRTOS kernel upgrade is usually a directory replacement and a read of the release notes. A Zephyr upgrade can touch devicetree bindings, Kconfig symbols and driver APIs, and the project documents each release's migration guide. Budget a few days per release if you track upstream, or pin a long-term support release and upgrade on a schedule.

Hiring and help. FreeRTOS has the largest pool of engineers who have used it and the most answered questions. For the others, the community is smaller but active, and each project runs a mailing list or chat for design questions.

Certification. If a regulator will examine the kernel, look for the artifacts you will need before you look at features: a safety manual, a qualified toolchain, a certification evidence package and a vendor who will support you through an audit. Check which of those exist for your exact kernel version and core.

Matching the choice to the project

A short rule of thumb helps when a team is split. A single board, a small team, a deadline within a quarter and a vendor SDK on the shelf point to FreeRTOS. A family of products with different boards, a need for Bluetooth or networking and a team willing to learn the build system point to Zephyr. A team coming from Linux that wants familiar shell, file and socket interfaces points to NuttX. A product that needs an existing certification path and a compact kernel points to ThreadX or a certified FreeRTOS variant, and the certifying body's list narrows it further.

Whichever you pick, isolate the kernel behind a thin layer of your own for the three or four services you use everywhere: create a task, send a message, take a lock and sleep. The layer is a few hundred lines. It will not make a port painless, but it keeps the next decision from rewriting your application.

When not to switch

Moving a working product between RTOSes costs more than the API translation suggests. Priorities invert, timing differs, and the driver layer changes. Only switch when the current RTOS blocks something you need, such as a missing stack or a license problem, not because another one has a nicer logo.

Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.