The Operating System

AS Level — Unit 1: Fundamentals of Computer Science

Purpose and Functions of an Operating System

The Operating System (OS) is the most important piece of system software on a computer. It acts as an intermediary between the user, application software, and the hardware. Without an OS, users would need to communicate with the hardware directly using machine code.

An Operating System is system software that manages computer hardware resources, provides common services for application programs, and acts as an interface between the user and the hardware.

Key Functions of an Operating System

Function Description
Memory management Allocates and deallocates RAM to processes; manages virtual memory, paging, and segmentation
Processor (CPU) management Schedules processes to use the CPU; handles multitasking by switching between processes
File management Organises files into directories/folders; manages file creation, deletion, renaming, access permissions, and storage allocation on disk
I/O device management Manages communication with peripheral devices through device drivers; handles data transfer between devices and memory
User interface Provides a way for users to interact with the computer (GUI, CLI, or natural language interface)
Security and access control Manages user accounts, authentication (passwords, biometrics), and access rights to files and resources
Error handling Detects and responds to hardware and software errors, displaying appropriate error messages
Networking Manages network connections, protocols, and shared resources in networked environments
Interrupt handling Detects, prioritises, and processes interrupts from hardware and software

Resource Management

The OS is fundamentally a resource manager. The main resources it manages are:

  • Processor time — which process gets to use the CPU and for how long
  • Memory (RAM) — which process gets which portion of memory
  • I/O devices — coordinating access to printers, disks, network interfaces, etc.
  • Storage — managing where files are stored on disk and how space is allocated

In exam questions about OS functions, think of the OS as a resource manager that controls access to the CPU, memory, storage, and I/O devices. Every function relates back to managing one or more of these resources.


Memory Management

Memory management is one of the most critical functions of the OS. It involves allocating blocks of RAM to processes that need them and reclaiming memory when processes finish. The OS must ensure that processes do not interfere with each other’s memory.

Paging

Paging divides both physical memory (RAM) and logical memory (the program) into fixed-size blocks:

  • Physical memory is divided into page frames (fixed-size slots in RAM)
  • A program’s logical address space is divided into pages of the same size
  • Pages are loaded into any available page frames — they do not need to be contiguous

The OS maintains a page table for each process that maps logical page numbers to physical frame numbers.

How paging works:

  1. A process is divided into equal-sized pages (e.g., 4 KB each)
  2. RAM is divided into page frames of the same size
  3. Pages are loaded into any available frame
  4. The page table translates logical addresses to physical addresses at runtime
Advantage Disadvantage
Eliminates external fragmentation (no gaps between allocations) Can cause internal fragmentation — the last page may not fill its frame completely
Simple allocation — any frame can hold any page Page table itself uses memory
Allows non-contiguous allocation Page faults (accessing a page not in RAM) cause delays

Segmentation

Segmentation divides a program into logical, variable-sized blocks called segments. Each segment represents a meaningful part of the program, such as:

  • The code segment (instructions)
  • The data segment (variables)
  • The stack segment (function calls and local variables)
  • The heap segment (dynamically allocated memory)

The OS maintains a segment table that stores the base address and length of each segment.

Advantage Disadvantage
Segments correspond to logical divisions of the program, making it easier to manage Can cause external fragmentation (gaps of free memory between segments)
Sharing of segments between processes is straightforward Variable sizes make allocation more complex
Protection can be applied per segment (e.g., code segment is read-only) Segments must be contiguous in memory

Paging vs Segmentation

Feature Paging Segmentation
Block size Fixed (e.g., 4 KB) Variable (depends on program structure)
Basis Physical division of memory Logical division of program
Fragmentation Internal fragmentation (wasted space in last page) External fragmentation (gaps between segments)
Programmer awareness Invisible to programmer Programmer-aware (logical divisions)
Sharing More difficult Easier (share a whole segment)
Table used Page table Segment table

Virtual Memory

Virtual memory is a technique that uses a portion of secondary storage (e.g., hard drive or SSD) as an extension of RAM. This allows the computer to run programs that are larger than the available physical RAM by keeping only the currently needed pages in RAM and storing the rest on disk.

Virtual memory uses secondary storage to extend the apparent size of RAM. Pages of a program are swapped between RAM and disk as needed, managed by the OS.

How virtual memory works:

  1. The program is divided into pages
  2. Only the pages currently being executed are loaded into RAM
  3. The remaining pages are stored in a swap file (or page file) on the hard drive
  4. When a required page is not in RAM (page fault), the OS:
    • Finds a page in RAM that is not currently needed
    • Writes it to disk (if modified) — this is called swapping out
    • Loads the required page from disk into the freed frame — this is called swapping in

Thrashing occurs when the system spends more time swapping pages in and out than executing useful instructions. This happens when there is insufficient RAM and too many processes are competing for memory.

Advantage Disadvantage
Programs can be larger than physical RAM Accessing disk is much slower than accessing RAM
More processes can run simultaneously Thrashing degrades performance severely
Programs do not need to know the physical memory size Requires disk space for the swap file
Efficient use of limited RAM Page faults add overhead

Virtual memory does not increase the amount of physical RAM — it uses secondary storage to simulate having more RAM. Remember that thrashing is the key problem that occurs when virtual memory is overused.

Types of Operating System

Different types of OS are designed for different computing environments and requirements.

Batch Operating System

A batch OS collects and groups similar jobs together (a “batch”) and processes them one after another without user interaction during execution. Jobs are submitted and processed when resources are available.

  • Example: Payroll processing, billing systems, bank statement generation
  • Advantage: Efficient use of resources for repetitive, similar jobs
  • Disadvantage: No user interaction; errors are only detected after the entire batch has been processed

Real-Time Operating System (RTOS)

A real-time OS processes data and responds within a guaranteed time frame. It is used in systems where delayed response could be dangerous or unacceptable.

There are two types:

  • Hard real-time: Missing a deadline causes system failure (e.g., airbag deployment, nuclear reactor control, pacemaker)
  • Soft real-time: Missing a deadline degrades performance but is not catastrophic (e.g., video streaming, online gaming)

  • Advantage: Guaranteed response times; high reliability
  • Disadvantage: Complex to develop; limited functionality (focused on specific tasks)

It is important to distinguish between two types of real-time system:

Feature Real-Time Transaction Processing Real-Time Control
Purpose Process individual transactions immediately Continuously monitor and control physical processes
Example ATM withdrawals, airline booking, point-of-sale Airbag deployment, nuclear reactor, temperature control
Input User-initiated transactions Sensor data (continuous)
Response Must complete within a set time or roll back Must respond instantly to changing conditions
Failure consequence Transaction fails or is reversed Physical danger or system failure

Multi-User Operating System

A multi-user OS allows multiple users to access the same computer system simultaneously, each with their own terminal or session. The OS manages resource allocation to give each user a fair share.

  • Example: University server accessed by hundreds of students, mainframe banking systems
  • Advantage: Efficient sharing of expensive resources; centralised administration
  • Disadvantage: Requires powerful hardware; complex security management

Multi-Tasking Operating System

A multi-tasking OS allows a single user to run multiple applications at the same time. The OS switches between tasks rapidly (context switching) to give the appearance of simultaneous execution.

  • Example: Running a web browser, word processor, and music player at the same time on a desktop PC
  • Advantage: Improved productivity; better use of CPU time
  • Disadvantage: Uses more memory; context switching adds overhead

Distributed Operating System

A distributed OS manages a collection of independent computers connected by a network, making them appear as a single system to the user. Tasks can be distributed across multiple machines.

  • Example: Cloud computing platforms, distributed databases, render farms
  • Advantage: Scalability; fault tolerance (if one machine fails, others continue); resource sharing
  • Disadvantage: Complex to design and manage; network dependency; security challenges

Embedded Operating System

An embedded OS is built into a dedicated device and performs a specific set of functions. It typically runs on limited hardware with constrained memory and processing power.

  • Example: Smart TV, washing machine, car engine management, digital camera
  • Advantage: Optimised for specific hardware; small and efficient; fast boot time
  • Disadvantage: Limited functionality; difficult to update

Comparison of OS Types

OS Type Users Interaction Key Feature Example Use
Batch Multiple (indirect) None during processing Jobs grouped and processed together Payroll, billing
Real-Time Single/Multiple Immediate Guaranteed response time Airbags, medical devices
Multi-User Multiple (simultaneous) Interactive Shared resources, concurrent access University servers
Multi-Tasking Single Interactive Multiple applications simultaneously Desktop PCs
Distributed Multiple Varies Multiple computers act as one Cloud computing
Embedded Single (indirect) Limited/None Dedicated device, specific task Washing machine

You may be asked to identify the most suitable type of OS for a given scenario. Focus on the key characteristics: does the system need guaranteed response times (real-time), multiple users (multi-user), no user interaction (batch), or is it a dedicated device (embedded)?


User Interfaces

The user interface is the means by which a user interacts with the computer. The OS provides one or more types of interface.

Command Line Interface (CLI)

A CLI allows users to interact with the OS by typing text commands at a prompt. The user must know the correct commands and syntax.

Examples: Windows Command Prompt, PowerShell, Linux Bash terminal

# Example CLI commands (Linux/Mac):
# ls              — list files in current directory
# cd Documents    — change to Documents directory
# mkdir NewFolder — create a new directory
# cp file1.txt file2.txt — copy a file
# rm file1.txt   — delete a file

Graphical User Interface (GUI)

A GUI uses visual elements — windows, icons, menus, and pointers (WIMP) — to allow users to interact with the computer using a mouse, touchpad, or touchscreen.

Examples: Windows desktop, macOS Finder, Android home screen

CLI vs GUI Comparison

Feature CLI GUI
Ease of use Difficult for beginners — must learn commands Intuitive — visual, point-and-click
Speed Faster for experienced users Slower for repetitive tasks
Resource usage Low — text-based, minimal RAM and processing High — graphical rendering requires more resources
Precision High — exact commands with parameters Lower — limited to available menu options
Automation Easy — commands can be scripted (batch files, shell scripts) Difficult to automate
Error-prone Typing mistakes cause errors Less error-prone (guided choices)
Accessibility Poor for non-technical users Good — designed for general users
Remote access Excellent — low bandwidth required Requires more bandwidth for remote desktop
Best for System administrators, developers, servers General users, creative applications

Natural Language Interface (NLI)

A natural language interface allows users to interact using everyday spoken or written language. The system interprets the user’s intent and responds accordingly.

Examples: Siri, Alexa, Google Assistant, ChatGPT

  • Advantage: Very accessible; no training needed; suitable for users with disabilities
  • Disadvantage: Can misinterpret commands; limited in complex tasks; requires significant processing power

A common exam question asks you to compare CLI and GUI. Structure your answer around specific criteria (ease of use, speed, resources, automation) rather than making vague statements. Always explain why one is better than the other for a given criterion.


Device Drivers and BIOS

Device Drivers

A device driver is a specialised piece of software that allows the OS to communicate with a specific hardware device. Each device requires its own driver because different devices have different commands and communication protocols.

A device driver is software that translates generic OS commands into specific instructions that a particular hardware device can understand and execute.

How device drivers work:

  1. An application sends a generic request to the OS (e.g., “print this document”)
  2. The OS passes the request to the appropriate device driver
  3. The device driver translates the request into device-specific commands
  4. The hardware device receives and executes the commands
  5. The device driver reports the result back to the OS

Key points about device drivers:

  • Each hardware device needs a specific driver for the OS it is being used with
  • Drivers are usually provided by the hardware manufacturer
  • Drivers must be updated when the OS is updated or when bugs are found
  • Incorrect or outdated drivers can cause system instability or hardware malfunction
  • The OS maintains a library of common drivers but may need additional drivers for specialist hardware

BIOS (Basic Input/Output System)

The BIOS (or its modern replacement, UEFI) is firmware stored on a ROM chip on the motherboard. It is the first software that runs when the computer is switched on.

Functions of the BIOS:

  1. Power-On Self-Test (POST) — tests that essential hardware components are present and functioning (CPU, RAM, keyboard, storage devices)
  2. Bootstrap loader — locates and loads the OS from secondary storage into RAM
  3. Hardware configuration — provides basic settings for hardware components (date/time, boot order, CPU settings)
  4. Basic I/O services — provides low-level routines for communicating with hardware before device drivers are loaded

Boot sequence:

  1. Computer is powered on
  2. BIOS runs the POST to check hardware
  3. BIOS reads the boot order to determine which storage device to load the OS from
  4. BIOS locates the boot sector on the selected device
  5. The bootstrap loader loads the OS kernel into RAM
  6. The OS takes control and loads device drivers, starts services, and presents the user interface

Remember the BIOS runs before the OS. Its job is to test the hardware (POST) and then load the OS into memory. Without the BIOS, the computer would not know where to find the operating system.


Utility Software

Utility software consists of system programs that perform specific maintenance and housekeeping tasks to keep the computer running efficiently. Utilities are not part of the OS kernel but often come bundled with the OS.

Utility software is system software that performs specific maintenance, optimisation, or security tasks to support the efficient operation of the computer system.

Common Utility Programs

Utility Purpose Details
Disk defragmenter Reorganises fragmented files on a hard disk Files become fragmented over time (parts stored in non-contiguous locations). Defragmentation moves file fragments so they are stored contiguously, improving read speed. Not needed for SSDs.
Disk formatter Prepares a storage device for use Sets up the file system structure (e.g., NTFS, FAT32, ext4) so the OS can read and write files
File compression Reduces file size Uses algorithms to encode data more efficiently. Reduces storage space and speeds up file transfer. Can be lossy (some data lost) or lossless (original data fully recoverable).
Antivirus / Anti-malware Detects and removes malicious software Scans files and memory for known malware signatures and suspicious behaviour. Requires regular updates to its virus definition database.
Firewall Monitors and controls network traffic Blocks unauthorised incoming/outgoing connections based on security rules. Can be software-based or hardware-based.
Backup utility Creates copies of data for recovery Supports full, incremental, and differential backups. Essential for disaster recovery.
Encryption utility Protects data by encoding it Converts plaintext to ciphertext so only authorised users with the decryption key can read it. Used for sensitive files, emails, and disk encryption.
File manager Organises files and folders Allows users to create, rename, move, copy, and delete files and directories.
System monitor Displays system performance information Shows CPU usage, memory usage, disk activity, network traffic, and running processes. Helps diagnose performance issues.

Why Utility Software is Needed

  • Performance — defragmentation and disk cleanup keep the system running efficiently
  • Security — antivirus, firewalls, and encryption protect against threats
  • Storage management — compression and backup utilities manage limited storage space
  • Reliability — backup utilities ensure data can be recovered after failure
  • Maintenance — regular use of utilities extends the useful life of the system

Be able to name, describe, and justify the use of specific utility programs for given scenarios. For example, if asked “how can a company protect sensitive data on employee laptops?”, you might suggest encryption utilities (to protect data if the laptop is stolen) and backup utilities (to recover data if the laptop is lost or damaged).


Buffering

A buffer is a temporary storage area in memory used to hold data that is being transferred between two devices or processes that operate at different speeds.

Buffering is needed because the CPU operates much faster than I/O devices (printers, disks, network connections). Without buffering, the CPU would have to wait idle until the slower device was ready.

Single Buffering

  • Data is placed in one buffer by the producing device/process
  • The consuming device/process reads from the same buffer
  • The producer must wait until the consumer has finished reading before writing new data
  • Simple but can leave the CPU or I/O device idle while waiting

Double Buffering

  • Two buffers are used alternately
  • While one buffer is being read by the consumer, the other is being filled by the producer
  • When both are done, the buffers swap roles
  • This allows the CPU and I/O device to work simultaneously, significantly improving throughput
  • Used in audio/video streaming, printing, and disk I/O
Feature Single Buffering Double Buffering
Buffers used 1 2
Concurrency Producer and consumer take turns Producer and consumer work simultaneously
Efficiency Lower — one device may be idle Higher — both devices stay busy
Complexity Simple Slightly more complex

Spooling

Spooling (Simultaneous Peripheral Operations On-Line) is a specific form of buffering used for slow output devices like printers. Print jobs are stored in a spool queue on disk, and the printer processes them one at a time while the CPU continues with other tasks.

Managing Backing Store: Directory Structure and File Attributes

Hierarchical Directory Structure

A hierarchical directory structure organises files into a tree of nested folders (directories), with a single root directory at the top.

  • The root directory contains all other directories and files.
  • Subdirectories allow files to be grouped logically (e.g. by user, project, or type).
  • A path specifies a file’s location by listing directories from root to file (e.g. /Users/Jason/Documents/report.txt).
  • Absolute path: the full path from the root — works from anywhere.
  • Relative path: the path from the current working directory.
Root /
├── Users/
│   ├── Jason/
│   │   ├── Documents/
│   │   └── Pictures/
│   └── Admin/
├── System/
└── Applications/

File Attributes

Every file has associated attributes — metadata stored and managed by the OS:

Attribute Description
Filename The name used to identify the file
File type / extension Indicates the format (e.g. .txt, .exe, .jpg)
File size Storage space occupied, in bytes
Date/time created When the file was first created
Date/time modified When the file was last changed
Date/time accessed When the file was last opened
Owner The user account that owns the file
Permissions Read / write / execute rights for owner, group, and others
Hidden Whether the file is visible in normal directory listings
Read-only Whether the file can be modified
Archive flag Whether the file has changed since the last backup

A hierarchical directory structure organises files in a tree of nested folders with a single root. File attributes are metadata describing each file — name, size, type, timestamps, owner, and permissions.

Know the difference between an absolute path (from the root, always correct) and a relative path (from the current directory). Be able to list file attributes and explain what each is used for — permissions and the archive flag are commonly tested.


Modes of Operation

Batch Processing

Batch processing collects jobs together and processes them as a group, without user interaction during the run.

  • Jobs are queued and processed one after another, typically overnight.
  • All input data is prepared in advance.
  • Results are not available until the batch completes.

Advantages: efficient use of processor time; large volumes processed automatically. Disadvantages: no immediate results; errors only found after the batch runs.

Applications: payroll processing, bank end-of-day transaction updates, utility bill generation, printing exam certificates.

Real-Time Control Systems

A real-time control system reads sensor inputs and responds immediately to control a physical process, within a guaranteed time deadline.

  • The response must occur within a strict time limit — a late response is as bad as no response.
  • Typically a dedicated, embedded system running one application continuously.

Applications: aircraft autopilot, anti-lock braking systems (ABS), industrial process control (temperature/pressure in a chemical plant), missile guidance.

Real-Time Transaction Systems

A real-time transaction system processes each transaction immediately, updating the database at once so data is always current.

  • Multiple users can access the system simultaneously.
  • The system must handle concurrent access and maintain data consistency.

Applications: ATM withdrawals, online seat booking (airline, cinema), online shopping stock updates, stock market trading.

Comparison

Feature Batch Processing Real-Time Control Real-Time Transaction
User interaction None during processing None (automated) Yes
Response time Not time-critical Strict deadline Immediate
Data currency Periodic Continuous Always current
Examples Payroll, billing ABS, autopilot ATM, booking systems

Batch processing groups jobs and processes them together without interaction. Real-time control responds to sensor inputs within strict time limits to control a physical process. Real-time transaction processing updates a database immediately for each transaction.

Given a scenario, identify the mode: similar high-volume jobs with no immediate results needed → batch; physical process must respond within milliseconds → real-time control; database must stay instantly current for multiple users → real-time transaction. Always justify with the scenario.