Skip to content
BIASED

Virtual machines and containers

Block 1 of 4~3 min

Why virtualize

The permissions topic ended with a hard limit: different UIDs still share one kernel, one file tree, one process list and one network — and root or a kernel bug crosses every boundary at once. Stronger walls come in two shapes. A virtual machine gives a program a whole computer of its own, kernel included. A container keeps one kernel but gives each group of processes its own view and resource limits.

A VM is a software copy of a computer: virtual CPUs, memory, disks and NICs. Reasons are practical — consolidation of lightly loaded servers, isolation of crashes and compromises, running another OS on the same hardware, and encapsulation (snapshots, copies, live migration). Cloud computing is built on that last property.

The simplest implementation is an emulator: guest registers and memory in arrays, every guest instruction fetched, decoded and carried out in software. Privileged instructions are easy — the emulator updates its own control state — and a guest can even use a different ISA (RISC-V on an x86 laptop). Speed is the problem: one guest add costs dozens of host instructions. Nearly all guest instructions are ordinary arithmetic, loads, stores and branches the host CPU could run itself. The question is when that is safe.

Answers are saved on the server and tied to this browser until you sign in.