Mission 1 · Spec 1.2.1
Operating systems
Memory management (paging, segmentation, virtual memory), interrupts and the ISR, types of operating system, the BIOS, device drivers and virtual machines.
- Starter 5 min
- Learn 15 min
- Lab 15 min
- Quiz 10 min
- Exam 15 min
The doorbell
You're reading when the doorbell rings. What do you do with your book before answering, and why?
Reveal
You mark your page, deal with the visitor, then carry on from where you left off. A CPU does the same with an interrupt: it saves the current state (register contents) on a stack, runs an interrupt service routine, then restores the state.
Key ideas
Paging
Memory is split into equal, fixed-size pages (physical divisions). A page table maps pages to frames, so a program need not be stored contiguously.
Segmentation
Memory is split into variable-size segments that match logical divisions of a program (e.g. a module or subroutine).
Virtual memory
Secondary storage used as extra memory when RAM is full. Pages not currently needed are swapped out. Too much swapping causes disk thrashing.
Interrupts
A signal to the CPU that a device or program needs attention. At the end of each FDE cycle the CPU checks for interrupts; if one has higher priority than the current task, the registers are pushed onto a stack and the ISR runs.
| Type of OS | Description |
|---|---|
| Distributed | Runs across several computers, sharing the load so they appear to the user as one system |
| Embedded | Built for a specific device with limited resources; very reliable |
| Multi-tasking | Appears to run several programs at once by rapidly switching between them (time slicing) |
| Multi-user | Several users share one computer's resources, e.g. a mainframe; a scheduler ensures fair CPU time |
| Real-time | Guarantees a response within a fixed time, e.g. car airbags, industrial control |
BIOS: the first program run at start-up, stored in ROM/flash; runs the power-on self test (POST) and loads the OS. Device drivers: software that lets the OS communicate with specific hardware. Virtual machines: software that emulates a computer, e.g. running another OS, or an intermediate-code interpreter such as the Java Virtual Machine.
Handling an interrupt
Put the steps in order.Paging or segmentation?
Virtual memory in action
Exam-style questions
1. Compare paging and segmentation.
[4 marks]Mark scheme
- Pages are a fixed size; segments vary in size (1)
- Pages are physical divisions; segments are logical divisions (1)
- Segments match the structure of the program, e.g. whole subroutines (1)
- Both allow a program to be stored non-contiguously / both use a table to map to physical memory (1)
2. Explain why a real-time operating system is needed in a car's airbag system.
[2 marks]Mark scheme
- An RTOS guarantees a response within a fixed, very short time (1)
- A delay in deploying the airbag could cause injury or death (1)
TUTOR NOTES
- Misconception: the CPU stops immediately when an interrupt arrives. It finishes the current cycle first.
- Exam habit: in interrupt questions, mention the stack and priorities.
Mission 2 · Spec 1.2.1
Scheduling
How the OS decides which process runs next: round robin, first come first served, multi-level feedback queues, shortest job first and shortest remaining time.
- Starter 5 min
- Learn 10 min
- Lab 20 min
- Quiz 10 min
- Exam 15 min
The supermarket queue
You have one item; the person in front has a full trolley. Is it fair to let you go first? What if people with one item kept arriving?
Reveal
Letting the shortest job go first lowers the average wait, but the trolley might never get served: starvation. Every scheduling algorithm balances throughput, fairness and responsiveness.
The algorithms
First come first served
Jobs run in arrival order to completion. Simple; long jobs make others wait. Non-pre-emptive.
Round robin
Each job gets a time slice (quantum), then goes to the back of the queue. Pre-emptive; fair, but doesn't consider priority and has switching overhead.
Shortest job first
The waiting job with the shortest total time runs next, to completion. Non-pre-emptive. Needs burst times in advance; long jobs may starve.
Shortest remaining time
Pre-emptive: the job with the least time remaining runs, and a newly arrived shorter job interrupts. Low waiting times; starvation risk.
Multi-level feedback queues
Several queues with different priorities. Jobs move between queues based on their behaviour, e.g. a job that uses a full time slice drops to a lower priority. Complex, but balances responsiveness and throughput.
Scheduling simulator
Edit the arrival and burst times, and compare algorithms.Exam-style questions
1. Explain the difference between pre-emptive and non-pre-emptive scheduling, giving an example of each.
[4 marks]Mark scheme
- Pre-emptive: the OS can stop a running job before it finishes to run another (1), e.g. round robin / shortest remaining time (1)
- Non-pre-emptive: once a job starts it runs until it finishes (1), e.g. first come first served / shortest job first (1)
2. Explain why shortest job first may not be suitable for a system with many long-running jobs.
[2 marks]Mark scheme
- Short jobs are always chosen first (1)
- so long jobs may wait indefinitely / be starved if short jobs keep arriving (1)
TUTOR NOTES
- Lab prompt: find arrival and burst times where round robin gives a lower average waiting time than FCFS.
- Exam habit: when asked to draw a schedule, label every time unit.
Mission 3 · Spec 1.2.2
Applications generation
Application and utility software, open and closed source, translators, the stages of compilation, and linkers, loaders and libraries.
- Starter 5 min
- Learn 15 min
- Lab 15 min
- Quiz 10 min
- Exam 15 min
Reading a sentence
How do you understand "The cat sat on the mat."? Think about the steps: recognising words, checking grammar, understanding meaning.
Reveal
A compiler works the same way: lexical analysis (recognise the words/tokens), syntax analysis (check the grammar), then code generation and optimisation.
Key ideas
Open source vs closed source
Open source: code can be viewed, modified and shared; free; community support. Closed source: code is protected; paid licence; official support and updates.
Translators
Assembler: assembly → machine code. Compiler: whole program → object code, producing an executable. Interpreter: translates and runs line by line.
| Stage | What happens |
|---|---|
| Lexical analysis | Whitespace and comments removed; code split into tokens; identifiers added to the symbol table |
| Syntax analysis | Tokens checked against the language's grammar rules; an abstract syntax tree is built; syntax errors reported |
| Code generation | Object code (machine code) is generated from the syntax tree |
| Optimisation | Code is made faster or smaller, e.g. removing redundant instructions or unused code |
Libraries
Pre-written, tested code that can be imported. Saves time and is reliable, but may not fit exactly and adds dependencies.
Linkers and loaders
A linker combines object code and library code into one executable (static linking copies it in; dynamic linking references it). A loader copies the program into memory and resolves addresses so it can run.
Lexical analyser
Type a line of code and see it tokenised.Stages of compilation
Exam-style questions
1. Describe what happens during lexical analysis.
[3 marks]Mark scheme
- Whitespace and comments are removed (1)
- The code is split into tokens / keywords and identifiers are replaced with tokens (1)
- Identifiers are added to the symbol table (1)
2. Explain the difference between static and dynamic linking.
[2 marks]Mark scheme
- Static: library code is copied into the executable, making it larger but self-contained (1)
- Dynamic: the executable holds references to library files, loaded at run time; smaller, but the library must be present (1)
TUTOR NOTES
- Misconception: syntax analysis creates the symbol table. It's started in lexical analysis.
- Exam habit: say what each stage outputs, not just what it checks.
Mission 4 · Spec 1.2.3
Software development methodologies
Waterfall, agile, extreme programming, spiral model and rapid application development: their features, strengths and weaknesses.
- Starter 5 min
- Learn 15 min
- Lab 15 min
- Quiz 10 min
- Exam 15 min
Building a house vs writing an app
You can't change a house's foundations after the walls are up. Can you change an app's design after release? How should that affect how we plan software?
Reveal
Software can change, so methods like agile embrace changing requirements with short iterations. Rigid, stage-by-stage methods like waterfall suit projects where requirements are clear and fixed.
The methodologies
| Method | Features | Suited to |
|---|---|---|
| Waterfall | Linear stages (analysis, design, implementation, testing, maintenance); each completed before the next; little user involvement after analysis | Large, stable projects with clear, fixed requirements |
| Agile | Short iterations (sprints) delivering working software; changing requirements welcomed; frequent user feedback | Projects where requirements are likely to change |
| Extreme programming (XP) | An agile method: pair programming, test-driven development, continuous integration, customer on the team | Small teams needing high-quality code and rapidly changing requirements |
| Spiral model | Repeated cycles of planning, risk analysis, engineering and evaluation; focus on identifying and reducing risk | Large, high-risk or expensive projects |
| RAD | Prototypes built quickly and refined with user feedback; time-boxed; reuses components | Projects with unclear requirements and heavy user interaction, e.g. user interfaces |
Which methodology?
Exam-style questions
1. A company is developing a mobile game where the client's ideas are likely to change. Evaluate whether it should use the waterfall model or agile development.
[9 marks]Mark scheme (levels)
- Level 3 (7–9): thorough knowledge of both; applied well to the scenario; justified conclusion.
- Level 2 (4–6): good knowledge, some application.
- Level 1 (1–3): basic knowledge.
- Indicative content: waterfall is linear, hard to go back, suits fixed requirements, clear documentation; agile uses iterations, welcomes change, regular client feedback, working software early, less documentation; changing ideas suit agile; a game benefits from playable prototypes and user testing. Conclusion: agile.
TUTOR NOTES
- Exam habit: 9-mark "evaluate" questions need a justified conclusion linked to the scenario.
- Misconception: agile means no planning or documentation.
Mission 5 · Spec 1.2.4
Types of programming language
Programming paradigms, assembly language and the LMC, addressing modes, and object-oriented concepts.
- Starter 5 min
- Learn 15 min
- Lab 20 min
- Quiz 10 min
- Exam 15 min
Many ways to say it
Add up the numbers in a list. How would you describe this as a list of steps? As a mathematical definition? As an object that knows how to total itself?
Reveal
Those are three paradigms: procedural (steps), functional/declarative (definitions), and object-oriented (objects with methods). Different paradigms suit different problems.
Key ideas
Paradigms
Procedural: sequences of instructions grouped into procedures. Object-oriented: objects combining data and methods. Declarative: describe what the result should be, not how (e.g. SQL). Functional: built from functions without changing state.
Assembly language and the LMC
Mnemonics map one-to-one to machine code. The Little Man Computer uses instructions such as LDA, STA, ADD, SUB, INP, OUT, BRA, BRZ, BRP and HLT. Try it in the site's LMC simulator.
OOP concepts
Class: a template. Object: an instance of a class. Method: a subroutine in a class. Attribute: data in a class. Inheritance: a subclass gains the attributes and methods of its superclass. Encapsulation: attributes are private, accessed through methods. Polymorphism: a method behaves differently depending on the object's class.
Addressing modes
OOP vocabulary
Exam-style questions
1. Explain the difference between direct and indirect addressing.
[2 marks]Mark scheme
- Direct: the operand is the address of the data to be used (1)
- Indirect: the operand is the address of a location holding the address of the data (1)
2. Explain why encapsulation is used in object-oriented programming.
[2 marks]Mark scheme
- Attributes are made private and can only be accessed through public methods (1)
- which prevents accidental or invalid changes / data can be validated / implementation can change without affecting other code (1)
TUTOR NOTES
- Practical: write an LMC program that adds two inputs, then one that outputs the larger.
- Misconception: an object and a class are the same thing.