Java – can the kernel be written in assembly language?
I've never done kernel programming I am an excellent programmer of Java language and often use it Now I want to do something interesting with the kernel The kernel resides between the hardware and the operating system It uses system calls to communicate with hardware Each programming language requires a compiler to compile code written in a high-level language and then generate low-level code, usually assembly language code I doubt if we have a kernel written in C, should we install the C compiler on the machine? Finally, when the kernel interacts with the hardware, it uses assembly language. Can I create the kernel in Java? If so, what are the same requirements? thank you.
Solution
Generally, the kernel is considered part of the operating system
System call is the interface provided by the operating system to the user application program The operating system communicates with the hardware through other mechanisms, such as interrupts or memory mapping registers
Compiler output is usually native machine code or language specific bytecode (as in the case of Java) Sometimes, the compiler also targets another programming language, such as C or JavaScript (conversion)
This is not necessary The output generated by C compiler can be executed directly on hardware without interpretation
The CPU does not understand assembly It knows the machine code
It has been done
If you want to write the kernel in Java, you either have to
>Compile the entire java code base into machine code > give yourself a CPU that can execute Java bytecode > find or build Java VMS and runtimes that can run on bare metal machines and run java code in them (if you do this skillfully, you can write most of the runtimes or part of the VMS of Java itself)
Now let's talk about an unspoken, almost rheological problem:
Maybe not Why? First, because setting takes a long time Second, because you can't just write ways to develop average business applications You must consider the performance of very time critical code (for example, context switching, which usually requires manual adjustment of components fast enough), manual memory management (for example, your MRU may want you to give it the location of the physical address page table, system / hardware specific mechanism (how to access the XYZ controller on this specific architecture?)
Therefore, you will first lose many advantages of Java over low-level languages such as C