CSZoneCambridge International AS & A Level Computer Science 9618
What is a Virtual Machine?
A Software Emulation of a Computer
A virtual machine (VM) is a software emulation of a complete computer system. It runs on physical hardware (the host) and presents a virtual hardware environment to an operating system (the guest). Multiple VMs can run simultaneously on one physical machine.
KEY TERMS
Host machine — the physical computer running the hypervisor
Guest OS — the operating system running inside the VM
Hypervisor — software layer that manages and runs VMs
Snapshot — saved state of a VM at a point in time
BENEFITS
Server consolidation — run many VMs on one physical server
Isolation — if one VM crashes, others unaffected
Easy to back up, restore, and clone
Test different OS/software without dedicated hardware
Run legacy software on modern hardware
Type 1 vs Type 2 Hypervisors
Bare-Metal vs Hosted Hypervisors
TYPE 1 — BARE-METAL HYPERVISOR
Guest OS
Hypervisor (runs on hardware directly)
Physical Hardware
Runs directly on hardware — no host OS. Better performance, more secure. Used in enterprise data centres.
Examples: VMware ESXi, Microsoft Hyper-V, Xen
TYPE 2 — HOSTED HYPERVISOR
Guest OS
Hypervisor (app)
Host OS
Physical Hardware
Runs as an application on a host OS. Easier to set up, slower. Used for development and testing.
Test software in a clean, isolated environment without affecting host
Use snapshots to restore to a known-good state after each test
Test on multiple OS (Windows, Linux, macOS) on one machine
Safely test malware in sandboxed VM without risk to host
Cloud providers (AWS, Azure) deliver scalable VMs on demand
JVM — JAVA VIRTUAL MACHINE
Java source code compiled to bytecode (intermediate code)
JVM interprets bytecode on the host platform at runtime
"Write once, run anywhere" — same bytecode runs on Windows, Linux, macOS
Each platform has its own JVM implementation
JIT (Just-In-Time) compiler: frequently used bytecode compiled to native machine code for speed
Exam Practice
Cambridge-style questions
Question 1
A software developer wants to test their application on three different operating systems before release. Explain how a virtual machine could be used to carry out this testing, and state two benefits of this approach. [4]
2
The developer installs a Type 2 hypervisor on their workstation and creates three separate VMs — one running each target operating system (e.g. Windows 10, Ubuntu Linux, macOS). The application can be installed and tested in each VM without needing three separate physical machines.
1
Benefit 1: Snapshots can be taken before each test run — if testing causes a crash or corrupts the environment, the VM can be instantly restored to the clean state, saving time.
1
Benefit 2: Testing is isolated — if the software contains a bug that crashes an OS, it only crashes the VM, leaving the host machine and other VMs unaffected.
Common Mistakes
Don't lose easy marks
1
Saying VMs "run on the cloud" — this conflates VM technology with cloud computing. VMs run on hypervisors, which can run on your own hardware (on-premise) or in a cloud data centre. The cloud uses VMs, but VMs are not exclusive to the cloud.
2
Confusing the JVM with a general virtual machine — the JVM is a specific VM for running Java bytecode. It's not a hypervisor and doesn't run guest operating systems. A general VM virtualises hardware; the JVM virtualises an instruction set for bytecode execution.
3
Saying bytecode is "compiled directly to machine code" — bytecode is an intermediate representation (not machine code for any specific CPU). It's interpreted by the JVM at runtime. JIT compilation may convert hot paths to native code, but the initial compilation is to bytecode, not machine code.
Topic Summary — 3.3.2
What You Need to Know
VIRTUAL MACHINES
Software emulation of hardware. Type 1 hypervisor: bare-metal, enterprise use (ESXi, Hyper-V). Type 2 hypervisor: runs on host OS, for development (VirtualBox). Benefits: isolation, snapshots, server consolidation, multi-OS testing.
JVM & INTERMEDIATE CODE
Java source → bytecode (platform-independent intermediate code). JVM interprets bytecode on each target platform. "Write once, run anywhere." JIT compiler converts frequently-run bytecode to native machine code for performance.
CSZone
Next Video
3.4.1
Language Translators
Compilers · Interpreters · Assemblers · Linkers
Head to CSZone.co.uk for the complete worksheet, quiz, and interactive tools