Teachers' Portal  /  A-Level Computer Science 9618  /  Hardware and virtual machines  /  Virtual machines
Lesson pack · A-Level Computer Science 9618 · 15.1 · A Level (A2)

Virtual machines

A computer made of software. A virtual machine is software that behaves like a complete computer, so one physical machine can run several operating systems at once.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Hardware and virtual machines
Syllabus reference
Cambridge International AS and A Level Computer Science 9618, 15.1
Level
A Level (A2)
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 3 of 6 in Hardware and virtual machines; follows Parallel processing architectures; leads into Boolean algebra
Central model
Fig. 1: the virtual machine software sits between the guests and the host, giving each guest operating system its own emulated hardware
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • The concept of a virtual machine: A guest operating system cannot tell the difference between real hardware and the emulated hardware that the virtual machine software gives it.
  • The roles of virtual machines: Questions often ask you to give examples of what virtual machines are used for.
  • Benefits and limitations: For a full answer, give a benefit or limitation and then explain it: what it means for the user or the organisation.
Key points to leave on the board
  • Concept: software that emulates the hardware of a computer; guest OS runs on the host.
  • Roles: give concrete examples: several OSs, legacy software, testing, malware analysis, server consolidation.
  • Benefits: isolation, less hardware, easy backup and snapshots.
  • Limitations: slower because of the overhead, needs a powerful host, some hardware cannot be emulated.
The core visual model

One picture every idea returns to

A virtual machine (VM) is an emulation of a computer system in software. The virtual machine software (a hypervisor) runs on the real hardware, usually on top of a host operating system, and presents emulated hardware to one or more guest operating systems, each of which behaves as if it had a whole computer to itself. Guest instructions are passed to, or translated for, the real hardware by the virtual machine software. VMs are used to run several operating systems on one computer, to run legacy software, to test software safely and to share servers between many customers. The main benefits are isolation (a crash or a virus in one guest does not affect the host or the others) and saving hardware; the main limitations are reduced performance and the need for a powerful host with plenty of memory.

two guest operating systems running on one physical computer guest applicationslegacy application guest OS 1 (e.g. Linux)guest OS 2 (older OS) virtual machine software (hypervisor) host operating system physical hardware: CPU, RAM, disk, network each dashedbox is onevirtualmachine emulates thehardware foreach guest each guest OS behaves as if it had a whole computer to itself
Fig. 1: the virtual machine software sits between the guests and the host, giving each guest operating system its own emulated hardware
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, A computer made of software.. A virtual machine is software that behaves like a complete computer, so one physical machine can run several operating systems at once. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: The concept of a virtual machineA guest operating system cannot tell the difference between real hardware and the emulated hardware that the virtual machine software gives it.Whole class, then pairs
13 to 21 minTeach and check: The roles of virtual machinesQuestions often ask you to give examples of what virtual machines are used for. Model the worked example Explaining a role in context on the board, one line at a time.Pairs
21 to 30 minTeach and check: Benefits and limitationsFor a full answer, give a benefit or limitation and then explain it: what it means for the user or the organisation. Your turn: A software developer tests every new version of her app in a virtual machine. Give one benefit and one limitation of doing this.Connect-Extend-Challenge
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 17 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in Benefits and limitations, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Connect-Extend-Challenge

After the new idea, each student writes three lines: how it connects to what they knew, how it extends their thinking, and what still challenges them. Pairs compare, then the challenges become the plenary.

The full structure, with its variations and the other twelve, is on the cooperative-learning page.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
A virtual machine is not extra hardware and it is not the same as virtual memory.It is software that emulates a whole computer.
"It is slower" earns little on its own.Say why: the virtual machine software has to intercept and translate the guest's instructions, which adds an overhead.
Worksheet

Virtual machines: worksheet

6 questions, 17 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · recall[2 marks]

Explain the term virtual machine.

Q2 · explain[3 marks]

Give three examples of the role of virtual machines.

Q3 · explain[4 marks]

Describe two benefits and two limitations of using virtual machines.

Q4 · apply[3 marks]

A university computer science department wants students to practise installing and configuring operating systems on the lab computers. Explain why it should use virtual machines.

Q5 · explain[2 marks]

Explain why software runs more slowly on a virtual machine than directly on the host hardware.

Q6 · analysis[3 marks]

A games company is choosing between running its new graphics-intensive game in a virtual machine for testing, or on dedicated physical test computers. Discuss which is more suitable.

Answer key and marking notes
Q1 · 2 marks
  • Software that emulates (the hardware of) a computer system.
  • It allows a guest operating system to run on a host computer as if it were running on its own hardware.
Q2 · 3 marks
  • Running more than one operating system on the same computer at the same time.
  • Running legacy software that needs an old operating system.
  • Any one of: testing software on different platforms without risk; running suspected malware in isolation; running many virtual servers on one physical server; running bytecode on a process VM such as the JVM.
Q3 · 4 marks
  • Benefit: the guest is isolated, so if it crashes or is infected the host and other guests are not affected.
  • Benefit: fewer physical computers are needed, saving cost, space and energy (or: easy to back up, copy or restore from a snapshot).
  • Limitation: performance is lower than on real hardware because of the overhead of emulation.
  • Limitation: the host needs plenty of memory and processing power (or: some hardware cannot be emulated; complex to manage).
Q4 · 3 marks
  • Each student can install a guest OS in a VM without changing the host operating system of the lab computer.
  • Mistakes only affect the guest, which can be deleted or reset from a snapshot, so the lab computers keep working.
  • Several different operating systems can be practised on the same computer, without buying extra hardware.
Q5 · 2 marks
  • The guest's instructions that use the hardware must be intercepted by the virtual machine software.
  • They are translated or emulated before being executed on the real hardware, which takes extra processing time (overhead), and the host's resources are shared with other guests.
Q6 · 3 marks
  • Virtual machines would make it easy to test on several operating systems and to reset after crashes, and would save hardware.
  • But the game is graphics-intensive: the emulation overhead and limited access to the real graphics hardware would make performance much lower, and some graphics features may not work.
  • Dedicated physical computers are more suitable for accurate performance testing; VMs could still be used for functional tests.
Quiz

6 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

In a computer running virtual machines, what is the host?

  • AThe physical computer and the operating system installed directly on it
  • BAn operating system running inside one of the virtual machines
  • CThe emulated hardware that the virtual machine software gives each guest
  • DA remote server from which the guest operating systems are downloaded
Q21 mark

A security researcher runs a newly found virus inside a virtual machine to see what it does. Which benefit of virtual machines is she relying on?

  • AIsolation: what happens in the guest cannot affect the host or other guests
  • BPerformance: programs run faster in a guest than on the real hardware
  • CSaving memory: a guest needs none of the host's RAM to run
  • DDirect access: the guest can control the host's hardware without any checks
Q31 mark

Why does software usually run more slowly in a virtual machine than directly on the host hardware?

  • AGuest instructions must be intercepted and translated by the VM software, adding overhead
  • BThe guest operating system has to be downloaded again each time a program in it is started
  • CVirtual machines can only use one bit of the processor's registers for each instruction
  • DThe host's processor runs at a lower clock speed whenever a virtual machine is switched on
Q41 mark

A company's accounts program only runs on an operating system that is no longer supported, and the old computer it runs on is failing. How can a virtual machine help?

  • AInstall the old operating system as a guest on a new computer and run the program in it
  • BInstall the program as a guest operating system so it no longer needs any operating system
  • CUse the virtual machine to repair the old computer's failing hardware automatically
  • DConvert the program into Java bytecode by running it once in a virtual machine
Q51 mark

A hosting company moves 30 separate physical servers onto 3 powerful physical hosts, each running 10 virtual servers. Which is a risk the company has introduced?

  • AIf one physical host fails, all 10 virtual servers on it stop at the same time
  • BEach virtual server can now read the files stored in every other virtual server
  • CThe virtual servers can no longer be backed up, because they exist only as software
  • DEach virtual server now needs its own separate physical network card and disk
Q61 mark

A program written in Java is compiled to bytecode on a Windows computer. The same bytecode file then runs unchanged on a Linux computer. Why?

  • AThe Linux computer has a Java Virtual Machine that executes the bytecode
  • BBytecode is machine code that every type of processor can execute directly
  • CThe Linux computer automatically runs Windows as a guest operating system for it
  • DThe compiler produced a separate machine-code version inside the file for every operating system
Quiz key
Q1: A

The host is the real computer and its own operating system, on which the virtual machine software runs. An operating system inside a virtual machine is a guest. The emulated hardware is what the virtual machine software presents to each guest, and nothing about virtual machines requires a remote server.

Q2: A

The guest is isolated from the host, so the virus can damage only the guest, which can then be deleted or reset from a snapshot. Guests run more slowly than real hardware, not faster; each guest needs its own share of RAM; and the point is that the guest does not get unchecked access to the host's hardware.

Q3: A

Instructions from the guest that use the hardware pass through the virtual machine software, which intercepts, translates or emulates them, and that extra work slows the guest down. Guests are not downloaded each time, the registers are used normally, and the clock speed does not drop because a VM is running.

Q4: A

Running legacy software is a classic role: the old operating system runs as a guest on modern hardware, and the program runs inside it as before. A program is not an operating system; virtual machine software cannot repair physical hardware; and running a program in a VM does not convert it into bytecode.

Q5: A

All the guests on a host depend on that one physical machine, so a hardware failure stops every one of them. Guests are isolated from each other, so they cannot read each other's files. A whole VM is a file, which actually makes backup and snapshots easier, and the virtual machine software emulates network cards and disks so separate hardware is not needed for each guest.

Q6: A

The JVM is a process virtual machine: it executes Java bytecode, so any computer with a JVM can run the same compiled file. Bytecode is not native machine code for any real processor; Linux does not secretly run Windows; and the compiler produces one bytecode file, not a version for every platform.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonParallel processing architectures