Show understanding of process management

16.1 Operating System (OS) – Core Management Tasks

What is an Operating System?

An operating system (OS) is system software that sits between the computer hardware and the applications. It manages hardware resources, provides essential services to programs, and offers a user‑friendly interface.

Core Purposes of an OS (Cambridge 9618 – 5.1)

  • Process Management – creation, scheduling, synchronisation, interruption, termination and context‑switching.
  • Memory Management – allocation, protection, virtual memory, paging/segmentation.
  • File Management – creation, organisation, storage, retrieval and protection of files.
  • Hardware Management – control of I/O devices, device drivers, and interrupt handling.
  • Security & Protection – authentication, authorisation, access control and isolation.
  • User Interface (UI) – command‑line (CLI) or graphical (GUI) interaction.
  • Utility Software & Program Libraries – bundled tools and reusable code libraries.

Process Management – Understanding the Concept

What is a Process?

A process is an executing instance of a program. It contains:

  • Program code (text segment)
  • Data (global/static variables)
  • Execution context – registers, stack, heap, and a Process Control Block (PCB) that stores its state.

Key Activities

  1. Process Creation – load program, allocate a PCB, assign a unique PID.
  2. Process Scheduling – decide which ready process receives the CPU.
  3. Context Switching – save the current process’s state and restore the next one.
  4. Interrupt Handling – hardware/software interrupts invoke an ISR; the ISR may move a process to the ready or blocked queue.
  5. Process Synchronisation – coordinate concurrent processes that share resources (semaphores, monitors, mutexes, message passing).
  6. Process Termination – release CPU, memory and I/O resources.

Process States (visual diagram)

+------+ +-------+ +----------+

| New |--->Ready| Ready |--->Running| Running |

+------+ +-------+ +----------+

^ | ^ |

| | | |

| | | |

| | | |

| | | |

| v | v

+------+ +-------+ +----------+

|Termi|<---Blocked|Blocked|<---| (I/O, wait) |

+------+ +-------+ +----------+

State descriptions

StateDescription
NewPCB is being initialised.
ReadyProcess resides in memory, waiting for CPU time.
RunningProcess is currently executing on the CPU.
Blocked (Waiting)Process cannot continue until an external event occurs (I/O completion, semaphore release, etc.).
TerminatedProcess has finished or been aborted; all resources are reclaimed.

Scheduling Algorithms

  • First‑Come, First‑Served (FCFS)
  • Shortest Job Next (SJN) / Shortest Remaining Time (SRT)
  • Round Robin (RR) – fixed time quantum q
  • Priority Scheduling – higher‑priority processes run first
  • Multilevel Queue – separate queues for different classes of processes, each with its own policy

Performance Metrics

  • CPU utilisation: \(U = 1 - p^{\,n}\) where p = probability a process is waiting for I/O, n = number of processes.
  • Throughput – number of processes completed per unit time.
  • Turnaround time – total time from creation to termination.
  • Waiting time – total time spent in the ready queue.
  • Response time – time from request to first response (critical for interactive systems).

Case Study: Round‑Robin Scheduling

Assume three processes P1, P2, P3 arrive at time 0 with CPU‑burst times 5 ms, 3 ms and 8 ms respectively. The quantum q = 2 ms.

Time 0‑2 : P1 runs (remaining 3 ms) → back of queue

Time 2‑4 : P2 runs (remaining 1 ms) → back of queue

Time 4‑6 : P3 runs (remaining 6 ms) → back of queue

Time 6‑8 : P1 runs (remaining 1 ms) → back of queue

Time 8‑9 : P2 runs (finishes) → leaves queue

Time 9‑11: P3 runs (remaining 4 ms) → back of queue

Time 11‑12: P1 runs (finishes) → leaves queue

Time 12‑14: P3 runs (remaining 2 ms) → back of queue

Time 14‑16: P3 runs (finishes)

Advantages

  • Fair allocation – every ready process gets an equal share of CPU time.
  • Good responsiveness for interactive users.

Disadvantages

  • Very small quantum → many context switches, high overhead.
  • Very large quantum → behaviour approaches FCFS, reducing responsiveness.

Memory Management

Goals

  • Provide each process with the illusion of a large, contiguous address space.
  • Protect one process’s memory from another.
  • Make efficient use of the limited physical RAM.

Virtual Memory

  • Allows processes to use more memory than physically present by swapping pages to secondary storage.
  • Implemented with a page table that maps virtual page numbers to physical frame numbers.

Paging vs. Segmentation

AspectPagingSegmentation
Division of memoryFixed‑size pages (e.g., 4 KB)Variable‑size logical segments (code, data, stack)
Address translationPage number + offset → frame number + offsetSegment number + offset → base address + offset
External fragmentationNone (only internal fragmentation)Possible, because segment sizes differ
Typical useMost modern general‑purpose OSesOften combined with paging for protection and sharing

Page‑Fault Handling (summary)

  1. CPU generates a fault when a referenced page is not in RAM.
  2. OS selects a free frame or evicts a victim page using a replacement algorithm (e.g., LRU, FIFO).
  3. The required page is read from disk into the chosen frame.
  4. Page table is updated and the interrupted instruction is restarted.

File Management

  • File creation & deletion – system calls such as create(), unlink().
  • Organisation – hierarchical directories (folders) that group related files.
  • Storage & retrieval – reading and writing data via open(), read(), write(), close().
  • File‑system types – FAT, NTFS, ext4, HFS+, APFS; each defines how blocks are allocated and how metadata is stored.
  • Permissions & protection – read/write/execute bits (Unix) or ACLs (Windows) that control who may access a file.

Example – Unix‑style file‑system permissions

-rwxr‑‑r‑‑ 1 alice staff 4096 Apr 12 09:23 report.txt

│ │ │ │ │

│ │ │ │ └─ Others: read‑only

│ │ │ └──── Group: read‑only

│ │ └─────── Owner: read, write, execute

│ └───────── File type (‑ = regular file)

└──────────── Permissions string

Hardware Management

  • I/O Device Control – keyboards, mice, printers, disks, network cards.
  • Device Drivers – specialised kernel modules that translate generic OS requests into device‑specific commands.
  • Interrupt Handling – hardware raises an interrupt; the OS’s interrupt service routine (ISR) saves the current context, services the device, and may move a process to the ready queue.
  • Direct Memory Access (DMA) – allows devices to transfer data to/from RAM without CPU involvement, improving throughput.
  • Polling vs. Interrupt‑driven I/O – polling repeatedly checks device status; interrupt‑driven I/O lets the device notify the OS when it is ready.

Security & Protection

  • Authentication – verification of identity (passwords, smart cards, biometrics).
  • Authorisation (Access Control) – permission bits, Access Control Lists (ACLs), role‑based access control.
  • Isolation – each process runs in its own protected address space; memory‑protection hardware prevents one process from reading/writing another’s data.
  • Additional mechanisms – firewalls, encryption services, audit logs, sandboxing.

User Interface (UI)

  • Command‑Line Interface (CLI) – text commands entered in a terminal (e.g., copy, ls, gcc).
  • Graphical User Interface (GUI) – windows, icons, menus, pointers; user actions are translated into system calls by the window manager.

Utility Software & Program Libraries

Typical Utilities (concrete examples)

  • Disk Management – Windows Disk Management, Linux fdisk/gdisk
  • File‑system check – Windows chkdsk, Linux fsck
  • Backup – Windows Backup & Restore, Linux rsync
  • Virus scanner – Windows Defender, ClamAV (Linux)
  • Task manager – Windows Task Manager, Linux top/htop

Program Libraries (examples & simple API call flow)

  • Windows – Dynamic‑Link Libraries (.dll) such as kernel32.dll, user32.dll.
  • Linux – Shared objects (.so) like libc.so, libpthread.so.

Simple API call diagram (open a file)

Application

└─► open("data.txt", O_RDONLY) // library call

System Call Interface (kernel entry point)

Kernel → File‑system driver → Device driver → Disk

Kernel returns a file descriptor (e.g., 3) to the application

Summary

  • The OS is the central manager of hardware, processes, memory, files, security and user interaction.
  • Effective process management (creation, scheduling, synchronisation, interrupts, termination) enables multitasking and responsive systems.
  • Memory management (paging, segmentation, virtual memory) gives each process a private, large address space while maximising RAM utilisation.
  • File management and hardware management complete the core tasks required by the Cambridge 9618 syllabus.
  • Utility software and program libraries provide ready‑made tools and APIs that simplify system administration and application development.
  • Understanding these concepts equips students to analyse, compare and evaluate different OS designs, as expected in the Cambridge IGCSE/A‑Level examinations.