Bare Metal Vs The World: When And Why To Use This IoT OS
Bare Metal for IoT runs one application at a time—in stark contrast to regular operating systems. Let's consider the options for developers and devices.
Join the DZone community and get the full member experience.
Join For FreeIntroduction
Not all operating systems are built equal. In fact, there is plenty of variety when it comes to multitasking, overheads, memory use, and more. This spectrum of choices can make things difficult for Internet of Things (IoT) developers when it comes to choosing the right system for their device.
One type that is uniquely suited to connected devices—at least basic ones—is Bare Metal. Just as a Bare Metal server only hosts one tenant at a time, a Bare Metal environment is entirely dedicated to running a single application. This is in stark contrast to regular operating systems which run multiple programs simultaneously. Let’s take a look at the different types of operating systems and consider which is best when it comes to IoT.
Bare Metal: Simplicity Is Key
A Bare Metal IoT system is a simple solution that is preferred for this very reason. In layman's terms, it’s a physical device that is completely dedicated to running a single application, which for example could be a “thermostat control program." In the days before PCs, this was how computers worked. You booted one program at a time and only one single application could run at the time.
However, when your PC desktop starts up today, it will normally boot up with Windows. Windows (or any other operating system) is a program. It is capable of loading, managing, and sharing the system resources (storage, CPU, network) to other applications (Word, Excel, browser) in a way where interference between these applications is minimal. This works well for a PC since users expect to run multiple programs at the same time, programs that might even not be known when the operating system was created. That being said, it doesn’t work so well for users who want to run one program and one program only.
Basic connected devices typically only comprise a sensor and a single function. Smart thermostats, for example, measure the temperature via a sensor and turn on a heater when the temperature reaches below a certain set threshold—it is normally a little more advanced than this, but let us use this as an example. Clearly, something as rudimentary as this does not require the level of operational complexity that is offered by Windows. So, the simple ability to boot one program only actually benefits basic use cases like this.
RTOS: Coping With Complex Scheduling
The simplicity of Bare Metal is especially evident when compared to its counterparts. The next step up from a Bare Metal system is RTOS (Real-Time Operating System). An RTOS has a relatively simple design, but, unlike Bare Metal, it can start and stop different processes concurrently. On the other hand, an RTOS is not as powerful as an OS. The biggest difference is usually memory protection and virtualization.
In a high-end operating system, application memory is separated and the OS ensures that one process (running application) cannot corrupt the memory of another process. This is done by virtualizing the memory. This makes it possible for the OS to swap unused memory onto the disk when not in use. 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 to a general system like a PC. However, on small embedded devices, this is different since you’ll usually have a good idea about:
- How many applications/processes need to be running
- What memory these applications/processes need
- Making sure those processes don’t interfere with each other.
In some circles, RTOS is favored for IoT applications because it can cope with the complex scheduling that most internet-connected embedded systems require. Further, integrating USB, TCP/IP, and GUI components into a Bare Metal system is time-consuming and extremely complex to the average developer.
OS: On The Heavier Side
Another step above RTOS—or, more like a huge leap above—is a fully-fledged OS. This operating system option is on the opposite end of the spectrum to Bare Metal. While Bare Metal and RTOS have some similarities—such as reduced overhead and efficient memory usage—Bare Metal and OS have virtually none.
You may be thinking that a traditional operating system is frowned upon by IoT developers and is simply too heavy for simple IoT devices—however, you’d be mistaken. One OS that is renowned and widely used within the IoT community is Linux, which is often a fixture of embedded systems.
One example of embedded Linux being used to operate a rather simple IoT device is the Raspberry Pi. The Raspberry Pi is a small circuit board that was originally designed for school children to engage children in software development. To this day, it’s well respected within the IoT community and often utilized in sectors such as industrial IoT.
Bare Metal |
RTOS |
OS |
|
Good for small devices |
✔ |
✔ |
❌ |
Level of application hardware control |
complete |
medium |
none |
Ability to multitask |
❌ |
Capable, but not with 100% separation |
✔ |
Overhead |
None |
Minimal |
High |
Efficient memory usage |
✔ |
✔ |
❌ |
Community support |
❌ |
✔ |
✔ |
Scalable/Portable |
❌ |
Medium |
Easily portable |
The Verdict: Which Is Right For You?
The decision of what’s right for your IoT device will come down to the use case. Simple sensors and basic devices simply do not need the processing power of higher-end operating systems and will likely benefit from the streamlined approach of Bare Metal. Heavier devices with more demands, meanwhile, will likely require something with a bit more muscle.
One important note is that despite Bare Metal development being time-consuming, a lot of developers do prefer to put in the extra work. This is because the more it’s managed, the more you’ve got the ability to control things.
Of course, not all that glitters is gold, and it is worth mentioning the limitations of Bare Metal environments. One of the costs of Bare Metal is lost performance since you have to communicate with the hardware through an operating system, but also all hardware across platforms needs to be unified and look the same. As a result, some features can become lost in operating system drivers.
Meanwhile, and this is of particular note for IoT devices, the need for internet communication can sometimes swing developers toward RTOS instead of Bare Metal. This is because internet communication requires the single application to now multiplex with the TCP/IP communication stack, which sometimes requires its own thread and can be simpler to handle on RTOS.
On the whole, though, Bare Metal does deliver ideal functionality for those devices with basic demands. The lack of overhead, efficient use of memory, and complete control of application hardware make it a contender for any straightforward connected device today.
Published at DZone with permission of Carsten Rhod Gregersen. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments