CIE AS & A Level Computer Science, section 15.1 (Processors, parallel processing and virtual machines)
What a virtual machine is
A virtual machine (VM) is software that behaves like a complete computer, running on a real computer (the host). It has its own virtual processor, memory, storage and operating system (the guest).
Uses
- Running a different operating system on the same machine, such as Windows inside a Mac.
- Testing software safely, as a faulty program only affects the virtual machine.
- Running old software that needs an old system (emulation of older hardware).
- Running several servers on one physical computer.
- Languages such as Java use a VM so the same compiled code runs on any device with the VM installed (the VM translates it for the real hardware).
Benefits
- Isolated from the real system, so it is safe to test viruses or unstable software.
- Cheaper, as one computer replaces several.
- A VM can be copied, saved and restored.
- Portability of programs.
Drawbacks
- Slower than running directly on the hardware, because of the extra layer.
- Uses a lot of the host's memory and processor time.
- If the host fails, all the virtual machines on it fail.
- The VM may not support all hardware features.
Example: process virtual machines
Some languages run on a process virtual machine: Python and Java source code is compiled to bytecode, which the virtual machine runs, so the same bytecode works on any platform that has the virtual machine.
Common mistake: saying a virtual machine is a "real" separate computer. It is software sharing the host's hardware, so it is slower than the real thing. Also, the host and guest are different: the host is the real machine.
Exam tip: for a scenario, state the use and the benefit together, for example "test untrusted software in a VM because any damage is isolated".
Check yourself
What is the host in a virtual machine setup?
The real physical computer that runs the virtual machine software.
Give one benefit of testing software in a VM.
Any faults or damage are isolated from the real system.
Give one drawback of using a VM.
It runs more slowly than directly on the hardware, because of the extra layer.