Fundamentals of Computer Systems
Hardware Components
Section titled “Hardware Components”Central Processing Unit (CPU)
Section titled “Central Processing Unit (CPU)”The CPU is the primary component that executes instructions. It consists of three main Sub-components:
| Component | Function |
|---|---|
| Arithmetic Logic Unit (ALU) | Performs arithmetic (add, subtract, multiply, divide) and logical (AND, OR, NOT, XOR) operations |
| Control Unit (CU) | Coordinates all activities: fetches instructions, decodes them, and signals other components to execute |
| Registers | Small, extremely fast storage locations inside the CPU used for temporary data during processing |
Registers
Section titled “Registers”| Register | Purpose |
|---|---|
| Program Counter (PC) | Holds the memory address of the next instruction to be fetched |
| Memory Address Register (MAR) | Holds the address in memory to be read from or written to |
| Memory Data Register (MDR) | Holds data that has been read from or is about to be written to memory |
| Accumulator (ACC) | Stores the results of ALU operations |
| Instruction Register (IR) | Holds the current instruction being decoded and executed |
| Status Register (Flags) | Stores flags such as Zero, Carry, Negative, Overflow from ALU operations |
Memory Types
Section titled “Memory Types”| Type | Full Name | Volatile? | Read/Write | Speed | Typical Use |
|---|---|---|---|---|---|
| RAM | Random Access Memory | Yes | Both | Fast | Main memory, running programs |
| ROM | Read Only Memory | No | Read only | Slower than RAM | Boot-up instructions (BIOS/UEFI), firmware |
RAM types:
- SRAM (Static RAM): Uses flip-flop circuits. Faster, more expensive. Used for CPU cache (L1, L2, L3).
- DRAM (Dynamic RAM): Uses capacitors. Slower, cheaper, needs refreshing. Used as main memory.
ROM types:
- PROM: Programmable once by the user.
- EPROM: Erasable using UV light, reprogrammable.
- EEPROM: Electrically erasable and reprogrammable.
Secondary Storage
Section titled “Secondary Storage”| Storage Type | Technology | Speed | Capacity | Cost | Volatility |
|---|---|---|---|---|---|
| HDD | Magnetic platters spinning at 5400/7200/10000 RPM | 80—160 MB/s | 500 GB — 20 TB | Low | Non-volatile |
| SSD | NAND flash memory via SATA/NVMe | 500 MB/s — 7 GB/s (NVMe) | 256 GB — 4 TB | Medium-High | Non-volatile |
| Flash Memory | NAND flash (USB drives, SD cards) | 10—300 MB/s | 1 GB — 1 TB | Medium | Non-volatile |
Input Devices
Section titled “Input Devices”| Device | Input Type | Common Use Case |
|---|---|---|
| Keyboard | Text, commands | Typing documents, entering data |
| Mouse | Pointing, clicking | GUI navigation, selecting objects |
| Scanner | Image, document capture | Digitising photos, OCR (Optical Character Recognition) |
| Microphone | Audio/sound input | Voice recording, voice commands |
| Camera / Webcam | Image, video capture | Video conferencing, photography |
| Touchscreen | Touch gestures | Mobile devices, kiosks, POS systems |
| Barcode Reader | Light reflection pattern | Retail checkout, inventory management |
| RFID Reader | Radio frequency signal | Access control, toll collection, tracking |
Barcode Reader vs RFID:
| Feature | Barcode Reader | RFID Reader |
|---|---|---|
| Line of sight required | Yes | No |
| Read range | Short (contact to ~30 cm) | Up to several metres |
| Data capacity | Limited ( a number) | Can store more data |
| Cost | Lower | Higher |
| Read multiple at once | No | Yes |
Output Devices
Section titled “Output Devices”| Device | Output Type | Common Use Case |
|---|---|---|
| Monitor | Visual display | Primary output for desktops/laptops |
| Printer | Hard copy (paper) | Inkjet (photo quality), Laser (high volume, fast) |
| Speaker | Audio output | Music, alerts, multimedia |
| Projector | Large visual display | Presentations, classrooms, cinemas |
Inkjet vs Laser Printer:
| Feature | Inkjet | Laser |
|---|---|---|
| Speed | Slower | Faster |
| Print quality (text) | Good | Excellent |
| Print quality (photos) | Better | Good |
| Cost per page | Higher | Lower |
| Initial cost | Lower | Higher |
| Mechanism | Sprays liquid ink | Uses toner powder, heat |
Von Neumann Architecture
Section titled “Von Neumann Architecture”The Von Neumann architecture defines a computer system with:
- Single shared memory for both instructions and data (stored-program concept).
- CPU consisting of ALU, CU, and registers.
- System bus connecting CPU, memory, and I/O devices.
+---------+ | CPU | | +-----+ | | | CU | | | +-----+ | | | ALU | | | +-----+ | | |Regs | | | +-----+ | +----+----+ | System Bus | +----+----+ | Memory | | (RAM + | | ROM) | +---------+ | System Bus | +----+----+ | I/O | | Devices | +---------+Key principles:
- Instructions and data are stored in the same memory.
- Memory is addressed linearly.
- Instructions are executed sequentially unless a branch/jump instruction changes the flow.
Harvard Architecture (Comparison)
Section titled “Harvard Architecture (Comparison)”| Feature | Von Neumann | Harvard |
|---|---|---|
| Memory bus | Single shared bus | Separate instruction and data buses |
| Memory | One memory for both | Separate memories for instructions and data |
| Speed bottleneck | Yes (bus contention) | No (parallel fetch) |
| Complexity | Simpler | More complex |
| Modern usage | Most general-purpose CPUs | DSPs, microcontrollers, CPU caches |
The Von Neumann bottleneck arises because the CPU and memory share a single bus. The CPU is Often much faster than memory, so it spends time waiting for instructions and data to be fetched. This is why modern CPUs use cache memory (L1, L2, L3) to reduce the impact of the bottleneck.
Cache memory is a small, fast memory between the CPU registers and main memory (RAM):
| Cache Level | Location | Size | Speed |
|---|---|---|---|
| L1 | Inside CPU core | 32—128 KB | Fastest (~1 cycle) |
| L2 | Inside CPU (per core or shared) | 256 KB — 1 MB | Fast (~10 cycles) |
| L3 | Inside CPU (shared among all cores) | 2—64 MB | Moderate (~40 cycles) |
| RAM | Outside CPU on motherboard | 4—128 GB | Slowest (~100+ cycles) |
When the CPU needs data, it checks L1 first, then L2, then L3, then RAM. If the data is found in Cache, it is a cache hit; otherwise it is a cache miss and the CPU must wait for the slower Memory.
The Fetch-Decode-Execute Cycle
Section titled “The Fetch-Decode-Execute Cycle”This is the fundamental cycle by which the CPU processes every instruction.
Step-by-step
Section titled “Step-by-step”- Fetch:
- PC holds the address of the next instruction.
- Address is copied from PC to MAR.
- Instruction is fetched from memory address in MAR into MDR.
- PC is incremented to point to the next instruction.
- Instruction in MDR is copied to IR.
- Decode:
- CU decodes the instruction in IR.
- The CU determines which operation to perform and which operands are needed.
- Execute:
- The instruction is executed (ALU performs calculations, data is moved, etc.).
- Results are stored in the accumulator or written back to memory.
- Status flags are updated as needed.
- Cycle repeats from step 1.
Example Trace
Section titled “Example Trace”Given memory starting at address 100:
| Address | Instruction |
|---|---|
| 100 | LOAD 5 |
| 101 | ADD 3 |
| 102 | STORE 6 |
Execution trace:
| Step | Action | PC | MAR | MDR | IR | ACC |
|---|---|---|---|---|---|---|
| Fetch | PC(100) -> MAR; Mem[MAR] -> MDR; PC = 101; MDR -> IR | 101 | 100 | LOAD 5 | LOAD 5 | ? |
| Decode | CU decodes LOAD 5 | 101 | 100 | LOAD 5 | LOAD 5 | ? |
| Execute | Mem[5] -> ACC | 101 | 100 | LOAD 5 | LOAD 5 | M[5] |
| Fetch | PC(101) -> MAR; Mem[MAR] -> MDR; PC = 102; MDR -> IR | 102 | 101 | ADD 3 | ADD 3 | M[5] |
| Decode | CU decodes ADD 3 | 102 | 101 | ADD 3 | ADD 3 | M[5] |
| Execute | ACC = ACC + Mem[3] | 102 | 101 | ADD 3 | ADD 3 | M[5]+M[3] |
| Fetch | PC(102) -> MAR; Mem[MAR] -> MDR; PC = 103; MDR -> IR | 103 | 102 | STORE 6 | STORE 6 | M[5]+M[3] |
| Decode | CU decodes STORE 6 | 103 | 102 | STORE 6 | STORE 6 | M[5]+M[3] |
| Execute | ACC -> Mem[6] | 103 | 102 | STORE 6 | STORE 6 | M[5]+M[3] |
Software Types
Section titled “Software Types”System Software
Section titled “System Software”Software that manages and controls hardware and provides a platform for application software.
| Type | Description | Examples |
|---|---|---|
| Operating System (OS) | Manages all hardware and software resources | Windows, macOS, Linux, Android, iOS |
| Utility Programs | Perform specific maintenance tasks | Disk defragmenter, antivirus, file manager, backup tool |
Application Software
Section titled “Application Software”Software designed for end-users to perform specific tasks.
| Type | Description | Examples |
|---|---|---|
| General-purpose | Widely used across many domains | Word processors, spreadsheets, web browsers |
| Special-purpose | Designed for a specific field | Accounting software, CAD, medical imaging |
| Custom/bespoke | Written for a specific organisation | A company”s payroll system |
Operating System Functions
Section titled “Operating System Functions”| Function | Description |
|---|---|
| Memory Management | Allocates and deallocates memory space, uses virtual memory (swap space on disk to extend RAM), manages paging and segmentation |
| Process Management | Schedules CPU time among processes, handles multitasking (time-sharing), manages process creation and termination |
| File Management | Organises files in directories/folders, handles file naming, access control, and storage allocation |
| User Interface | Provides CLI (Command Line Interface) or GUI (Graphical User Interface) for user interaction |
| Device Management | Uses device drivers to communicate with hardware, manages I/O operations |
| Security | User authentication, access control, firewall integration |
Types of User Interfaces
Section titled “Types of User Interfaces”Command Line Interface (CLI):
- User types commands using a keyboard.
- Requires memorisation of commands and syntax.
- Efficient for experienced users; supports scripting and automation.
- Examples: Windows Command Prompt, Linux bash, macOS Terminal.
Graphical User Interface (GUI):
- Users interact with visual elements (windows, icons, menus, buttons).
- Intuitive and easy to learn; does not require memorising commands.
- Uses pointing devices (mouse, touchscreen).
- Consumes more system resources than CLI.
- Examples: Windows Explorer, macOS Finder, Android/iOS home screens.
Menu-Driven Interface:
- User selects options from a predefined list of menus.
- Common in ATMs, self-service kiosks, and embedded systems.
- Limited flexibility but very easy to use for specific tasks.
Virtual Memory
Section titled “Virtual Memory”Virtual memory is a memory management technique that uses secondary storage (hard disk/SSD) as an Extension of RAM. When physical RAM is full, the operating system moves less frequently used pages (data blocks, 4 KB) from RAM to a designated area on disk called the swap space or page file. When those pages are needed again, they are swapped back into RAM.
| Aspect | Advantage | Disadvantage |
|---|---|---|
| Capacity | Allows running more/larger programs than physical RAM alone | Disk access is much slower than RAM (thousands of times slower) |
| Cost | Effectively increases memory without buying more RAM | Excessive swapping (thrashing) severely degrades performance |
| Implementation | Transparent to the user and applications | Requires disk space to be reserved |
Thrashing occurs when the system spends more time swapping pages in and out of memory than Executing actual instructions. This happens when the system is overloaded with too many processes Competing for insufficient RAM.
Number Systems
Section titled “Number Systems”Binary (Base 2)
Section titled “Binary (Base 2)”Digits: 0, 1. Each digit is a bit. 8 bits = 1 byte.
| Decimal | Binary |
|---|---|
| 0 | 0000 0000 |
| 1 | 0000 0001 |
| 2 | 0000 0010 |
| 5 | 0000 0101 |
| 10 | 0000 1010 |
| 255 | 1111 1111 |
Hexadecimal (Base 16)
Section titled “Hexadecimal (Base 16)”Digits: 0—9, A(10), B(11), C(12), D(13), E(14), F(15). Each hex digit represents exactly 4 bits.
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| F | 1111 | 15 |
| 10 | 0001 0000 | 16 |
| FF | 1111 1111 | 255 |
| 100 | 0001 0000 0000 | 256 |
Binary-Coded Decimal (BCD)
Section titled “Binary-Coded Decimal (BCD)”Each decimal digit (0—9) is represented by its 4-bit binary equivalent.
| Decimal | BCD |
|---|---|
| 0 | 0000 |
| 9 | 1001 |
| 15 | 0001 0101 |
| 127 | 0001 0010 0111 |
Conversions
Section titled “Conversions”Decimal to Binary: Repeatedly divide by 2, record remainders from bottom to top.
Decimal to Hexadecimal: Repeatedly divide by 16, record remainders.
Binary to Hexadecimal: Group bits in groups of 4 from the right, convert each group.
Hexadecimal to Binary: Replace each hex digit with its 4-bit binary equivalent.
Decimal to BCD: Replace each decimal digit with its 4-bit binary equivalent.
Worked Example: Decimal 185 to Binary, Hex, and BCD
To binary:
R R R R R R R R
Reading remainders from bottom to top:
To hexadecimal:
R . . So
To BCD:
Data Representation
Section titled “Data Representation”Text Representation
Section titled “Text Representation”ASCII (American Standard Code for Information Interchange)
Section titled “ASCII (American Standard Code for Information Interchange)”- 7-bit code, extended to 8-bit (Extended ASCII).
- Represents 128 characters (0—127): uppercase letters (65—90), lowercase letters (97—122), digits (48—57), control characters (0—31), symbols.
- Each character stored as 1 byte (8 bits) with the MSB unused or used for parity.
| Character | ASCII (decimal) | ASCII (binary) |
|---|---|---|
| ‘A’ | 65 | 0100 0001 |
| ’Z’ | 90 | 0101 1010 |
| ’a’ | 97 | 0110 0001 |
| ’0’ | 48 | 0011 0000 |
| Space | 32 | 0010 0000 |
Unicode
Section titled “Unicode”- Supports characters from all languages, symbols, and emoji.
- UTF-8 encoding: variable-length (1—4 bytes). Backward-compatible with ASCII (first 128 characters identical).
- UTF-16: 2 or 4 bytes per character.
- UTF-32: fixed 4 bytes per character.