Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
3  
That is a hot topic for hypervisor-VMs / cloud-deployment. Some want to remove the OS openmirage.org , some want to remove the VM docker.io . –  Patrick Mar 8 at 8:58
    
Take a look at AS/400. –  SK-logic Mar 8 at 9:06

5 Answers 5

up vote 2 down vote accepted

How far can this be taken?

Pretty far. You might want to check out jnode (Java New Operating system Design Effort) 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.

share|improve this answer
    
Is jnode dead? It seems they haven't updated the site in a while. –  Aviv Cohn Mar 8 at 10:13
    
I checked the site before I posted this. There seems to have been some activity in the last couple of months. Jnode does seem to move slowly, and I suspect that this is at least partly due to the work involved in implementing hardware-level stuff. Skillsets [java language] and [bare metal driver] don't always intersect. But it is a fair question. –  SailsMan63 Mar 8 at 14:30

There are "bare metal" machines based on virtual machines. Most recently, there have been various attempts at a Java Processor which would run a JVM (well, JM since its not virtual) in hardware. They do exist - though not in general purpose machines that we use, they more harken back to the original embedded idea that Java was born from.

This harkens back to the Lisp machine which approached CPU design instead with high level instructions in the CPU itself.

The reason is... you don't really get that much out of the specialization at a hardware level... and the direction of research has been for smaller instruction sets with multiple cores rather than trying to make complex instructions. That's where the money has been chased and thats why people are exploring that path more.

The question to consider - is narrowing down your available programs that the system can run worth the investment cost of creating such a system. Furthermore, as the general purpose processors get faster, can you keep up with a viable alternative?

... cheaper desktop PCs soon were able to run Lisp programs even faster than Lisp machines, without the use of special purpose hardware. Their high profit margin hardware business eliminated, most Lisp Machine manufacturers went out of business by the early 90s ...

From Wikipedia on the Lisp Machine.

Note that last section on the other language-optimized computers which includes the above mentioned Java Processors. They just haven't been commercially viable in most situations (and none of them for a general purpose machine).

share|improve this answer
    
en.wikipedia.org/wiki/MAJC –  gnat Mar 15 at 21:10

Bare metal JVMs do (did?) exist, but never scaled enough in volume to fund enough development R&D to keep up with super high-volume mainstream processor implementations. An x86 (in a small nanometer process) or ARM ends up running a JVM faster and cheaper and using less power than a multi-Moores-law-generations-behind (thus, in big nanometer or micron process) custom JVM. And it currently takes tens of millions to billions to keep up.

The same thing happened to some non-consumer-driven RISC architectures and some less-specialized DSPs.

share|improve this answer

You are correct that there is a close relationship between VMs and Operating Systems. There is also a close relationship between those two and Programming Languages. In fact, one might argue that they are more or less the same thing!

There is a famous quote by Daniel H. H. Ingalls from the Design Principles of Smalltalk: "an Operating System is a collection of routines missing from the language; there shouldn't be one."

The original Smalltalk machines didn't have an OS, or rather the Smalltalk system was the OS. Even the video drivers were written in Smalltalk. You might also want to look into the design of the AS/400, which is closely related to what you are asking about.

share|improve this answer

Hardware implementations of the JVM do exist, and there are a number to choose from. However, they aren't without some drawbacks. For one, you can't easily upgrade the machine if it's written in silicon.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.