In computer science, bare machine (or bare metal) refers to a
computer executing instructions directly on logic hardware without an intervening
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
. Modern operating systems evolved through various stages, from elementary to the present day complex, highly sensitive systems incorporating many services. After the development of programmable computers (which did not require physical changes to run different programs) but prior to the development of operating systems, sequential instructions were executed on the computer hardware directly using
machine language
In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
without any system software layer. This approach is termed the "bare machine" precursor to modern operating systems. Today it is mostly applicable to
embedded system
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' ...
s and
firmware
In computing, firmware is a specific class of computer software that provides the low-level control for a device's specific hardware. Firmware, such as the BIOS of a personal computer, may contain basic functions of a device, and may provide ...
generally with time-critical latency requirements, while conventional programs are run by a
runtime system overlaid on an operating system.
Advantages
For a given application, in most of the cases, a bare-metal implementation will run faster, using less memory and so being more power efficient. This is because operating systems, as any program, need some execution time and memory space to run, and these are no longer needed on bare-metal.
For instance, any hardware feature that includes inputs and outputs are directly accessible on bare-metal, whereas the same feature using an OS must route the call to a subroutine, consuming running time and memory.
Disadvantages
For a given application, bare-metal programming requires more effort to work properly and is more complex because the services provided by the operating system and used by the application have to be re-implemented regarding the needs. These services can be:
* System boot (mandatory)
* Memory management: Storing location of the code and the data regarding the hardware resources and peripherals (mandatory)
* Interruptions handling (if any)
* Task scheduling, if the application can perform more than one task
* Peripherals management (if any)
* Error management, if wanted or needed
Debugging a bare-met