If you’re developing a new IoT device or system, you’ll have to decide what kind of operating system it’s going to run on. It’s normally a case of choosing between a real time operating system (RTOS) and a traditional OS. However, a lot of IoT developers go down an old-school route and opt for bare metal. And unfortunately, there’s no easy way to decide between them.
I’ve heard plenty of debate about which of the three is best, but developers are pretty divided on the issue. Let’s take a balanced look at bare metal, RTOS, and OS to help you decide what might be the best for your next IoT project.
What is meant by “bare metal”?
A “bare-metal” device is a physical device that is completely dedicated to running a single dedicated application, which, for example, could be a program to control a smart thermostat. Back in the not-so-good-old days, this was how all computers worked. Only one single application could run at a time, so computers were specialized at performing just one task at a time.
However, when your PC desk starts up today, it will typically boot up with Windows or another operating system. And through an operating system, you can run a variety of applications simultaneously, like Excel, Slack, Chrome, etc. A PC does this in a way in which the applications don’t really interfere with each other, unless of course you have way too many tabs and applications open at the same time, at which point your computer might get a bit overwhelmed.
If you’re like me, you probably have plenty of experience with that. But typically, users expect to run multiple programs at the same time on a PC without too much trouble. But this type of multitasking isn’t necessary for all devices and programs.
For example, a thermostat program that just measures the temperature through a sensor and turns on a heater when the temperature drops too much doesn’t need this level of complexity. A device that basic doesn’t benefit from the higher energy usage and wasted computing power that can occur with an RTOS or OS, so you’d probably be better off using bare metal in that case.
RTOS vs. OS
The next step up from a bare-metal system in terms of computing power is an RTOS, or real-time operating system. An RTOS has a relatively simple design, but, unlike a bare metal system, it can stop one process and then start another. But an RTOS is not as powerful as an OS. The most significant difference is usually the way an OS can allocate memory to specific tasks to perform them simultaneously with relatively high performance, while an RTOS uses its memory to perform just one task at a time at the highest level of speed.
Using an OS ensures that one process – like running an application – doesn’t interfere with the memory of another process. Advanced memory handling is normally not present in an RTOS. This level of advanced resource management (memory, disk, network, CPU) is very useful when applied on a general system like a PC, where you may have a wide variety of applications you’ll want to run, and you’re not necessarily sure when you buy your computer what those will be. However, on IoT devices, you’ll typically have a good idea about:
- How many applications/processes will be running
- How much memory these applications/processes need
Knowing those things helps you make sure those processes don’t interfere with each other. An RTOS will just switch between tasks, rather than trying to do them at the same time, so the memory can be completely dedicated to that single task. Since the memory is dedicated, the task can be finished faster, which is why these systems are called real-time operating systems in the first place. That’s why a lot of developers choose an RTOS for IoT devices.
An RTOS is certainly more complicated than a bare metal system. It also has less computing power than an OS. That said, a lot of developers still prefer an RTOS because it offers more control, flexibility, and speed than an OS and with better performance than bare metal. Some of the most popular RTOS options for IoT include FreeRTOS from Amazon, Zephyr from the Linux Foundation, and Azure RTOS ThreadX from Microsoft.
Want to find the right RTOS for your IoT device or application? Read through Nabto’s IoT RTOS Comparison guide here.
Bare metal vs. OS
Bare metal and an OS are at opposite ends of the spectrum. While bare metal systems and RTOSs hold some similarities, such as reduced cost, energy, and efficient memory usage, bare metal and OSs have virtually none.
You may be thinking that a traditional operating system is frowned upon by IoT developers as simply too complex for any IoT devices. However, that’s not true in every case. A general-purpose OS like Linux or Windows is still a viable option for IoT applications that require rich functionalities with powerful microprocessors, large memories, and run complex software. An OS is better for IoT gateways, for example, which connect to many different IoT devices to funnel data and control to a central system. An OS is also better for cloud computing servers, where there’s a need to process large data streams from various nodes or end devices.
One OS that is pretty widely used in the IoT community is the aforementioned Linux, while Windows and Mac are rarely used. Some of the most popular OSs that are adjusted specifically for IoT are Linux-based. The Raspberry Pi is an example of an IoT circuit board that’s typically equipped with a version of Linux called the Raspberry Pi OS. A Raspberry Pi was originally designed to engage young students in software and hardware development. But it’s versatile enough that the board’s functionality has expanded far beyond being a hobbyist’s tool, and today it’s well respected within the IoT community and often utilized in applications such as industrial IoT.
So, how does Linux work for IoT? Well, rather than utilizing the full features of the OS, most Linux-based systems for IoT use a Linux kernel. A kernel is the core of the operating system, without a lot of extras. If you’ve ever had a Linux computer, you’ve probably noticed that it comes with certain extras and software already on board. A kernel still comes with certain software, but it’s much more streamlined. It’s a basic interface that allows developers to control and interact with everything in the system and install additional software applications as needed.
However, the pre-installed software that does come with the kernel can still be somewhat complex to manage for a new developer. It can be hard to grasp which applications are actually running, what their jobs are, and how to configure them without risking device security. For example, in the case of some surveillance cameras, breaches have occurred, not in the supplier’s software but rather in the supporting software distributed with the operating system.
Are you still stuck on what the key differences between RTOS and OS are? Check out our blog post on RTOS vs. OS – Advantages and Disadvantages.
Bare metal vs. RTOS vs. OS: comparison table
As you can see, there are many advantages and disadvantages to every one of these options. Furthermore, the perceived pros and cons differ depending on which developer you ask.
To help better explain the differences among bare metal, RTOS and OS, see the comparison table below.
The final word on bare metal vs. RTOS vs. OS in IoT
I’m afraid I can’t give you a definitive answer here. The debate will continue to rumble within the IoT community, and your only option is to make an informed decision based on the specific requirements of your product and your own preferences.
What I can tell you is that bare metal is great for IoT developers who want to remain in control of all aspects, employ limited and small devices or applications, and have the knowledge to code and maintain the IoT stack themselves. Whereas RTOS is a good option if you want minimal overhead with some resource management, but want a bit more community protection than the highly-culpable bare metal model. Finally, an OS is good if you have a larger device and you are okay with sacrificing some system resources and control to have the development skills and capability to step in and address any issues down the road.
If you want to find out what we’d recommend for your device – get in touch with us today and book a free consultation.
Read Our Other Resources
We’ve also published a range of IoT resources for our community, including:
- If you decide to use an RTOS, check out How to Choose the Best RTOS for IoT.
- Buying versus building an IoT platform, which discusses how to choose the best option for you.
- Our guide on how to Develop IoT Apps and what platforms you can use.
- A Complete Guide to REST APIs will help you learn more about the world’s most popular API.
- Find the right microcontroller by reading our Complete Guide to Microcontrollers for IoT.