It struck me recently that a virtual machine for a high level programming language is very much like an OS. It manages resources, e.g. stack, heap, etc. similar to how an operating system manages resources and if the programming language supports threads then the virtual machine also does time-sharing and context switching similar to how an operating system does it.How far can this analogy be taken? Why is that we don't have a bare-metal implementation of the JVM? It seems like all the pieces are there so what exactly is the reason such things are not more prevalent?
Virtual machine for a high level programming language vs an operating system
programming languages;operating systems;virtual machine;virtualization
How far can this be taken?Pretty far. You might want to check out jnode (Java New Operating system Design Effort) (github repo) which is a full bare metal implementation of the JVM. Only about 500k of assembly, as a nano-kernel, used in the boot process. Once the OS is running, all running code is actually java.Why is that we don't have a bare-metal implementation of the JVM?A lot of things that JVM developers are used to thinking of as just there are actually supported by the underlying OS, and the JVM just uses the OS resource. Example:Device drivers. If you look at the jnode code above, you will find that there is ongoing effort in building device drivers. They need to be written in java, which you will never see anywhere else.