System Software
Operating Systems ยท Process Management ยท Memory ยท Translation Software ยท BNF ยท RPN
A process is a program in execution. Every process moves between three states:
| Algorithm | How it works | Pros | Cons |
|---|---|---|---|
| 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 |
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.
RAM
RAM
DISK
free
DISK
RAM
When a process accesses a page not in RAM โ page fault โ OS loads it from disk (swapping out another page if needed).
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
BNF is a formal notation for defining the grammar (syntax rules) of a programming language.
RPN places operators after their operands. No brackets needed โ operator precedence is explicit in position. Evaluates using a stack.
Infix โ RPN
Evaluating RPN with a stack
| Compiler | Interpreter | |
|---|---|---|
| Translation | Entire program before execution | Line-by-line at runtime |
| Speed | Fast execution (pre-compiled) | Slower (translates each run) |
| Error detection | All errors at compile time | Stops at first runtime error |
| Distribution | Can distribute executable (no source) | Source code usually needed |
| Debugging | Harder โ re-compile each change | Easier โ run and see immediately |
| Use case | Production software (C, C++) | Development/scripting (Python, JavaScript) |
- 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
