+ 1
how does an operating system that can run on many different processors execute the program?
when we make an app for certain OS, it gets compiled into machine code for that specific OS, but since an OS can run on different processors, does it mean the OS further compiles it down to the machine language that the installed processor understands?
6 Respostas
+ 2
I think you have a wrong understanding of what role the OS has in a computer system. It doesn't play ANY role in compiling code into machine language, other than supporting the compiler than runs on top of it.
An OS"s basic function is to simply manage the resources available to the system: the cpu, memory, I/O devices, and external and internal drives. What does the compiling is the software that resides on top of the OS, namely the compiler and other programs that support it, like the scheduler routines and such in the kernel.
Compilers know, more or less, what they're compiling for, or at the very least, have settings that allow you to change what system they are compiling for. The most important thing they need to know is whether the machine code they produce will run on the hardware the code will be loaded into, which is largely dependent on the Instruction Set Architecture (ISA) of a system. Since many silicon companies have standardized how instructions are formatted, this isn't as common a problem as it once was. ARM and Intel's x86 and x64 architectures are the most common now.
The OS does have a role in running the compiled machine code, which is why Windows Software doesn't usually run on linux, and vice versa. This isn't a ISA conflict, however, rather an internal difference between the OS's that can fubar how it reads the instructions.
Hope that clears up some stuff for you.
+ 2
Thanks a lot Martin Taylor
i really appreciate all the infos provided by u😊
+ 1
「HAPPY TO HELP」 thanks for the answer, this things are really confusing.
i want to learn embedded system, i have many questions regarding it.
if we download a program in a microcontroller, do we directly compile it into a machine language understandable by the microcontroller?
how do languages that require a virtual machine to run work, run on small microcontrollers?
+ 1
Well you see, languages like c/c++ are cpu dependent, meaning if you want to run programs written in c for other cpus,you have to get the respective compiler for that cpu but with java for instance, when source code is compiled,its converted into bytecode that is not cpu dependant but needs an interpreter or JVM to run,so any machine with an interpreter can run source code without compiling
+ 1
Hacker029 what if the user somehow dont have JVM, do we send the JVM package along with the app?
0
Yes,You can create an executable i.e .exe but its irrelevant, jvms are crucial for a system anyway, we run java almost everywhere these days