Explain why a computer system requires an Operating System (OS)

5.1 Operating Systems – Why a Computer System Requires an OS

Learning objective

Explain why a computer system needs an Operating System (OS) and describe the main services it provides, in line with the Cambridge IGCSE/A‑Level syllabus.

1. Purpose of an Operating System

An OS is the essential software layer that sits between the hardware and the user programmes. It makes a computer:

  • Usable – supplies a command‑line or graphical interface.
  • Reliable – protects programmes from each other and from hardware faults.
  • Efficient – shares resources so that the CPU, memory and I/O devices are kept busy.
  • Portable – programmes can be written once and run on many machines that provide the same OS services.

2. Core Management Tasks (the five OS functions)

TaskWhat the OS doesTypical example (exam‑style)
Process managementCreates, schedules, synchronises and terminates processes; maintains process states (new, ready, running, blocked, terminated).Round‑robin scheduler gives each of three programmes a 10 ms time‑slice.
Memory managementAllocates and de‑allocates main‑memory blocks; provides virtual memory, paging and protection between processes.A programme requests 8 KB more RAM; the OS swaps a seldom‑used page to disk to satisfy the request.
File‑system managementCreates, deletes and renames files and directories; maintains a hierarchical directory tree; stores file attributes (size, timestamps, permissions); controls access with read/write/execute rights.When a user types rm report.doc, the OS removes the directory entry and frees the occupied blocks.
Device (hardware) managementProvides a uniform interface to peripherals via device drivers; buffers I/O, handles interrupts, and performs error recovery.A printer driver converts a generic “print” request into the specific command sequence required by the HP LaserJet.
Security & protectionAuthenticates users, enforces access‑control lists, isolates processes, and prevents unauthorised hardware access.A non‑admin user cannot delete C:\Windows\system32 because the OS denies the operation.

3. Utility Software that Usually Comes with an OS

These tools are not part of the kernel but are bundled to help users and administrators manage the system.

  • Disk formatter – prepares a storage device with a file system.
  • Defragmenter – rearranges fragmented files to improve access speed.
  • Backup & restore – copies data to a safe location and recovers it if needed.
  • Virus/anti‑malware scanner – detects and removes malicious code.
  • Compression utilities (e.g., zip, gzip) – reduce file size for storage or transmission.
  • System monitor – displays CPU, memory and disk utilisation.

Exam‑style question: “A user’s hard‑disk has become unreadable after a power failure. Which bundled utility would you use to try to recover the lost data?” – Answer: the backup & restore tool (or a disk‑repair utility such as chkdsk).

4. Program Libraries

Libraries contain reusable code that applications can call without re‑implementing common functions.

  • Static library – linked into the programme at compile time; the code becomes part of the executable.
  • Dynamic library (DLL / shared object) – loaded at run‑time; the same code can be shared by many programmes, saving memory.

Typical examples:

  • Standard C library – printf(), sqrt(), file I/O.
  • Graphics library – drawing primitives, window handling.
  • OS‑specific API – system‑call wrappers that translate a programme’s request into kernel actions.

Code‑snippet illustration (pseudo‑code):

// programme.c – uses the standard C library (dynamic linking)

#include <stdio.h>

int main(void) {

double r = 5.0;

double area = MPI * r * r; // MPI comes from the math library

printf("Area = %.2f\n", area);

return 0;

}

The call to printf is resolved at run‑time by the C run‑time library; the programme itself does not contain the implementation of printf.

5. Types / Architectures of Operating Systems

  • Batch OS – Executes jobs sequentially without interactive user input (early mainframes).
  • Time‑sharing / Multi‑user OS – Allows many users to run programmes simultaneously (e.g., UNIX, Linux, Windows Server).
  • Real‑time OS (RTOS) – Guarantees that critical tasks complete within strict time limits (e.g., aerospace control, industrial PLCs).
  • Embedded OS – Small‑footprint, often single‑tasking, designed for dedicated devices (e.g., Android on smartphones, VxWorks).

6. How the OS Provides Its Services

  1. Bootstrapping – Firmware loads the kernel from non‑volatile storage into RAM and transfers control.
  2. Kernel – Core component running in privileged mode; handles interrupts, scheduling, memory management and device control.
  3. System calls – Well‑defined API that user programmes invoke to request OS services (e.g., open(), fork(), read()).
  4. Interrupt handling – Responds to asynchronous hardware signals, allowing I/O without busy‑waiting.

7. Process Scheduling & States

A process moves through a set of states while the OS schedules it:

  • New – Process is being created.
  • Ready – Waiting in the ready queue for CPU time.
  • Running – Currently executing on the CPU.
  • Blocked (Waiting) – Suspended because it awaits I/O or an event.
  • Terminated – Finished execution; resources are reclaimed.

Common scheduling algorithms (briefly):

  • Round‑robin – equal time‑slices, pre‑emptive.
  • Priority‑based – higher‑priority processes run first; ageing can prevent starvation.
  • Shortest‑job‑first – selects the process with the smallest expected CPU burst.

8. Comparison – With vs. Without an OS

AspectWith an OSWithout an OS
Program developmentStandard libraries, system calls, portable source code.Direct hardware programming; code tied to a specific machine.
Resource sharingPre‑emptive scheduling, virtual memory, file locks.Manual time‑slicing; high risk of conflicts and memory overlap.
SecurityUser accounts, permissions, process isolation.All code runs with full hardware access; no protection.
UsabilityCLI or GUI, file browsers, help systems.Only low‑level firmware/monitor; no convenient interface.
ReliabilityFault handling, dead‑lock detection, graceful shutdown.Any error can crash the whole machine.

9. Illustrative Example – Coordinated File Access

Two programmes need to append data to the same log file.

  1. Each programme calls open("log.txt", O_APPEND); the OS returns a file descriptor.
  2. The OS places an advisory lock on the file while the first programme writes.
  3. When the write completes, the lock is released and the second programme can safely write its data.

Without an OS each programme would have to implement its own low‑level locking protocol, greatly increasing the chance of data corruption.

10. Simple Mathematical View of CPU Utilisation

For n independent processes with average service time Si and average inter‑arrival time Ai, the theoretical CPU utilisation is

\(U = \displaystyle\sum{i=1}^{n}\frac{Si}{A_i}\)

The scheduler tries to keep U close to 1 (full utilisation) while avoiding starvation.

11. Link to Language Translators (5.2)

Compilers, assemblers and interpreters rely on OS services to:

  • Read source files and write object files.
  • Allocate memory for the generated code.
  • Launch the resulting programmes (process creation, I/O redirection).

Thus the OS provides the runtime environment in which language translators operate.

12. Summary

  • The OS abstracts hardware, making programmes easier to write, portable and less error‑prone.
  • It performs five core management tasks: process, memory, file‑system, device, and security management.
  • Utility software and program libraries extend the OS’s functionality and aid development.
  • Different OS types (batch, time‑sharing, real‑time, embedded) suit different application domains.
  • Without an OS every application would have to control the hardware directly, leading to complexity, incompatibility and unreliable systems.

Layered view of a computer system – hardware at the bottom, the OS kernel in the middle, and user applications (including language translators) on top.