Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can software be executed in bare metal machine? [duplicate]

I just wonder, can we execute a program on a machine without an operating system?

Besides, I heard that the Linux kernel is written in C language and a kernel is run during booting, so I just wonder how a computer understand the language without first compiling?

like image 278
caramel1995 Avatar asked Jan 20 '10 08:01

caramel1995


People also ask

Does bare metal have operating system?

The term bare metal refers to the fact that there is no operating system between the virtualization software and the hardware. The virtualization software resides on the “bare metal” or the hard disk of the hardware, where the operating system is usually installed. Bare metal isn't only used to describe hypervisors.

What is bare metal in software?

Bare metal programming is a low-level type of programming that is hardcoded to a system at the hardware level and operates without an abstraction layer or operating system (OS). It also interlinks with the hardware, considering the specific build of components.

What are the advantages of bare metal programming?

Bare-metal programming has the advantage that embedded software solutions can be planned in detail for a specific use case on the smallest possible level without having to accept the overhead and possible errors of an operating system.

What is bare machine in operating system?

In computer science, bare machine refers to a computer executing instructions directly on logic hardware without an intervening operating system. Modern operating systems evolved through various stages, from elementary to the present day complex, highly sensitive systems incorporating many services.


3 Answers

From Wikipedia:

When a computer is first powered on, it does not have an operating system in ROM or RAM. The computer must initially execute a small program stored in ROM along with the bare minimum of data needed to access the nonvolatile devices from which the operating system programs and data are loaded into RAM. The small program that starts this sequence of loading into RAM, is known as a bootstrap loader, bootstrap or boot loader. This small boot loader program's only job is to load other data and programs which are then executed from RAM.

The computer can understand the Linux kernel because it has already been compiled and stored (usually) on disk. The bootloader gives the computer enough functionality to load the precompiled kernel into memory.

You wouldn't need to load a whole operating system to run a program on a computer, you could write a bootloader to kick off a program you had compiled. You would not have access to any of the operating system calls that make life easier for programmers.

like image 160
mattjames Avatar answered Oct 21 '22 14:10

mattjames


In short, yes.

Linux is still a software program, in machine code, that runs on a bare metal machine. While you can execute a software program without an operating system, your program will need to implement ALL the code that is used to talk to various pieces of hardware in a computer to various degrees - e.g. outputting data to a display, interpreting input from a keyboard / mouse / network card etc. (Some of the very low level stuff are implemented by the firmware in computer components, but the rest your program will have to implement). This makes it very time-consuming and difficult for you to write something that runs entirely without an operating system.

like image 40
futureelite7 Avatar answered Oct 21 '22 13:10

futureelite7


Yes, and it is done today for small microcontrollers with a few KB of memory.

The program is typically written in C and compiled on some other computer (that is called cross-compiling) and then loaded as binary data into the flash memory of the controller.

like image 23
starblue Avatar answered Oct 21 '22 14:10

starblue