15.1 Virtual Machines

Files and Resources - If necessary

Specification

NOTE:  Java Virtual Machines are covered in 1.5.4 & 3.4.3 Translators

Exam Key Terms

Summary of Key Terms

To understand a Virtual Machine (VM) we need to look at the options around its use. We'll start with looking at the key differences between a VM, hypervisor and emulator. The specification does not mention emulation, but it is implicit in understanding and discussing VMs.

Virtual Machine (VM):

What it is: A VM is a software emulation of a complete computer system. It has its own virtual hardware (CPU, memory, storage, network) and runs a guest operating system (OS) independently from the host OS.

How it works: VMs run on top of a hypervisor, which manages the allocation of resources and communication between the VM and the underlying hardware.

Benefits:

Use cases:

Hypervisor:

What it is: A hypervisor (or Virtual Machine Monitor, VMM) is a thin software layer that enables virtualization. It sits directly on top of the physical hardware and creates and manages VMs.

Types:

Role:

Emulator:

What it is: An emulator is a software or hardware system that allows one computer system (the host) to behave like another computer system (the guest). It focuses on replicating the behaviour of a specific hardware environment, including the CPU, peripherals, and even firmware.

How it works: Emulators translate guest system instructions into instructions the host system can understand. This translation process can be slower than running code natively on the hardware.

Use cases:

Key Differences Summary:

VM grid

To jump into more detail for VMs:

Examples of a VMs role:

Benefits and limitations of VMs

Benefits:

Limitations:

Background Reading (detail)

This section was re-written on the 17 March 2019.

While the textbooks provide little content, there is a confusing array of information on the Internet. You will the terms emulator and virtual machine used interchangeably.  This is NOT the case.  The key differences are:

Both aim for some level of independence from the hardware of the host machine, but a virtual machine tends to simulate just enough hardware to make the guest work, and do so with an emphasis on efficiency of the emulation/virtualization. Ultimately the virtual machine may not act like any hardware that really exists, and may need VM-specific drivers.

An emulator on the other hand tries to exactly reproduce all the behaviour, including quirks and bugs, of some real hardware being simulated. Required guest drivers will exactly match the environment being simulated. Emulators are used to allow gamers to play console games on vastly different hardware. 

What is Virtual Machine(VM)?

Computers vary in the hardware they use, and run different programs and operating systems. Sometimes we might want to have the functionality and capability of another computer system running on our own computer. It may be that the hardware for the other system no longer exists or is unavailable, or we may wish to have several versions of a computer running simultaneously on one hardware system.

We can use software to emulate the other computer system so that our computer can behave like that system. This emulation is known as a virtual machine.

The process of creating and running a virtual machine is known as virtualisation. The computer that runs the virtual machine is known as the host. The virtualised system is known as a guest. Virtualisation software, known as an emulator, creates a virtual implementation of the guest system on the host computer, providing the host with the functions and programs of the guest. The emulator translates the instructions of the guest computer so that the host computer can understand them.  Most modern CPUs allow instructions to bypass the host OS and run directly, allowing the VM software to directly access hardware without having to translate instructions for the host OS to run. This can give big speed improvments.

The emulator also provides a bridge that allows the virtual machine to use the user interface, via the host operating system (I/O – input/output), allowing the user to interact with the software running on the virtual machine.

Tasks of Virtual Machine Software

Virtual machine software undertakes many tasks, including:

Types of Virtual Machine

There are two main types you should know about:

System virtual machines

System virtual machines emulate the software of another computer system completely. They allow the host computer to have all the software functionality of the guest system.

System virtual machines run the operating system of the guest system within the operating system of the host, allowing programs supported by the guest operating system to be run on the host computer. As a result, system virtual machines are often used to allow the host computer to run an operating system written for another hardware platform. 

Users running Apple operating systems often use a Microsoft Windows virtual machine to run the Windows operating system on Apple computers. Similarly, users of Apple- or Windows-based computers often run Linux as a virtual machine. The system virtual machine allows full use of the guest computer operating system and the programs that run on it. 

Another use of system virtual machines is to provide access to programs that current operating systems no longer support. Many old DOS and Windows 3.1, 95 and 98 programs are not supported in Windows 8 and 10. Through using a system virtual machine for these old operating systems, such programs can still be run. 

System virtual machines often require substantial processing power and memory. This is inevitable, as many modern operating systems require fast processors and plenty of memory. When emulating these operating systems, the more capable a host computer is, the faster and more capable the guest operating system will be. A host computer with limited resources may still be able to run a system virtual machine but it may have degraded performance.

Process virtual machines

Sometimes called an application virtual machine, runs as a normal application inside a host OS and supports a single process. Its purpose is to provide a platform-independent programming environment that abstracts away details of the underlying hardware or operating system, and allows a program to execute in the same way on any platform. For example Wine software in Linux helps to run Windows application.  Therefore, they do not provide a platform on which an entire operating system could run, just a single program.

They are often used to support a programming language, allowing programs created in that language to run on a variety of systems.  They are frequently used to emulate old video game systems and arcade games.

Running virtual machines simultaneously

If a host system is powerful enough, several virtual machines can be run side-by-side on one computer. A good example of this is the increasing use of virtual machines to run several virtual servers, such as a domain name server, web server and print server, on one physical server. The host server maintains the virtual machines and allows them to act as though they are all separate computers.

Use of VMs

The desire to run multiple operating systems was the initial motive for virtual machines, so as to allow time-sharing among several single-tasking operating systems. The use of virtual machines to support separate guest operating systems is popular in regard to embedded systems. A typical use would be to run a real-time operating system simultaneously with a preferred complex operating system, such as Linux or Windows. Another use would be for novel and unproven software still in the developmental stage, so it runs inside a sandbox. Virtual machines have other advantages for operating system development, and may include improved debugging access.  They can also be used to run older software that may be incompatible with newer OS variants.  For example, many old MS-DOS games do not run under Windows 7, 8 or 10. A DOS emulator provides a virtual machine in which the game can communicate as programmed and the VM is able to communicate with the host hardware as necessary.

The role of the VM is to provide a virtual environment, separate from the host OS (on which the VM is running).  In addition, VMs will also allow you to run software on hardware they were not designed for.  For example, running Apple's OS X within Windows 10.  The more recent the operating system, the more sophisticated the VM typically needs to be, as recent OS will expect hardware features which need to be interpreted by the VM.  Performance can be a significant issue with VMs.

Virtual machines have a number of popular uses:

To summarise the paragraphs above, uses include:

Benefits and Limitations

The main advantages of virtual machines:

The main disadvantages:

Links

Videos

DOS box and discussion of emulation