Virtual machine for a high level programming language vs an operating system

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?

3

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.

2

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).

2

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.

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.

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.

Only superficially.

OS typically does not have the luxury to run detailed static (compiler or machine code) analysis on any executable code that the user is about to run on the OS.

Whereas the language execution environment is partly responsible for compiling the code from a higher level representation into executable machine instructions, therefore it is in a perfect position to perform analyses to prevent certain types of malformed, rogue, or jailbreaking payload.

On the other hand, high-end anti-virus solutions often promise to do this kind of analyses. However it can only do this on a very selective basis.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật