0

Well, I think I've asked this question before but I want to be 100% sure I got this right,

Let's say I compile a C program. it's gets translated into bytecode, now what happens to that bytecode, does it immediately run on the processor, or does it get processed by the kernel first and then runs on processor after the kernel has manipulated it and handled the memory allocation & etc....

Also, is a kernel considered as a virtual machine?

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
user3687265
  • 103
  • 3
  • 12
  • First read answers to similar questions [What happens when a computer program runs?](http://stackoverflow.com/questions/5162580/what-happens-when-a-computer-program-runs) and [What happens when you run a program?](http://stackoverflow.com/questions/1204078/what-happens-when-you-run-a-program) and [How does program execute? Where does the Operating Systems come into play?](http://stackoverflow.com/questions/1599434/how-does-program-execute-where-does-the-operating-systems-come-into-play) and then refine your own question to make it less broad (and eliminate the pieces you already understand) – xmojmr Dec 08 '14 at 21:23

2 Answers2

1

Let's say I compile a C program. it's gets translated into bytecode, now what happens to that bytecode, does it immediately run on the processor, or does it get processed by the kernel first and then runs on processor after the kernel has manipulated it and handled the memory allocation & etc....

The kernel is the core of an operating system. In a traditional design, it is responsible for memory management, I/O, interrupt handling, and various other things. In order to implement its functionality, the C library must call kernel functions. This is all managed by the compiler itself,though,it might internally communicate with the kernel. Hence,there is a major-role of compiler.

The compiled code can be in the form of object code or binary executables, i.e., program.obj on ancient Windows OS and a.out on ancient *nix machines, or an executable file as in current Windows OS, Linux, etc.

The source code during compilation is converted into generated code(executables) for target machine which is to be run directly on system(processor) using registers and memory and KERNEL then plays major role...

Also, is a kernel considered as a virtual machine?

Also, your kernel is a major component of real machine! So,how it could be itself a virtual machine?

So,clear answer--- NO !

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
1

No, it doesnt. Long story short: the only jobs of the kernel are to create a new control block structure which represent a new process, and that internally will be inserted in the scheduler to be scheduled according to certain policies.

Then there is the activation of the binary image: the kernel creates a new virtual space for the process, creates some executable pages to store the binary code of the executable, some other pages for data, and it starts to execute main(). It will execute whatever binary code will be in the executable, without doing any check.

Consider that is not THAT simple, there are many more operations regarding this process of the binary image activation. I advice you to read some operating system book which is introductory to these concepts, then a book about operating system internals to understand better what really happen. You can also read kernel source code, when available.

The kernel is NOT a virtual machine, these are two completely different concepts.

Marco Pagliaricci
  • 1,366
  • 17
  • 31