Cambridge 9618 · International A Level Computer Science · ~16 min read
Notes
Video
Slides
Quiz
Worksheet
What is a Virtual Machine?
A virtual machine (VM) is a software emulation of a complete computer system. It allows a physical computer to run multiple independent operating systems simultaneously. Each VM behaves as if it were a separate physical computer with its own CPU, memory, storage, and network interface — but shares the actual physical hardware with other VMs.
The actual physical hardware is the host
The OS running inside a VM is the guest OS
The software managing VMs is the hypervisor (also called Virtual Machine Monitor / VMM)
Applications (running in VM)
e.g. web server, database, app
Guest OS (inside VM)
e.g. Ubuntu, Windows Server
Hypervisor (VMM)
Manages VMs, allocates resources
Host OS (Type 2 only)
e.g. Windows 11 (not present in Type 1)
Physical Hardware
CPU · RAM · Storage · Network
Hypervisor Types
A hypervisor is the software layer that creates, runs, and manages virtual machines. There are two types:
Type 1 — Bare-Metal Hypervisor
Runs directly on the hardware — no host OS underneath
More efficient — less overhead
Better performance for VMs
Used in enterprise data centres and cloud computing
Examples: VMware ESXi, Microsoft Hyper-V, Xen, KVM
The hypervisor IS the operating system for the hardware
Type 2 — Hosted Hypervisor
Runs on top of an existing host OS
More overhead — hardware access goes: app → guest OS → hypervisor → host OS → hardware
Easier to install and use
Used on developer workstations and desktop testing
Each VM is isolated — a crash or security breach in one VM cannot affect others or the host.
⚡
Resource Efficiency
Multiple VMs share one physical server — hardware resources are used more efficiently than one OS per server.
📸
Snapshots
Save the exact state of a VM at any point. Restore instantly if something goes wrong — perfect for testing.
🔧
Testing & Development
Run a different OS to test software or run malware safely, without risking the main system.
🏛️
Legacy Software
Run old software that requires an older OS inside a VM, even on modern hardware.
☁️
Cloud Computing
Cloud providers (AWS, Azure) run thousands of VMs per physical server — selling computing as a service.
Disadvantages of Virtual Machines
Performance overhead: VMs use more CPU and RAM than native execution — the hypervisor layer adds latency
Resource competition: many VMs on one host compete for the same physical RAM, CPU, and I/O
Complexity: managing many VMs requires specialised knowledge and tooling
Startup time: booting a full guest OS takes time (though fast snapshots mitigate this)
Emulation vs Virtualisation
🎮 Emulation
Simulates a completely different hardware architecture
Every instruction translated from the emulated CPU to the host CPU
Very slow — each guest instruction may require many host instructions
Example: running PS2 games on a PC (different CPU architecture)
Example: running ARM Android apps on an x86 PC
⚡ Virtualisation
Guest and host share the same CPU architecture
Guest instructions can often run directly on the CPU (with hardware assistance)
Near-native performance — much faster than emulation
Example: running Ubuntu Linux VM on an x86 Windows machine
Requires hardware support: Intel VT-x or AMD-V
Virtual Machines for Intermediary Code
The term "virtual machine" also applies to software environments that execute bytecode — an intermediate representation between source code and native machine code. The most important example in Cambridge 9618 is the Java Virtual Machine (JVM).
Java / JVM execution model
Java source code .java files
→
Compiled by javac compiler
Java bytecode .class files
→
Distributed and run on any platform
JVM (Virtual Machine) Windows / Mac / Linux
→
JIT compiles or interprets bytecode
Native machine code CPU executes
Why use bytecode and a VM?
Write Once, Run Anywhere: Java bytecode runs on any machine that has a JVM — Windows, Mac, Linux, Android — without recompiling
Security: the JVM provides a sandboxed environment — bytecode is checked before execution, preventing certain attacks
JIT (Just-In-Time) compilation: the JVM can compile frequently-used bytecode to native machine code at runtime, improving performance
Other examples: Python runs on a VM (CPython); .NET programs run on the CLR (Common Language Runtime)
Language
Bytecode format
Virtual Machine
Java
.class files
JVM (Java Virtual Machine)
C# / .NET
CIL (Common Intermediate Language)
CLR (Common Language Runtime)
Python
.pyc files
CPython interpreter
Kotlin, Scala
.class files
JVM
Cambridge 9618 exam tip: Know two uses of "virtual machine": (1) hardware virtualisation — a guest OS running on a hypervisor; (2) bytecode VM — JVM/CLR running bytecode. For hardware VMs: distinguish Type 1 (bare-metal, runs on hardware, used in data centres) from Type 2 (hosted, runs on host OS, used on desktops). Benefits: isolation, resource efficiency, snapshots, testing, legacy software. For JVM: Java compiled to bytecode → JVM interprets/JIT-compiles → native code. Key advantage: write once, run anywhere.
⚠️ Common Mistakes
Confusing emulation and virtualisation — emulation simulates a different CPU architecture (slow); virtualisation shares the same CPU architecture (fast/near-native)
Saying Type 1 hypervisors are "better" in all cases — Type 2 is easier to set up and use on a developer's laptop; Type 1 is better for production servers
Saying the JVM compiles Java — the JVM runs bytecode; the Java compiler (javac) produces bytecode from .java source code; JIT compilation within the JVM converts bytecode to native code at runtime
Forgetting VMs have performance overhead — VMs always use more CPU/RAM than running on bare metal, because the hypervisor layer adds overhead
Confusing guest OS and host OS — host OS is the OS of the physical machine; guest OS runs inside the VM
✅ Notes completed!
▶
Video coming soon
Click slide or press arrow keys to navigate
Worksheet — 3.3.2 Virtual Machines
8 questions · Cambridge 9618 standard
Q1State two differences between a Type 1 and a Type 2 hypervisor.[2]
✅ Mark scheme
Any two from: Type 1 runs directly on the hardware; Type 2 runs on top of an existing host OS [1]; Type 1 has better performance/less overhead; Type 2 has more overhead [1]; Type 1 is used in data centres/enterprise; Type 2 is used on personal workstations for development/testing [1].
Q2Give three reasons why companies use virtual machines in their data centres instead of one application per physical server.[3]
✅ Mark scheme
Any three from: more efficient use of hardware resources — multiple VMs share one physical server [1]; isolation — a failure or security breach in one VM does not affect others [1]; easy to scale — new VMs can be created quickly without purchasing new hardware [1]; snapshots allow quick backup and recovery [1]; reduced physical hardware costs and energy consumption [1].
Q3Explain the difference between emulation and virtualisation. Give an example of each.[4]
✅ Mark scheme
Emulation simulates a completely different CPU architecture — every guest instruction must be translated to the host CPU's instruction set, making it slow [1]; example: playing PS2 games on a PC, or running ARM software on an x86 machine [1]; virtualisation runs a guest OS that uses the same CPU architecture as the host — guest instructions can run directly on the CPU with hardware assistance, giving near-native performance [1]; example: running Ubuntu Linux in VirtualBox on a Windows x86 machine [1].
Q4Describe the role of the JVM in running Java programs. Include what bytecode is and what JIT compilation does.[4]
✅ Mark scheme
Java source code (.java) is compiled by the Java compiler (javac) into bytecode (.class files) — bytecode is an intermediate representation that is not native machine code for any specific CPU [1]; the JVM (Java Virtual Machine) is a software virtual machine that executes bytecode on any platform — it reads the .class files and runs them [1]; JIT (Just-In-Time) compilation: the JVM identifies frequently-executed sections of bytecode and compiles them to native machine code at runtime, so they execute faster than interpretation [1]; this means Java is "write once, run anywhere" — the same bytecode runs on any machine with a JVM, whether Windows, Mac, or Linux [1].
Q5State one disadvantage of running software inside a virtual machine compared to running it directly on hardware.[2]
✅ Mark scheme
Performance overhead — the hypervisor layer between the guest OS and the hardware adds latency to every hardware access; running in a VM uses more CPU and RAM than running the same OS directly on the hardware (bare metal) [1]; this means tasks complete more slowly and the physical machine needs more resources to run the same workload inside a VM [1].
Q6A software developer needs to test whether their application works on Windows, macOS, and Linux. How can virtual machines help with this? State two advantages over having three separate physical computers.[3]
✅ Mark scheme
The developer can run all three operating systems as VMs on a single machine, switching between them easily [1]; advantage 1: cost — no need to purchase three separate physical computers [1]; advantage 2: snapshots — the developer can take a snapshot of each VM before testing, and instantly restore it if the test causes problems (no need to reinstall the OS) [1]. Accept any valid advantage with a clear explanation.
Q7Explain what a virtual machine is and describe the role of the hypervisor. State two benefits of running virtual machines on a single physical server, and identify one performance disadvantage compared to running directly on hardware.[5]
✅ Mark scheme
A virtual machine is a software emulation of a complete computer system that runs on top of a physical host machine [1]; the hypervisor (VMM) manages and allocates the physical hardware resources (CPU, RAM, storage) among multiple VMs and enforces isolation between them [1]; Benefit 1: server consolidation — multiple VMs share one physical machine, reducing hardware costs and energy consumption [1]; Benefit 2: isolation/security — a crash or compromise in one VM does not affect others running on the same host [1]; Disadvantage: overhead — the hypervisor adds a layer of abstraction that consumes CPU and memory resources, reducing the performance available to each VM compared to native execution [1].
Q8Distinguish between emulation and virtualisation. Explain why emulation typically has higher performance overhead than virtualisation, and give one use case where emulation is necessary rather than virtualisation.[4]
✅ Mark scheme
Virtualisation: runs a guest OS on the same CPU architecture as the host — many instructions run directly on the hardware [1]; Emulation: simulates a completely different hardware architecture in software — every instruction of the guest CPU must be translated to host CPU instructions [1]; Performance overhead: emulation must translate every single guest instruction at runtime; virtualisation can execute most instructions natively, so emulation is typically much slower [1]; Use case: running old console games on modern hardware (e.g. PS2 emulator on a PC) — the guest CPU (MIPS) is different from the host CPU (x86/ARM), so emulation is required; virtualisation only works when host and guest share the same architecture [1].
Topic Quiz
Question 1 of 10
You scored
out of 10
Card 1 of 9
Click to reveal definition
🎉
All cards reviewed!
Term
Definition
🎯
Mini Test — 3.3.2 Virtual Machines
10 questions · 10 marks · 10 minutes
⏱ 10:00
Section A — Multiple Choice [5 marks]
Q1What is a hypervisor?
Q2VirtualBox is an example of which type of hypervisor?
Q3What is Java bytecode?
Q4What does JIT compilation do in the JVM?
Q5Which is a key advantage of the JVM bytecode approach over compiling directly to native machine code?
Section B — Short Answer [5 marks]
Q6State two benefits of using virtual machines in cloud computing.
Mark schemeAny two from: many VMs share one physical server — better resource utilisation [1]; VMs are isolated — a security breach in one customer's VM does not affect others [1]; VMs can be created/destroyed rapidly — easy to scale resources up or down [1]; snapshots allow instant backup and recovery [1].
Q7Explain why emulation is slower than virtualisation.
Mark schemeEmulation simulates a different CPU architecture — every instruction from the emulated CPU must be translated into one or more instructions for the host CPU [1]; this translation adds significant overhead — one emulated instruction may require many host instructions to execute; virtualisation uses the same architecture so guest instructions can often run directly on the host CPU with hardware assistance, requiring little or no translation [1].
Q8Describe what a VM snapshot is and give one use case.
Mark schemeA snapshot saves the complete state of a VM at a specific point in time — the contents of RAM, disk, and CPU state [1]; use case: before testing a software update — take a snapshot, apply the update; if it breaks the system, restore the snapshot instantly rather than reinstalling the OS [1].
Q9Explain how the CLR (.NET) is similar to the JVM.
Mark schemeBoth are virtual machines that execute an intermediate bytecode representation (CLR executes CIL; JVM executes Java bytecode) [1]; both allow "write once, run anywhere" — the same compiled bytecode runs on any platform with the runtime installed; both may use JIT compilation to convert bytecode to native code at runtime for better performance [1].
Q10Give one reason why a company might use a Type 1 hypervisor in a data centre rather than a Type 2 hypervisor.
Mark schemeType 1 hypervisors run directly on hardware without a host OS underneath — there is less overhead/fewer layers between the VMs and the hardware [1]; this gives VMs better performance (lower latency, higher throughput) which is critical in a data centre running many production workloads simultaneously [1]. Accept: no host OS means fewer vulnerabilities; Type 2 depends on a host OS which adds complexity and attack surface.