I never did kernel programming. I am a good programmer in the Java language and frequently use it. Now i feel to do something interesting with kernels. A kernel resides between hardware and OS. It communicates with hardware using system calls. Every programming language require a compiler to compile the code written in high level language and then it generate low level code, which is generally assembly language code. Here comes my doubt, if we have kernel written in C, then should we have a C compiler installed on the machine? At the end, when kernel interacts with hardware it uses assembly language, can i create kernel in Java language? If yes, then what are the requirements for the same? Thank you.
Share
Usually, the kernel is considered to be part of the operating system.
System calls are the interface that is provided by the OS to user applications. The operating system communicates with the hardware through other mechanisms (for example interrupts or memory-mapped registers).
The compiler output is typically either native machine code or a language-specific bytecode (like in the case of Java). Sometimes, compilers also target another programming language such as C or Javascript (transpilation).
That’s not necessary. The C compiler produces output that can execute directly on the hardware without interpretation.
The CPU doesn’t understand assembly. It understands machine code.
It has been done.
If you want to write a kernel in Java, then you either have to
Now to the unspoken, almost rhethorical question:
Probably not. Why? First of all, because it would take ages to set up. Second, because you couldn’t just code the way you develop an average business application. You’d have to think about performance of very time-critical code (e.g. context switching, which often requires hand-tuned assembly to be fast enough), manual memory management (as in: your MRU might expect you to give it the physical address where the page table lies), system-/hardware-specific mechanisms (how to access a XYZ controller on this particular architecture?), …
So you would lose many of the advantages that Java has over a low-level language like C in the first place.