How do bare metal, embedded Linux and an RTOS compare as ways to program an IoT device?
Bare metal is one stand-alone program with no kernel. Embedded Linux gives a full OS with drivers and tools at the cost of size and power. An RTOS sits between them: a small real-time kernel that runs tasks concurrently with predictable timing.
* Three ways to structure device software, from smallest and simplest to largest and richest. *
| Bare metal | RTOS | Embedded Linux | |
|---|---|---|---|
| Kernel | None; code runs stand-alone on the processor | Small real-time kernel | Full Linux kernel with kernel/user isolation |
| Concurrency | Tasks run one at a time, driven by priority-based interrupts and timers | Tasks run concurrently; preemption lets a higher-priority task interrupt a lower one | Processes and threads, but scheduling is tuned for throughput, not deadlines |
| Synchronisation | No tools; you build your own flags | Semaphores, mutexes, queues | Full set, plus IPC between processes |
| Footprint | Smallest memory, lowest power and cost | Kilobytes, plus optional file systems, protocol stacks, GUIs | Larger footprint, more RAM, bigger SoC, more power |
| Ecosystem | What you write yourself | Drivers and stacks for the target chip | Large driver library, mature IP stack, vast reusable source code, advanced compile and debug tools |
| Best for | Ultra-low-power, single-purpose devices | Devices that must respond within a defined short time | Gateways and devices that need rich software |
The deciding question is what the device has to guarantee. If it only reads a sensor every minute, bare metal is enough. If it must react to an event within a few milliseconds while also running Wi-Fi, an RTOS gives concurrency without giving up timing. If it needs a web server, a database and SSH, embedded Linux is worth the megabytes and the watts.
Tip: Linux is fair, an RTOS is predictable, bare metal is simple.
Go deeper:
Wikipedia — Embedded Linux — what it takes to shrink Linux onto a device, and where it is used.
DigiKey — Introduction to RTOS Part 1: What is a Real-Time Operating System? — the same bare-metal / RTOS / general-purpose OS comparison, with a super-loop example.