ASUnit 1 · Fundamentals of Computer Science
The parts of a computer system
Every computer system, from a phone to a server, has the same main parts:
| Part | What it does |
|---|---|
| Processor (CPU) | Fetches, decodes and executes instructions |
| Main memory (RAM) | Holds the programs and data currently in use |
| Secondary storage | Keeps programs and data when the power is off |
| Input and output devices | Get data in and results out |
| Communication devices | Connect to other systems, e.g. a network interface card |
They are connected by buses, sets of parallel wires that carry signals between components:
- Data bus: carries data and instructions. It works in both directions.
- Address bus: carries the memory address to read from or write to. One direction only, from the processor. Its width sets how much memory can be addressed: a 32-bit address bus can address 2³² locations.
- Control bus: carries control signals such as read, write, clock and interrupt requests.
External devices connect through ports and controllers, for example USB, HDMI, Thunderbolt or a network port, or wirelessly.
Von Neumann architecture
In the Von Neumann architecture, programs and data are stored together in the same main memory (the stored program concept). The processor fetches instructions one at a time and executes them.
The processor contains:
- Arithmetic logic unit (ALU): does calculations and logical comparisons.
- Control unit (CU): decodes instructions and sends control signals to coordinate everything else.
- Clock: sends regular pulses that keep components in step.
- Registers: very fast storage locations inside the processor.
| Register | Holds |
|---|---|
| Program counter (PC) | The address of the next instruction |
| Memory address register (MAR) | The address about to be read from or written to |
| Memory data register (MDR) | The data or instruction just read, or about to be written. Also called the memory buffer register (MBR) |
| Current instruction register (CIR) | The instruction being decoded and executed |
| Accumulator (ACC) | Results of calculations in the ALU |
| Status register | Flags such as carry, zero, negative and overflow |
The Von Neumann bottleneck: instructions and data share one memory and one set of buses, so they cannot be fetched at the same time. The processor can be left waiting for memory.
Harvard architecture keeps instructions and data in separate memories with separate buses, so both can be fetched at once. It is common in microcontrollers and digital signal processors. Most modern processors are a mix: one main memory, but separate caches for instructions and data close to the processor.
Memory and caching
| Type | Volatile? | Use |
|---|---|---|
| Registers | Yes | Inside the processor; fastest of all |
| Cache (SRAM) | Yes | Copies of recently or frequently used data and instructions |
| Main memory (DRAM) | Yes | Programs and data in use |
| ROM / flash firmware | No | Start-up instructions (firmware, the bootstrap loader) |
- SRAM (static RAM) is fast but expensive and takes more space per bit, so it is used for cache.
- DRAM (dynamic RAM) must be refreshed constantly but is cheaper and denser, so it is used for main memory.
Cache is small, fast memory between the processor and main memory. When the processor needs something, it checks the cache first:
- Cache hit: it's there, so it arrives quickly.
- Cache miss: it has to come from slower main memory, and a copy is kept in the cache.
Caching works because programs tend to reuse the same data and instructions (loops) and use items stored next to each other (arrays, sequential code).
Most processors have several levels: L1 (smallest, fastest, usually per core), L2, and L3 (largest, slowest, often shared between cores).
The memory hierarchy: moving away from the processor, memory gets larger, cheaper per byte and slower: registers → cache → RAM → secondary storage.
The same idea is used elsewhere: a disk cache keeps recently used disk data in RAM, and a web browser cache keeps copies of pages and images on your device.
Parallel processing
Parallel processing means carrying out more than one instruction, or more than one part of a task, at the same time.
- Multi-core processors: several processing cores on one chip, each able to run its own instructions.
- Multiprocessor systems: several separate processors, as in servers and supercomputers.
- SIMD (single instruction, multiple data): one instruction is applied to many data items at once. Graphics processors (GPUs) work like this, which suits graphics, video and machine learning.
- MIMD (multiple instruction, multiple data): different processors run different instructions on different data. Multi-core processors are MIMD.
- Pipelining: while one instruction is being executed, the next is decoded and the one after that fetched, so the stages overlap.
Advantages: tasks that can be split up finish faster, more programs can run at once, and work can be shared to keep each core cooler and more efficient.
Disadvantages: programs must be written to split the work, some tasks cannot be split, and coordinating the processors adds overhead. Unit 4 looks at these limits in detail.
The fetch–execute cycle
The processor repeats this cycle for every instruction. Square brackets mean "the contents of".
Fetch
- MAR ← [PC] (the address of the next instruction is copied to the MAR)
- PC ← [PC] + 1 (the program counter moves on to the next instruction)
- MDR ← [Memory] addressed by the MAR (the instruction travels along the data bus)
- CIR ← [MDR] (the instruction is copied into the current instruction register)
Decode: the control unit works out what the instruction means: its operation code (opcode) and operand.
Execute: the instruction is carried out.
Reading data from RAM into a register. If the instruction is LDA 20 (load the value stored at address 20 into the accumulator), the execute stage is:
- MAR ← 20
- MDR ← [Memory] at address 20
- ACC ← [MDR]
After executing, the processor checks for interrupts before starting the next fetch.
Input and output devices
Choose a device by thinking about the user, the data and the environment.
| Device | How it works | Suitable for |
|---|---|---|
| Capacitive touchscreen | Detects the change in charge where a finger touches | Phones, tablets, kiosks; not with ordinary gloves |
| Resistive touchscreen | Two layers pressed together | Industrial use, gloves, stylus; tougher but less clear |
| Microphone (voice input) | Speech recognition software | Hands-free use, accessibility |
| Camera / scanner | Captures images; OCR turns text in images into editable text | Documents, ID checks, number-plate recognition |
| Barcode and QR code readers | Read printed codes | Shops, stock control, tickets |
| RFID / NFC | Reads tags by radio, without line of sight | Contactless payment, access cards, stock tracking |
| Biometric sensors | Fingerprint, face, iris | Secure, quick log-in |
| Sensors | Measure temperature, light, motion and more | Control and monitoring systems |
| Device | Suitable for |
|---|---|
| LCD / LED / OLED display | General output; OLED gives deep blacks and flexible screens |
| E-ink display | E-readers, shelf labels: readable in sunlight, very low power |
| Laser printer | Fast, high-volume text printing |
| Inkjet printer | Cheap to buy, good photo quality |
| 3D printer | Prototypes and models |
| Speakers / headphones | Sound, screen readers |
| Actuators (motors, valves) | Control systems |
| Haptic feedback | Vibration on phones, controllers, accessibility |
In an exam, always link the device to the situation: say why it suits that user or environment.
Secondary storage
| Magnetic hard disk (HDD) | Solid state drive (SSD) | Optical (Blu-ray, DVD) | Cloud storage | |
|---|---|---|---|---|
| How data is stored | Magnetised areas on spinning platters | Electric charge in flash memory cells | Pits and lands read by a laser | On the provider's servers |
| Speed | Slower; the read head has to move | Very fast, no moving parts | Slow | Depends on the connection |
| Capacity | Very high | High | Low | Effectively unlimited |
| Cost per GB | Low | Higher | Low per disc | Ongoing subscription |
| Durability | Can be damaged by knocks | Robust; cells wear out after many writes | Scratches | Depends on the provider |
| Typical use | Large archives, servers, backups | Laptops, phones, operating systems | Distributing films and software | Sharing, syncing, off-site backup |
Functional characteristics to compare: capacity, access speed, transfer rate, cost, portability, durability and reliability.
Fragmentation and defragmentation
A file is stored in blocks on a disk. When files are deleted, gaps are left. A new file may not fit in one gap, so it is split across several gaps in different places: the file is fragmented.
Consequences on a hard disk: to read a fragmented file the read/write head has to move to several places, so loading takes longer. The disk does more work and the free space is broken into small pieces.
Defragmentation reorganises the disk so each file's blocks are next to each other (contiguous) and the free space is gathered together. Files load faster afterwards.
SSDs should not be defragmented. They have no moving head, so access time is the same wherever the data is, and each extra write wears the flash cells. Instead the operating system uses the TRIM command to manage free space efficiently.
Networks and how they communicate
- LAN (local area network): covers one site, such as a school or office. The organisation owns the hardware.
- WAN (wide area network): covers a wide area, using infrastructure such as leased lines owned by telecoms companies. The internet is the largest WAN.
Client–server: a central server provides services (files, email, log-in) to client computers. Easier to manage, secure and back up, but the server is a single point of failure.
Peer-to-peer: every computer is equal and shares its resources directly. Cheap and simple, but harder to manage and secure.
| Hardware | Role |
|---|---|
| Network interface card (NIC) | Connects a device to the network; has a unique MAC address |
| Switch | Sends data only to the device it is addressed to, within a LAN |
| Router | Forwards packets between networks, using IP addresses |
| Wireless access point | Lets wireless devices join the network |
| Modem | Converts between digital data and the signal used on the line |
Devices communicate by splitting data into packets. Each packet carries addressing information, so it can be delivered and reassembled. Data transmission covers packets and routing in detail.
Standards and protocols
A standard is an agreed specification that many manufacturers follow, set by bodies such as the IEEE or IETF. A protocol is a set of rules for communication: the format of messages, how they are sent and how errors are handled.
Why they matter: devices and software from different manufacturers can work together, buyers aren't locked into one supplier, and products are cheaper and easier to develop.
| Protocol | Purpose |
|---|---|
| HTTP / HTTPS | Requesting and sending web pages; HTTPS encrypts the connection |
| FTP | Transferring files between computers |
| SMTP | Sending email, and passing it between mail servers |
| IMAP | Reading email that stays on the server, so it syncs across devices |
| POP3 | Downloading email to one device, usually removing it from the server |
| TCP | Splits data into packets, numbers them, checks they all arrive and asks for any missing ones to be sent again |
| IP | Addresses packets and routes them across networks |
| UDP | Sends packets without checking they arrive: faster, used for streaming, online games and voice calls |
| DHCP | Gives a device an IP address automatically when it joins a network |
| DNS | Turns domain names into IP addresses |
| Wi-Fi (IEEE 802.11) | Wireless local networks |
| Bluetooth | Short-range wireless links between devices |
TCP/IP is a stack of four layers, each with its own protocols: application (HTTP, SMTP), transport (TCP, UDP), internet (IP) and link (Ethernet, Wi-Fi). Each layer only deals with the layer above and below, so one layer can change without affecting the others.
Handshaking
Handshaking is the exchange of signals between two devices before data is sent, to check that both are ready and to agree the rules for the transfer, such as the speed, the protocol and the error checking.
TCP's three-way handshake sets up a connection:
- SYN: the client asks to connect.
- SYN-ACK: the server agrees and acknowledges.
- ACK: the client acknowledges, and data can flow.
Handshaking is also used between a computer and a device such as a printer: the printer signals when it is ready, busy or out of paper, so data is not sent faster than it can be handled.
The internet as global infrastructure
The internet is a worldwide network of networks. The World Wide Web is just one service that runs on it, alongside email, file transfer, streaming and more.
- Internet service providers (ISPs) connect homes and businesses.
- Backbone links: high-capacity fibre connections between major networks and countries, including undersea cables.
- Internet exchange points (IXPs): places where networks connect and swap traffic.
- Routers forward packets along the best available route; if a link fails, traffic goes another way.
- DNS servers turn names such as helloworld.org.uk into IP addresses.
- Data centres host servers for websites and cloud services.
No single organisation owns the internet. It works because every part follows the same protocols (TCP/IP).
A2Unit 4 · Computer Architecture, Data, Communication and Applications
Contemporary processor architecture
Modern processors build on Von Neumann with features that keep the processor busy:
- Multiple cores, each with its own L1 (and often L2) cache, sharing an L3 cache.
- Pipelining: fetch, decode and execute overlap, so ideally one instruction finishes every clock cycle. A branch can empty (flush) the pipeline, because the instructions already fetched may be the wrong ones.
- RISC and CISC:
| RISC (reduced instruction set) | CISC (complex instruction set) |
|---|---|
| Few, simple instructions, each usually one clock cycle | Many instructions, some doing several steps |
| Easier to pipeline; more instructions per program | Shorter programs; harder to pipeline |
| Lower power: phones and tablets (ARM) | Most desktops and laptops (x86) |
- GPUs with thousands of simple cores for SIMD work.
- System on a chip (SoC): processor, GPU, memory controller and more on one chip, as in phones.
Limits to parallelisation
Adding processors does not make every task faster in proportion:
- Sequential parts. Some steps depend on the result of the step before, so they cannot run at the same time. These set a hard limit.
- Overheads. Splitting the task, sending data to each processor and combining the results all take time.
- Synchronisation. Processors may have to wait for each other to reach the same point.
- Shared resources. Processors compete for the same memory, buses and cache, which can become a bottleneck.
- Program design. The program must be written to run in parallel, which is harder and can introduce new errors (such as two processors updating the same data at once).
Some tasks split very well, such as rendering separate frames, or applying a filter to separate parts of an image. Others hardly split at all, such as a calculation where each step needs the previous answer.
Calculating runtime with parallelisation
Split the task into the part that must run sequentially and the part that can run in parallel. Only the parallel part is shared between the processors:
new runtime = sequential time + (parallel time ÷ number of processors)
Example: a task takes 100 s on one processor; 80% of it can run in parallel. On 4 processors:
- Sequential part = 20% of 100 s = 20 s
- Parallel part = 80 s ÷ 4 = 20 s
- New runtime = 20 + 20 = 40 s
Speed-up = old runtime ÷ new runtime = 100 ÷ 40 = 2.5 times faster, not 4.
The limit (Amdahl's law): however many processors you add, the sequential 20 s remains. The best possible runtime is 20 s, so the maximum speed-up is 100 ÷ 20 = 5. In general, maximum speed-up = 1 ÷ (sequential fraction).
Evaluating the effect: doubling from 4 to 8 processors only cuts the runtime from 40 s to 30 s, and every extra processor adds cost and overheads. Past a point, more processors aren't worth it.
Assembly language
Assembly language uses short mnemonics in place of binary machine code. Each instruction usually becomes one machine code instruction. An assembler translates it.
Exam questions give you the instruction set to use, so read it carefully. Here is a typical accumulator-based set, used in the practice questions on this site:
| Instruction | Meaning |
|---|---|
| LDA #n | Load the number n into the accumulator |
| LDA a | Load the value stored at address a into the accumulator |
| STA a | Store the accumulator at address a |
| ADD #n / ADD a | Add the number n, or the value at address a, to the accumulator |
| SUB #n / SUB a | Subtract the number n, or the value at address a |
| BRZ label | Branch (jump) to label if the accumulator is zero |
| BRP label | Branch to label if the accumulator is zero or positive |
| BRA label | Always branch to label |
| HLT | Stop |
The # means immediate addressing: the number itself. Without it, the operand is an address: direct addressing.
Example: address 20 holds 7 and address 21 holds 5.
| Instruction | ACC | Address 22 |
|---|---|---|
| LDA 20 | 7 | |
| ADD 21 | 12 | |
| SUB #2 | 10 | |
| STA 22 | 10 | 10 |
| HLT |
How it is executed: the assembled program is loaded into memory. The processor runs it with the fetch–execute cycle: the program counter points at each instruction in turn, and a branch simply puts a new address into the program counter.
A loop that counts down from 3:
| Label | Instruction |
|---|---|
| LDA #3 | |
| loop | SUB #1 |
| BRP loop | |
| HLT |
This repeats SUB #1 until the accumulator goes below zero, then stops with −1 in the accumulator.
Voice input
| Type | How it works | Good for | Limitations |
|---|---|---|---|
| Command and control | Recognises a small, fixed set of spoken commands ("call home", "next slide") | Hands-free control: driving, operating theatres, machinery, people with limited movement | Only knows its commands; noise can trigger mistakes |
| Dictation (large vocabulary) | Turns continuous natural speech into text, using a large vocabulary and language models; may train to one speaker | Writing documents, notes and messages; accessibility for people who find typing difficult | Accents, background noise and specialist words cause errors; needs proofreading; less private in shared spaces |
| Voice print recognition | Identifies a person by the features of their voice (pitch, tone, rhythm), like a fingerprint | Security: telephone banking, phone log-in, alongside other checks | A cold or background noise can cause rejections; recordings and AI voice clones can fool weaker systems |
Suitability: command and control suits short tasks where hands are busy and the commands are predictable. Dictation suits longer text where typing is slow or impossible. Voice print recognition suits identifying callers remotely, but is safest as one factor of several.
Connecting portable devices to networks
Applications that need a portable device on a network:
- Delivery drivers and field engineers updating jobs and capturing signatures in real time
- Mobile banking, contactless payments and online shopping
- Navigation and live traffic information
- Health care staff reading and updating patient records at the bedside
- Smart watches and other wearables syncing data
- Collecting survey, scientific or stock-check data on site and sending it straight back
- Email, messaging, video calls and cloud file syncing on the move
Hardware for a wireless connection:
- A wireless network adapter in the device: a radio transmitter and receiver with an antenna (built into phones, tablets and laptops)
- A wireless access point or wireless router, connected to the wired network
- For mobile data, a SIM and a cellular modem in the device, and mast base stations run by mobile networks
How the connection is made (Wi-Fi): the access point broadcasts its network name (SSID). The device connects and is authenticated, usually with a password using WPA2 or WPA3, which also encrypt the traffic. DHCP then gives the device an IP address.
Contemporary wireless technologies:
| Technology | Range | Use |
|---|---|---|
| Wi-Fi 6 / 6E / 7 (IEEE 802.11ax / be) | Tens of metres | Home, office and public networks; faster and better with many devices |
| 4G and 5G mobile | Kilometres, via masts | Mobile data anywhere with coverage; 5G gives higher speed and lower delay |
| Bluetooth (including Low Energy) | About 10 m | Headphones, wearables, sensors |
| NFC | A few centimetres | Contactless payment, pairing devices |