What is Virtualization and Emulation?


Virtualization involves simulating parts of a computer's hardware - enough for a guest operating system to run unmodified - but most operations still occur on the real hardware for efficiency reasons. Virtualization therefore is normally faster than emulation but the real system has to have an architecture identical to the guest system. For example, VMWare can provide a virtual environment for running a virtual WindowsXP machine "inside" a real one. However VMWare cannot work on any real hardware other than a real x86 PC.


In emulation the virtual machine simulates the complete hardware in software. This allows an operating system for one computer architecture to be run on the architecture that the emulator is written for.

The diagram below illustrates how a Java based PC emulator fits into the hierarchy of programs that uses the real computer's hardware. The real operating system is installed on the real hardware, and the JVM is installed on top of the real operating system. JPC emulates a layer of virtual hardware onto which another operating system and associated software can be installed.

Other Emulators

There are many different computer emulators, some of which have been written in Java: e.g. Commodore 64, Atari ST, Nintendo and ZX Spectrum. However, because of the frightening complexity of the x86 platform, emulators for the x86 PC less common, and until JPC, no one had written one in pure Java.

Probably the most impressive x86 emulator is QEMU, a generic machine emulator and virtualizer which can emulate various CPU types on several host systems. However because QEMU is written in C, and not Java, it is not easily ported to new host systems. Currently it only supports 3 host systems, while JPC will run anywhere where there is a Java SE compatible VM. (See JPC in action on just some of these platforms.)

QEMU is quick as an emulator, but it is also able to used as a virtualizer, where it can achieve near native performance by executing the guest code directly on the host CPU. But this approach does have some drawbacks. First, when QEMU is running as a virtualizer, the application running in QEMU is allowed out of the emulator's sandbox, and will execute directly on the host CPU. We consider this a massive security risk, one that we address by the application running in JPC not only within the JPC sandbox, but within the Java sandbox as well. Second, while QEMU can approach native speeds by using virtualization; virtualization will only work when the target CPU is of the same type as the host CPU. When QEMU is run in emulation, JPC is actually as quick or quicker! QEMU is a phenomenal effort, and because its open source, well written and mature, it has proven to be a valuable tool during compatibility testing of JPC.

Since we have gone public with JPC it has come to our attention that another group has also developed a Java based PC emulator. Dioscuri, which has been developed at the National Library of the Netherlands and National Archive of the Netherlands, is a project with a goal of digital preservation, i.e. to ensure documents and programs from the past can still be accessed in the future. Dioscuri is not as mature as JPC, and their emulation is very slow. They use none of the advanced optimization strategies that JPC employs, emulate only a very primitive PC, and are unable to execute code that uses Protected or Virtual 8086 Mode.