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-metal program is difficult since:
* There are no software error notifications nor faults management, unless they have been implemented and validated.
* There is no standard output, unless it has been implemented and validated.
* The machine where the program is written cannot be the same where the program is executed, so the target hardware is either an
emulator
In computing, an emulator is hardware or software that enables one computer system (called the ''host'') to behave like another computer system (called the ''guest''). An emulator typically enables the host system to run software or use peri ...
/ simulator or an external device. This forces to setup a way to load the bare-metal program onto the target (
flashing), start the program execution and access the target resources.
Bare-metal programming is generally done using a close-to-hardware language, such as
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), ...
,
C++,
C,
assembly language, or even for small amounts of code or very new processors
machine code
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 ...
directly.
All the previous issues inevitably mean that bare-metal programs are very rarely
portable.
Examples
Early computers
Early computers, such as the
PDP-11
The PDP-11 is a series of 16-bit minicomputers sold by Digital Equipment Corporation (DEC) from 1970 into the 1990s, one of a set of products in the Programmed Data Processor (PDP) series. In total, around 600,000 PDP-11s of all models were so ...
, allowed programmers to load a program, supplied in
machine code
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 ...
, to
RAM. The resulting operation of the program could be monitored by
lights
Light is an electromagnetic radiation, part of which stimulates the sense of vision.
Light or Lights may also refer to:
Illumination
* Light bulb
* Traffic light
Arts and entertainment Music
* Lights (musician) (born 1987), Canadian singer-son ...
, and output derived from
magnetic tape
Magnetic tape is a medium for magnetic storage made of a thin, magnetizable coating on a long, narrow strip of plastic film. It was developed in Germany in 1928, based on the earlier magnetic wire recording from Denmark. Devices that use mag ...
, print devices, or
storage
Storage may refer to:
Goods Containers
* Dry cask storage, for storing high-level radioactive waste
* Food storage
* Intermodal container, cargo shipping
* Storage tank
Facilities
* Garage (residential), a storage space normally used to store car ...
.
Embedded systems
Bare machine programming remains common practice in
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, where
microcontroller
A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs ( processor cores) along with memory and programma ...
s or
microprocessor
A microprocessor is a computer processor where the data processing logic and control is included on a single integrated circuit, or a small number of integrated circuits. The microprocessor contains the arithmetic, logic, and control circu ...
s often boot directly into monolithic, single-purpose software, without loading a separate operating system. Such
embedded software can vary in structure, but the simplest form may consist of an infinite
main loop, calling
subroutine
In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.
Functions ma ...
s responsible for checking for inputs, performing actions, and writing outputs.
Development
The approach of using bare machines paved the way for new ideas which accelerated the evolution of
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 ...
development.
This approach highlighted a need for the following:
*
Input/output
In computing, input/output (I/O, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, possibly a human or another information processing system. Inputs are the signals ...
(I/O) devices to enter both code and data conveniently:
** Input devices, such as
keyboards, were created. These were necessary, as earlier computers often had unique, obtuse, and convoluted
input device
In computing, an input device is a piece of equipment used to provide data and control signals to an information processing system, such as a computer or information appliance. Examples of input devices include keyboards, mouse, scanners, cameras ...
s.
For example, programs were loaded into the
PDP-11
The PDP-11 is a series of 16-bit minicomputers sold by Digital Equipment Corporation (DEC) from 1970 into the 1990s, one of a set of products in the Programmed Data Processor (PDP) series. In total, around 600,000 PDP-11s of all models were so ...
by hand, using a series of toggle switches on the
front panel of the device. Keyboards are far superior to these vintage input devices, as it would be much faster to type code or data than to use toggle switches to input this into the machine. Keyboards would later become standard across almost every computer, regardless of brand or price.
*Output devices such as
computer monitor
A computer monitor is an output device that displays information in pictorial or textual form. A discrete monitor comprises a visual display, support electronics, power supply, housing, electrical connectors, and external user controls.
The ...
s would later be widely used, and still are to this day. They proved themselves to be a huge convenience over earlier
output devices, such as an
array of lights on the
Altair 8800, which would indicate the status of the computer.
Computer monitors can also easily display the output of a program in a user friendly manner. For example, one would have to be intimately knowledgeable about a specific early computer and its display system, consisting of an array of lights, to even begin to make sense of the status of the computer's hardware. In contrast, anybody who can read should be able to understand a
well-designed user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine f ...
on a modern system, without having to know anything about the hardware of the computer on which the program is being run.
* Faster, cheaper, more widely available
secondary storage
Computer data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processing unit (CPU) of a comput ...
devices to store programs to
non-volatile memory
Non-volatile memory (NVM) or non-volatile storage is a type of computer memory that can retain stored information even after power is removed. In contrast, volatile memory needs constant power in order to retain data.
Non-volatile memory typ ...
. This was needed, as it was cumbersome to have to type code in by hand in order to use the computer in a useful way, which would be lost upon every
reboot
In computing, rebooting is the process by which a running computer system is restarted, either intentionally or unintentionally. Reboots can be either a cold reboot (alternatively known as a hard reboot) in which the power to the system is phys ...
due to the system saving it to
volatile memory.
* The requirement for a convenient
high-level language and a translator for such a high-level language to the corresponding machine code.
*
Linkers to link
library
A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
modules, which may be written by the user or already available on the system.
* Loaders to load
executable
In computing, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instructions", as opposed to a data fil ...
s into
RAM from the
secondary storage
Computer data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processing unit (CPU) of a comput ...
.
* Suitable
I/O devices, such as
printers for producing a
hard copy
''Hard Copy'' is an American tabloid television show that ran in syndication from 1989 to 1999. ''Hard Copy'' was aggressive in its use of questionable material on television, including gratuitous violence.
The original hosts of ''Hard Copy' ...
of the output generated by programs.
See also
*
Bare machine computing
Bare Machine Computing (BMC) is a computer architecture based on bare machines. In the BMC paradigm, applications run without the support of any operating system (OS) or centralized kernel i.e., no intermediary software is loaded on the bare machin ...
*
Barebone computer
*
Standalone program
A stand-alone program, also known as a freestanding program, is a computer program that does not load any external module, library function or program and that is designed to boot with the bootstrap procedure of the target processor – it runs o ...
References
* {{cite book, first1=A., last1=Silberschatz, first2=Peter, last2=Galvin, first3=Greg, last3=Gagne, title=Operating System Concepts, year=2003, isbn=9780471250609, url=https://archive.org/details/operatingsystemc0006silb, url-access=registration
History of computing hardware
History of software
Operating systems