๐Ÿ–ฅ๏ธ A Level ยท Chapter 16

System Software

Operating Systems ยท Process Management ยท Memory ยท Translation Software ยท BNF ยท RPN


๐Ÿ”ง 16.1 Operating System Purposes
Core job of the OS
The OS sits between hardware and user applications. Its job is to maximise resource usage, abstract hardware complexity, and provide a safe, fair environment for multiple processes to run.
Process Management & States

A process is a program in execution. Every process moves between three states:

๐ŸŸก Ready
Waiting for CPU
โ†’
Scheduled
๐ŸŸข Running
Using CPU
โ†’
I/O wait
๐Ÿ”ด Blocked
Waiting for I/O
Transitions
Ready โ†’ Running: scheduler picks the process. Running โ†’ Blocked: process requests I/O (disk, network). Blocked โ†’ Ready: I/O completes. Running โ†’ Ready: time slice expires (pre-emption).
Scheduling Algorithms
AlgorithmHow it worksProsCons
Round Robin Each process gets a fixed time slice in turn Fair, responsive, no starvation High-priority jobs wait equally
Shortest Job First (SJF) Process with shortest estimated runtime goes next Minimises average waiting time Long jobs may starve; need to know runtime
First Come First Served Queue โ€” earliest arrival runs first Simple, no starvation Long jobs block short ones (convoy effect)
Shortest Remaining Time Pre-emptive SJF โ€” switch if new job has less time remaining Optimal average wait time Context-switching overhead; needs runtime estimates
Virtual Memory, Paging & Segmentation

When RAM is full, the OS uses virtual memory โ€” treating part of the disk as extra RAM. This allows programs larger than physical RAM to run.

Memory is divided into fixed-size blocks called pages (in RAM) and frames (on disk). The OS maintains a page table mapping virtual page numbers to physical frame addresses.

P0
RAM
P1
RAM
P2
DISK
P3
free
P4
DISK
P5
RAM

When a process accesses a page not in RAM โ†’ page fault โ†’ OS loads it from disk (swapping out another page if needed).

Disk Thrashing
If too many processes compete for too little RAM, the OS spends more time swapping pages than executing instructions. Performance collapses. Fix: add RAM or reduce running processes.

Paging

  • Fixed-size blocks
  • No external fragmentation
  • Pages don’t map to logical meaning
  • Simpler to manage

Segmentation

  • Variable-size blocks (matching logical sections: code, data, stack)
  • Can cause external fragmentation
  • More meaningful to programmer
  • Protection: code segment can be read-only

โš—๏ธ 16.2 Translation Software
Stages of Compilation
1
Lexical Analysis
Tokenises source code: removes whitespace/comments, converts keywords/identifiers/literals into tokens. Builds a symbol table.
2
Syntax Analysis
Checks token stream against grammar rules (using a parse tree). Reports syntax errors. Produces Abstract Syntax Tree (AST).
3
Semantic Analysis
Checks meaning: type checking, variable declarations, scope. Are operations valid? (e.g. can’t add integer to string)
4
Code Generation
Translates AST into intermediate or target machine code.
5
Optimisation
Improves generated code: removes dead code, simplifies loops, reorders instructions for speed/efficiency.
BNF โ€” Backus-Naur Form

BNF is a formal notation for defining the grammar (syntax rules) of a programming language.

Symbols: ::= means “is defined as” | means “or” < > encloses a non-terminal (something to be expanded) Example โ€” defining a digit and integer: <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <integer> ::= <digit> | <integer> <digit> This says: an integer is either a single digit, OR an existing integer followed by another digit โ†’ allows: 5, 42, 317, 9001…
Syntax diagrams
Syntax diagrams (railroad diagrams) are the visual equivalent of BNF โ€” boxes represent terminals/non-terminals, arrows show valid paths through the grammar.
Reverse Polish Notation (RPN)

RPN places operators after their operands. No brackets needed โ€” operator precedence is explicit in position. Evaluates using a stack.

Infix โ†’ RPN

Infix: (3 + 4) ร— 5 RPN: 3 4 + 5 ร— Infix: A + B ร— C RPN: A B C ร— +(higher precedence ร— goes first)

Evaluating RPN with a stack

Expression: 3 4 + 5 ร— Token Stack 3 [3] 4 [3, 4] + [7] (3+4) 5 [7, 5] ร— [35] (7ร—5) Result: 35 โœ“
Why RPN?
Compilers use RPN internally because it eliminates operator precedence ambiguity and maps directly to stack-machine instructions. Easy to evaluate with a simple stack algorithm.
CompilerInterpreter
TranslationEntire program before executionLine-by-line at runtime
SpeedFast execution (pre-compiled)Slower (translates each run)
Error detectionAll errors at compile timeStops at first runtime error
DistributionCan distribute executable (no source)Source code usually needed
DebuggingHarder โ€” re-compile each changeEasier โ€” run and see immediately
Use caseProduction software (C, C++)Development/scripting (Python, JavaScript)
Hybrid (Java)
Java compiles to bytecode (platform-independent), then the JVM interprets or JIT-compiles bytecode at runtime. Gets some benefits of both.
โšก Exam Essentials
  • Name all 3 process states and transitions between them
  • Compare all 4 scheduling algorithms with pros and cons
  • Explain paging, page fault, and disk thrashing
  • Distinguish paging from segmentation
  • Name all 4โ€“5 compilation stages in order
  • Write and interpret BNF grammar rules
  • Convert infix to RPN and evaluate RPN using a stack trace

๐Ÿ““ Other Notes:

Chapter 13: Data Representation Chapter 14: Communication & Internet Chapter 15: Hardware & Virtual Machines Chapter 17: Security Chapter 18: Artificial Intelligence

๐Ÿ“‹ 9618/4 Detailed Exam Guide โ†’

Scroll to Top