Cambridge AS & A Level9608

Hardware and virtual machines

Computer Science 9608 Chapter Notes

What this chapter covers

Hardware and virtual machines
ShareWhatsAppPost
Hardware and virtual machines notes

Unable to load PDF

The notes viewer could not load. Please refresh the page.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Hardware and virtual machines notes as text: skim, search, and jump between subtopics.

~11 min read

1. The Operating System as a Resource Manager

The Operating System (OS) is the most important piece of software on a computer. Its main job is to act as an intermediary between the user's applications and the physical hardware. Think of it as a manager for the computer's resources. It manages the Central Processing Unit (CPU), memory (RAM), storage devices (hard drives, SSDs), and input/output (I/O) devices like keyboards and printers. By managing these resources, the OS ensures that multiple programs can run fairly and efficiently without interfering with each other. It also provides a user interface (like Windows or macOS) that hides the immense complexity of the underlying hardware, allowing us to use the computer without needing to know how the circuits work.

Key term

Operating System (OS): System software that manages all computer hardware and software resources and provides common services for computer programs.

Examiner insight

Examiners reward answers that clearly link a specific OS function (e.g., scheduling) to the overall goal of maximising resource utilisation or providing a stable platform for users.

Worked example 14 marks

Describe two ways in which an operating system manages a computer's hardware resources.

  1. 1
    1. Processor Management: The OS manages how the CPU's time is shared between all the running programs (processes). It uses a scheduler to decide which process gets to run and for how long, creating the illusion of multitasking.
  2. 2
    1. Memory Management: The OS allocates portions of the main memory (RAM) to programs that need it. It ensures that one program cannot access or overwrite the memory space of another, which prevents crashes and maintains system stability.

Recap

  • The Operating System acts as a bridge between applications and hardware.
  • It is responsible for managing resources like the CPU, memory, and I/O devices.
  • A key function is providing a user interface to simplify interaction with the computer.
  • The OS ensures fair and efficient resource allocation among multiple running programs.
  • Device drivers are managed by the OS to allow communication with specific hardware.
  • File management, security, and error handling are also core responsibilities of the OS.

Quick check

  1. Name two resources managed by an operating system.2 marks
  2. What is the purpose of a device driver?1 mark

2. Processor Management and Scheduling

When you run a program, the OS loads it into memory and it becomes a 'process'. A process is a program in execution. Modern operating systems are capable of 'multitasking', which means they can handle many processes at once (e.g., a web browser, a music player, and a word processor). Since there is usually only one CPU, this is an illusion created by the OS. The OS's 'scheduler' rapidly switches the CPU's attention between different processes, giving each a small slice of time. This happens so fast that it appears they are all running simultaneously. An 'interrupt' is a signal to the processor, often from a hardware device, that requires immediate attention, causing the OS to pause the current process and handle the interrupt.

Key term

Process: A program that has been loaded into memory from storage and is currently being executed by the processor.

Examiner insight

Marks are often awarded for explaining *why* scheduling is necessary in a multitasking environment—to share the CPU fairly and efficiently—not just stating that it happens.

Common pitfall

Confusing a 'program', which is a static set of instructions stored on a disk, with a 'process', which is a dynamic instance of a program being actively run by the computer.

Worked example 16 marks

In a multitasking operating system, a process can be in one of several states. Identify three process states and explain what each one means.

  1. 1
    1. Ready: The process has been loaded into main memory and is waiting for its turn to be executed by the CPU. It has everything it needs to run but is waiting for the scheduler to allocate CPU time.
  2. 2
    1. Running: The process is currently being executed by the CPU. Its instructions are being processed.
  3. 3
    1. Waiting (or Blocked): The process is paused because it is waiting for some event to occur, such as the completion of an I/O operation (e.g., reading from a file) or waiting for user input.

Recap

  • A process is a program that is currently executing.
  • Multitasking is the ability of an OS to run multiple processes concurrently.
  • The scheduler is the part of the OS that decides which process to run next.
  • An interrupt is a signal that pauses the current process to handle an urgent event.
  • Processes transition between states such as New, Ready, Running, Waiting, and Terminated.
  • Scheduling algorithms aim to maximise CPU utilisation and minimise response time.

Quick check

  1. What is the difference between a program and a process?2 marks
  2. What is the main purpose of a scheduling algorithm?1 mark

3. Memory Management: Paging and Virtual Memory

Memory management is how the OS controls the use of RAM. One common technique is 'paging'. The OS divides physical RAM into fixed-size blocks called 'frames', and it divides a program's logical address space into matching fixed-size blocks called 'pages'. When a program runs, its pages are loaded into available frames in RAM. This allows a program's memory to be non-contiguous, making memory allocation more flexible. 'Virtual memory' is an extension of paging. It allows the OS to use a portion of the hard disk as if it were extra RAM. If a required page is not in RAM (a 'page fault'), the OS swaps it in from the hard disk, potentially swapping out an unused page from RAM to make space. This lets you run programs that are larger than the available physical RAM. However, excessive swapping, known as 'disk thrashing', can severely slow down the system because hard disks are much slower than RAM.

Key term

Virtual Memory: A memory management technique that uses secondary storage to extend the apparent size of physical memory, creating the illusion of a very large main memory.

Examiner insight

High-scoring answers clearly explain the process of a page fault and how the OS handles it, including the role of swapping pages between main and secondary memory.

Common pitfall

Stating that virtual memory is 'extra RAM'. It is a technique using much slower secondary storage (like a hard drive) to *simulate* extra RAM, not a physical extension of it.

Worked example 16 marks

a) Explain two advantages of using virtual memory. [4]b) Explain one problem that can occur in a virtual memory system. [2]

  1. 1

    a) Advantage 1: It allows you to run programs that are larger than the physical RAM available. The OS loads only the necessary parts of the program into RAM, keeping the rest on the hard disk.

  2. 2

    a) Advantage 2: It allows for more efficient multitasking. More programs can be held in memory (even if only partially), which means the CPU is less likely to be idle while waiting for programs to be loaded, increasing throughput.

  3. 3

    b) Problem: Disk thrashing. This occurs when the system spends too much time swapping pages between RAM and the hard disk and not enough time doing actual processing. It happens when there isn't enough physical RAM to hold the active pages for all running processes, leading to constant page faults and a severe drop in performance.

Recap

  • Paging divides memory into fixed-size blocks to manage allocation.
  • Virtual memory uses secondary storage to simulate more RAM than is physically present.
  • A 'page fault' occurs when the CPU needs a page that is not currently in RAM.
  • The OS handles a page fault by loading the required page from the hard disk into RAM.
  • 'Disk thrashing' is a performance problem caused by excessive page swapping.
  • Virtual memory allows larger programs and more concurrent processes to run.

Quick check

  1. What is a page fault?1 mark
  2. Which is faster, accessing data in RAM or accessing data in virtual memory on a hard disk?1 mark

4. Understanding Virtual Machines

A Virtual Machine (VM) is an emulation of a complete computer system within another computer. It's essentially a 'computer inside a computer'. A VM runs as a process on a physical 'host' machine, but to the software running inside the VM, it looks like its own dedicated piece of hardware with its own 'guest' operating system. This is made possible by a piece of software called a 'hypervisor' or Virtual Machine Monitor (VMM). The hypervisor sits between the host hardware and the VM, creating the virtual environment and managing the allocation of the host's physical resources—such as CPU time, RAM, and storage—to the various VMs running on it.

Key term

Hypervisor: Software, firmware, or hardware that creates, runs, and manages virtual machines.

Common pitfall

Confusing a virtual machine with virtual memory. They are completely different concepts; a VM emulates an entire computer, while virtual memory is a technique to extend a computer's RAM using a disk.

Fun fact

The concept of virtual machines is not new! It was first developed by IBM in the 1960s to allow their expensive mainframe computers to be shared by multiple users running different operating systems simultaneously.

Worked example 14 marks

a) Define the term 'virtual machine'. [2]b) Explain the role of the hypervisor in a virtual machine implementation. [2]

  1. 1

    a) A virtual machine is a software-based emulation of a physical computer system. It runs on a host computer but provides the functionality of a separate, independent computer with its own guest operating system.

  2. 2

    b) The hypervisor is the software layer that creates and manages the virtual machine(s). It allocates and manages the host machine's physical resources (CPU, memory, storage) and provides them to the guest operating systems running in the VMs.

Recap

  • A virtual machine (VM) is a software emulation of a physical computer.
  • The physical machine is called the 'host' and the OS inside the VM is the 'guest' OS.
  • A hypervisor is the software that creates and manages VMs.
  • The hypervisor allocates physical host resources to the guest VMs.
  • Each VM is isolated from the host and other VMs, running in its own 'sandbox'.
  • Do not confuse a virtual machine with virtual memory.

Quick check

  1. What is the term for the physical computer that a virtual machine runs on?1 mark
  2. What is the name of the software used to create and manage VMs?1 mark

5. Benefits and Limitations of Virtual Machines

Virtual machines are incredibly useful for several reasons. A key benefit is 'server consolidation': a company can replace many under-utilised physical servers with a single, more powerful server running multiple VMs, saving on hardware costs, power, and cooling. They are also perfect for software development and testing, providing an isolated 'sandbox' environment where new code can be tested without risking the stability of the host system. You can easily run legacy applications on a modern computer by creating a VM with an older operating system. However, VMs have limitations. The main one is 'performance overhead'; because the hypervisor adds an extra layer of software, a VM will always be slightly slower than running on the native hardware. They also consume significant host resources, as each VM needs its own dedicated slice of RAM and CPU, and managing a large number of VMs can become complex.

Key term

Server Consolidation: The practice of reducing the number of physical servers in a data center by running multiple virtual servers on a smaller number of more powerful machines.

Examiner insight

Examiners look for balanced answers that discuss both benefits and limitations, using specific, technical examples like 'server consolidation' or 'performance overhead' to support points.

Worked example 13 marks

An organisation is considering using virtual machines. State two benefits and one limitation of this approach.

  1. 1

    Benefit 1: Running multiple operating systems. A single physical machine can host several VMs, each running a different OS (e.g., Windows, Linux, macOS). This is useful for development, testing, or accessing OS-specific software.

  2. 2

    Benefit 2: Hardware cost reduction (Server Consolidation). Multiple virtual servers can run on one physical server, reducing the need to buy and maintain many separate machines. This also saves on power and cooling costs.

  3. 3

    Limitation 1: Performance overhead. A virtual machine will not offer the same level of performance as a native system because of the extra processing required by the hypervisor to manage resources and translate instructions. This makes VMs less suitable for performance-critical applications.

Recap

  • Benefit: VMs allow multiple, different operating systems to run on a single physical machine.
  • Benefit: Server consolidation reduces hardware, power, and space requirements.
  • Benefit: VMs provide isolated sandbox environments for safe software testing.
  • Benefit: They enable legacy software to run on modern hardware.
  • Limitation: Performance is lower than a native system due to hypervisor overhead.
  • Limitation: VMs consume host resources and can be complex to manage.

Quick check

  1. State one reason a software developer might use a virtual machine.1 mark
  2. Why is a virtual machine typically slower than a physical machine with the same specifications?1 mark

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. Explain the difference between a process and a program, and describe the role of the operating system's scheduler in managing processes.4 marks
  2. A company wants to continue using essential accounting software that only runs on an old version of Windows, but their new computers all run the latest version. Explain how a virtual machine could solve this problem.3 marks
  3. Describe the process that occurs during a 'page fault' in a system that uses virtual memory.4 marks
  4. Identify three distinct functions of an operating system, excluding the user interface.3 marks
  5. Compare and contrast virtual machines and virtual memory. You must refer to the purpose and implementation of each.6 marks
  6. Explain the term 'disk thrashing' and describe a situation that might cause it to occur.3 marks
  7. A large data centre uses virtualisation for server consolidation. Explain what server consolidation is and give two reasons why it is beneficial for the data centre.5 marks
  8. Explain what an interrupt is and give two examples of events that could cause an interrupt.4 marks
  9. Describe two limitations of using virtual machines compared to running an operating system directly on physical hardware.4 marks
  10. A process can exist in 'Running', 'Ready' or 'Waiting' states. Explain how a process might transition from the 'Running' state to the 'Waiting' state, and from the 'Running' state to the 'Ready' state.4 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters