impera Open Impera

A levels Computer Science · Computer systems

Operating systems

1The role of the operating system

The operating system (OS) is software that manages the computer's hardware and provides a platform for applications.

Its jobs include:

  • memory management: sharing RAM between programs;
  • processor scheduling: sharing CPU time between processes;
  • managing input and output devices, through device drivers;
  • file management: organising files and folders on storage;
  • security: user accounts, passwords and access rights;
  • providing a user interface.

It also hides the complexity of the hardware: programs ask the OS to save a file instead of controlling the disk directly. This makes the computer act like a simpler "virtual machine".

Check yourself

Which job of the OS shares CPU time between programs?

  • Device drivers

  • File management

  • Scheduling

  • Memory management

Show the answer

Scheduling

Who runs next.

2Memory management

Programs need memory, and several must share RAM safely without overwriting each other.

  • Paging splits memory into equal-sized pages (for example 4 KiB). A program's pages can be placed anywhere in RAM; a page table maps them.
  • Segmentation splits a program into logical parts of different sizes, such as the code for one subroutine, or one data structure.
  • Virtual memory uses part of the disk as if it were RAM. Pages not in use are moved (swapped) to disk to make room.

Paging. Program A's pages sit in any free frames of RAM, tracked by a page table; page A3 has been swapped out to disk.

If RAM is very short, the computer spends more time swapping pages than doing work: this is disk thrashing, and the computer becomes very slow.

Check yourself

What is virtual memory?

  • Extra memory built into the CPU chip

  • A very fast type of RAM used for caching

  • Memory used only by the BIOS at start-up

  • Part of secondary storage used as if it were extra RAM

Show the answer

Part of secondary storage used as if it were extra RAM

Disk pretending to be RAM.

3Scheduling

A process moves between states: ready (waiting for the CPU), running (on the CPU) and blocked (waiting for input/output).

Process states. Only one process per core is running; others wait in the ready queue or are blocked waiting for input/output.

AlgorithmHow it worksProblem
first come, first servedruns jobs in arrival order to completionlong jobs hold up short ones
round robineach process gets a fixed time slice, then goes to the back of the queueno priorities
shortest job firstruns the shortest job nextneeds run times in advance; long jobs may wait forever (starvation)
shortest remaining timelike shortest job first, but can interrupt for a shorter new jobstarvation
multilevel feedback queuesseveral queues of different priority; processes move between themcomplex
Worked example

Round robin with a time slice of 2

  1. Jobs A (5 units), B (3 units) and C (1 unit) arrive together.
  2. A runs 0–2, B 2–4, C 4–5 (C finishes at 5).
  3. A runs 5–7, B 7–8 (B finishes at 8).
  4. A runs 8–9 (A finishes at 9).
Check yourself

What is a time slice?

  • The time taken to boot up the computer and load the operating system

  • The total run time of a job from when it starts until it finishes

  • The fixed amount of CPU time a process gets in round robin before the next process runs

  • A part of RAM that is set aside for each process when it starts

Show the answer

The fixed amount of CPU time a process gets in round robin before the next process runs

Quantum.

4Types of operating system

TypeFeatureExample use
single-user multitaskingone user runs many programs at oncea laptop
multi-usermany users share one computer's resources fairlya mainframe or server
distributedone OS spread across several computers that work as onelarge scientific computing
embeddedsmall and built for one device, with limited resourcesa washing machine
real-timemust respond within a guaranteed timeaircraft controls, car airbags
Check yourself

Which type of OS is needed for a car's airbag system?

  • Real-time

  • Single-user desktop

  • Distributed

  • Multi-user

Show the answer

Real-time

Guaranteed response.

5BIOS and device drivers

The BIOS (or modern UEFI) is firmware stored in non-volatile memory on the motherboard. When the computer is switched on, it:

  1. runs the power-on self-test (POST) to check the hardware;
  2. finds the bootloader on the storage device;
  3. loads the operating system into RAM.

A device driver is software that lets the OS talk to a particular piece of hardware, such as a printer. It translates general OS commands into the specific instructions the device understands, so the OS does not need to know every device in detail.

Check yourself

Why is the BIOS stored in non-volatile memory?

  • It is a user application that must survive when the power is turned off

  • It changes every time the computer runs, so it must be saved after each session

  • It must be available when the computer is first switched on, before anything is loaded

  • It is too large to fit in RAM, so it must be stored somewhere else

Show the answer

It must be available when the computer is first switched on, before anything is loaded

Not lost when off.

6Virtual machines and utility software

A virtual machine is software that imitates a computer. Uses:

  • running a different operating system inside the current one (for example to test software);
  • running intermediate code such as Java bytecode on any platform;
  • separating servers safely on one physical machine.

Virtual machines are slower than running directly on the hardware.

Utility software helps maintain the computer:

  • antivirus software scans for and removes malware;
  • defragmentation rearranges file pieces on a hard disk so they are next to each other;
  • backup software copies files, either full or incremental (only what has changed);
  • compression software makes files smaller.
Check yourself

What does disk defragmentation do?

  • Adds more memory by using part of the disk as virtual RAM

  • Deletes unused files to free up space on the disk for new files

  • Encrypts the disk so that its files cannot be read by others

  • Rearranges parts of files so they are stored together, speeding up access on a hard disk

Show the answer

Rearranges parts of files so they are stored together, speeding up access on a hard disk

Tidies the pieces.

Now test yourself

This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.

Practise in Impera