Answer the question
In order to leave comments, you need to log in
Who is the code derived from CIL (.net bytecode) for?
By compiling the source code in a .net-compatible language, we get CIL, which is subsequently translated by the virtual machine into, so to speak, the "final" code designed for a specific platform.
Usually you can find a wording like "compiled by a JIT compiler to machine code."
However, is it so right in the engine room?
After all, "machine code" means instructions that the processor can execute directly, without any additional transformations from various kinds of translators. If you open the Mono wiki page, in the first paragraph you can see for which operating systems there are implementations of mono and which processor architectures are supported. That is, you can write in Mono from under Windows, Macos, Linux, and the program you wrote will work on all OS from the list by reference (namely, Windows, Linux, BSD (FreeBSD, OpenBSD, NetBSD), Solaris, Mac OS X , Apple iOS, Wii).
But the operating system itself may not work with any processor architecture.
What I'm leading to is: if CIL is really compiled into machine code, which goes directly to the processor for execution, then why specify a list of target operating systems?
Maybe then CIL is still compiled into code for the operating system, which is already engaged in its final translation into machine code for the processor?
After all, even if we recall the book "Computer Architecture" by Tanenbaum, then there the level of machine instructions is at the very bottom, and above it there are several other levels, in particular, level 3 of the operating system
Answer the question
In order to leave comments, you need to log in
An executable is not a direct set of instructions. It can have a special structure - .com, exe, Linux and Unix binaries are different - CIL is compiled into machine code, but as a result, not just command bytecode is created, but a binary of a certain format that the operating system can work with - machine code must somehow be loaded into memory, perhaps not even all but in parts, the entry point must be reported to the processor, and so on.
Now there are practically no linear programs that are written in such a way that they are executed in a mono-environment - everything is written based on multitasking OS.
Thus, in the CLI, ordinary machine code that is executed by the processor, but which contains certain bookmarks, calls to operating system functions in order for this code to work successfully in a certain OS, so that it does not grab 100% of the CPU for empty cycles, and so on .
This does not mean that there is non-machine code, it means that the machine code is written to work in certain conditions and contains certain calls.
well-formulated question, contains at least half of the answer (c)here so..
Maybe then CIL is still compiled into code for the operating system, which is already engaged in its final translation into machine code for the processor?
код для операционной системы
. The operating system is exactly the same program (in reality, a set of programs) like all the others.if CIL is really compiled into machine code that goes directly to the processor for execution, then why specify a list of target operating systems?CIL is translated into machine code by runtime (for example, mono) at the moment immediately before execution. And if the runtime cannot work on a certain OS, then CIL will not work there either.
The article provided by the link explains in detail what and how under the hood of the net framework. There you will find the answer to your question.
https://habr.com/en/post/90426/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question