Computer ScienceFoundation20 min read

Operating Systems: Structure and Services

The program that makes every other program possible

This topic appears in:

01

Why an operating system exists at all

Definition

Kernel — The core of the operating system, always resident in memory, which manages the CPU, memory and devices. Other parts of the OS — the interface, the utilities — can be replaced or restarted; the kernel cannot.

Without one, every program would have to contain its own code for reading a disk, driving a screen and talking to a network card — and any two programs running together would overwrite each other's memory. The operating system exists to solve both problems: it provides shared services so programs need not reinvent them, and it enforces separation so they cannot interfere.

It is loaded before anything else. Firmware on the motherboard starts, checks the hardware, finds the disk holding the OS, loads the kernel into memory and hands over control — a sequence called booting. From that moment the OS is in charge, and every other program runs by its permission.

Select Firmware, then Operating system, then Application. That is the boot order, and it is also the order of a request travelling back down when an application wants to save a file.

02

The five services it provides

The syllabus names five, and each exists because programs would otherwise conflict over a shared resource.

ServiceThe problem it solves
Process managementmany programs, one CPU — who runs next, and for how long
Memory managementmany programs, one RAM — who gets which region, and keeping them apart
File managementorganising storage into files and folders, and controlling access
Device managementtalking to thousands of device models through drivers
Security and usersaccounts, passwords and permissions, so one user cannot read another's files

Multitasking on a single core

A single-core CPU executes one instruction at a time, yet twenty programs appear to run at once. The OS gives each a few milliseconds in turn and switches between them faster than a human can notice — time-slicing. Saving one program's state and restoring another's is a context switch. A multi-core processor genuinely runs several at once, but the illusion on one core is achieved entirely by switching.

03

Memory management, and why a short-of-memory machine crawls

Each program is given the illusion of a large private address space. The OS maps those virtual addresses onto whatever physical RAM happens to be free, which is what lets a program be written without knowing where in memory it will end up, and what stops one program from reading another's data.

When RAM fills, the OS writes the least recently used pages out to disk and reads them back when needed — paging, or swapping. Disk is thousands of times slower than RAM, so a machine that has started paging heavily becomes dramatically slow while the CPU sits idle waiting. That is the specific reason adding RAM often helps more than a faster processor.

Worked example

A user complains that their computer is fine in the morning but crawls by the afternoon, with the disk light constantly on. Explain what is happening.

  1. The constant disk activity with a slow machine is the signature of paging.If the CPU were the bottleneck the processor would be at 100%, not the disk.
  2. Through the day more applications and browser tabs are opened, and each occupies RAM.Programs closed by the user free their memory; ones merely minimised do not.
  3. Once RAM is full the OS begins moving pages to disk to make room.It has no alternative — the alternative is refusing to run anything new.
  4. Every switch between programs now requires a disk read, which takes thousands of times longer than a memory access.Hence the disk light and the sluggishness together.
  5. The fixes: close unused programs, reduce startup programs, or add RAM.A faster disk shortens the delay; more RAM removes it.

RAM has filled and the OS is paging to disk — visible as constant disk activity with a slow machine.

04

Files, permissions and users

The file system organises storage into a hierarchy of folders, records where each file physically sits, and stores its metadata — name, size, type, dates, and who may do what with it.

Permissions are the security half. A typical scheme grants read, write and execute rights separately, to the owner, to a group, and to everyone else. That is what allows a school to give students read access to shared resources while preventing them from altering them, and it is why an administrator account should not be used for everyday work: any malware that runs inherits the permissions of the account that started it.

Deleting a file usually does not erase it

Deleting normally removes the file's entry from the index and marks its space as reusable. The data itself stays on the disk until something happens to overwrite it, which is why recovery software can retrieve deleted files — and why a disk being given away or sold must be securely wiped, not merely emptied of its recycle bin.

05

Types of operating system

Different jobs need different scheduling behaviour, and the syllabus lists the categories.

A single-user single-tasking system runs one program for one person — simple embedded devices. Single-user multi-tasking is what a laptop runs. A multi-user system serves several people at once on shared hardware, as a server does. A real-time system guarantees a response within a fixed time, which matters when the computer is controlling a car's brakes or a patient monitor — being right too late is the same as being wrong. And a distributed system spreads one job across many machines that appear as one.

Before you leave this chapter

  1. The OS provides shared services and enforces separation between programs.
  2. The kernel is the always-resident core; booting loads it before anything else runs.
  3. Five services: processes, memory, files, devices, and security.
  4. Multitasking on one core is time-slicing, not simultaneous execution.
  5. Heavy paging — a slow machine with a busy disk — means RAM is full.

Practice questions

6 questions · 20 marks · full working on every one

Try each one on paper first, then open the working. The marks are shown where they are actually awarded, because that is where they are actually lost.

Short questions

3 · 6 marks

Two marks each, in the style of the short-question section of the paper. Answer in two or three lines.

SQ1[2 marks]
What is the kernel of an operating system?
Model answer

The core of the OS, permanently resident in memory, which manages the CPU, memory and devices and controls access to them. Other parts of the OS such as the user interface can be restarted or replaced; the kernel cannot.

Examiner tip. The words "core" and "resident in memory" both earn credit. Adding what distinguishes it from the rest of the OS secures the second mark.

SQ2[2 marks]
Explain how a single-core processor appears to run several programs at once.
Model answer

Through time-slicing: the operating system gives each program a few milliseconds of CPU time in turn and switches between them far faster than a person can perceive. Only one instruction is ever executing, so the simultaneity is an illusion.

Examiner tip. Say explicitly that only one runs at a time. Answering "it uses multiple cores" contradicts the question, which specified a single core.

SQ3[2 marks]
Why should everyday work not be done from an administrator account?
Model answer

Any program that runs inherits the permissions of the account that started it. Malware launched from an administrator account can therefore alter system files and install itself permanently, whereas the same malware run from a standard account is confined to that user's own files.

Examiner tip. The principle of least privilege is what is being tested. Tie the answer to what malware could then do, rather than saying it is "safer".

Solved numericals

2 · 8 marks

Full working, one step per line, with the marks shown where they are awarded.

N1[4 marks]
Describe four services provided by an operating system.
Full working
  1. Process management — scheduling which program uses the CPU and for how long[1]
  2. Memory management — allocating RAM to each program and keeping them separate[1]
  3. File management — organising storage into files and folders and controlling access to them[1]
  4. Device management — communicating with hardware through drivers; also accept security and user accounts[1]

Process, memory, file and device management — plus security and the user interface.

Examiner tip. Name the service and say what it does. A list of four bare terms usually scores two of the four marks.

N2[4 marks]
A computer with 4 GB of RAM becomes extremely slow when many applications are open, and the disk activity light stays on. Explain the cause and suggest two solutions.
Full working
  1. RAM has filled, so the OS is moving pages of memory out to disk — paging or swappingthe constant disk light is the clue[1]
  2. Disk access is thousands of times slower than RAM, so every switch between programs now waits on the diskthe speed gap is the explanation[1]
  3. Solution: close unused applications and reduce the number of programs starting automatically[1]
  4. Solution: install more RAM, which removes the need to page rather than merely making paging fasteran SSD helps but does not fix the cause[1]

RAM is full and the OS is paging to disk. Close programs, or add RAM.

Examiner tip. Distinguish removing the cause from reducing the symptom. More RAM stops the paging; a faster disk only shortens each delay.

Long questions

1 · 6 marks

Theory and numerical together, as they appear in the long-question section.

LQ1[6 marks]
A hospital uses computers for two very different jobs: office machines for administration, and a monitor attached to a patient that must raise an alarm within a guaranteed time.
  1. State the type of operating system suited to each, with a reason.
  2. Explain what "real-time" guarantees and why it matters here.
  3. Explain one way file permissions protect patient records on the office machines.
Mark scheme
  1. Office machines: a single-user multi-tasking operating system, since one person at a time runs several applications togetheraccept multi-user for shared machines[1]
  2. Patient monitor: a real-time operating system[1]
  3. Real-time guarantees that a response occurs within a fixed maximum time, not merely quickly on averagethe guarantee is the distinguishing feature[1]
  4. For a patient monitor an alarm raised late is as dangerous as no alarm, so a predictable worst case matters more than average speed[1]
  5. File permissions grant read, write and execute rights separately to the owner, a group and others[1]
  6. So clinical staff can be given read access to records while administrative staff cannot open them at all, and only authorised users may alter themthe example must fit the hospital[1]

(a) multi-tasking for the office, real-time for the monitor (b) a guaranteed maximum response time (c) separate read and write rights per group

Examiner tip. The point about real-time is the guarantee, not the speed. A general-purpose OS is usually faster on average but occasionally pauses — and "occasionally" is unacceptable for a patient monitor.