Linux vs Bare Metal – Advantages of Programming Under an OS

embedded-systemslinuxoperating systems

Assume you are presented with an embedded system application to program, in C, on a multi-core environment (think a Cavium or Tilera) and need to choose between two environments:

Code the application under Linux in SMP mode or code the application under a thin bare metal executive (something like a very minimal RTOS), perhaps with a single core running UP Linux that can serve control tasks.

For the purpose of this question, assume that both environment provide the same level of performance guarantees in any measurable aspects of run time performance, including number of meaningful action per second, jitter, latency, real time considerations – the works. (and yes, I realize this is by far not a trivial assumption at all, bare with me).

How would you justify going with a Linux SMP based solution rather then a bare metal thin executive solution?

The question may seems silly. It certainly seems obvious to me – but I have to convince someone that does not think the same. Could you help make a list of arguments in favor of choosing a real SMP aware OS (Linux) vs. a bare metal executive assuming performance guarantees are NOT an issue?

Many thanks

Best Answer

Some initial advantages include:

  • Code safety because the operating system can enforce memory protection and run some tasks in supervisor mode and others in user mode. A few years ago when I had a class for a very popular RTOS I was shocked to see it used a flat, shared memory space. Not sure if this is common, but it seems like a big jump backward.
  • Availability of wide ranging support for many peripherals through drivers.
  • If a device is not available, a driver can implement just the functionality needed to fit with a corresponding stack, rather than everything that goes with having the device. Typically at least one similar device will have been written and can be used as an example.
  • There may be compiler or library level support for thread safe support for Linux. If you have an executive, you may lack this and you may need to provide it yourself. If the executive has an active user base, there may be a combination of libraries available for purchase or via open source, but the quality may depend on how wide and deep the support that community provides. Pick your community with care.
  • If you start without all the baggage that comes with a real operating system, how long until you can't get along without those extra features? Who writes, integrates, and maintains them?

Hope this helps.

Related Topic