What is the difference between Bare metal, RTOS and SoC?
The statement &quot;An RTOS is code written on bare metal&quot; is very misleading; all operating systems are written at a level that would be considered bare metal, except we only use the term bare metal to describe software/firmware that is written to operate directly without the use of an operating system. Sometimes you may see the term EABI used to mean bare metal, EABI stands for Embedded Application Binary Interface, but it really means code that isn't an application and that has no Application Binary Interface.
Software OS (operating system) categories are roughly: RTOS where the task scheduler guarantees execution time for designated critical system tasks, EABI/&quot;bare-metal&quot; where there is no OS at all and resources are managed directly by the software; Hypervisor for lightweight &quot;virtual machine&quot; task swappers that sort of try to encapsulate several traditional OSs, and finally just plain OS for operating systems that didn't have the benefit of this kind of marketing buzzword generator. This is all independent of whether the hardware is based on a CPU, a microcontroller, or a SoC.
From the perspective of problem-solving:
Software: EABI/bare-metal is just a new name for how programming was always done since Von Neumann and storable-program digital computers. (Before that, programming was much closer to designing a whole new hardware configuration for each new problem.) The name emerged somewhat recently to describe the alternative to other approaches. For example the GCC compiler builds code that works with some type of target OS, so there is a target field that can be &quot;windows&quot; or &quot;linux&quot; or &quot;EABI&quot; if neither of those. Most code written on microcontroller systems like PIC and Arduino is actually bare-metal.
Software: OS solves the problem of many different pieces of application software each needing to support every new piece of hardware, and also supports sharing resoruces among multiple application programs. Introduced time-sharing, inter-process communication, device drivers, file systems, and even the distinction of application software which is focused on solving one particular problem, without getting bogged down in all of the details of managing every resource directly.
Software: RTOS solves the problem of guaranteed latency. Keeping an advanced fighter jet airplane flying is a difficult problem, because the airframes they use are unstable -- allowing quick, nimble flying, but not able to just glide without constant correction. When the operating system is in charge of controlling the flight surfaces, the system absolutely cannot tolerate a delayed response -- the RTOS must be able to guarantee that every critical process gets enough system resources to produce results according to a real-time schedule. This makes the task scheduler more complicated, and the trade-off is that the RTOS has to be able to reject launching a new process if it cannot absolutely guarantee that the new process won't impact critical scheduled tasks.
Hardware: CPU &quot;Central Processing Unit&quot; is the main part of a computer system, that reads instructions from the memory system (which is external), decodes those instructions, and performs those actions. The term is used both for big furniture-sized IBM System/360 cabinets as well as for single-chip CPUs such as 8080/8085/Z80, 6502/6500/6800, etc. The CPU by itself can't do anything without a bunch of supporting actors providing memory and peripheral interfacing.
Hardware: Microcontroller would have been called a &quot;System on Chip&quot; if anyone in marketing had thought to call it that back in the mid 1980s... it's basically a single-chip CPU with some internal memory and some on-chip peripherals. Usually it does not have any way to add more memory and peripherals, because the CPU bus is completely internal to the microcontroller. Pins are expensive, and the CPU's internal bus requires a lot of pins working together. Microcontrollers solve the problem of running a &quot;bare-metal&quot; program inside a single IC, with communication only through bit-banging GPIO or low-pin-count interfaces like SPI/I2C.
Hardware: SoC &quot;System on Chip&quot; is really a marketing term, I think it first came from Xilinx Zynq XC7000 series. As Xilinx uses the term, it is a combination of dual-core ARM CPU together with FPGA programmable logic. Supposed to solve the problem of systems that require lots of application programming but also having low-latency programmable logic.