Basic Components of a Computer System

Understanding the basic components of a computer is as important as understanding the engine, the gearbox, and the tyres of a car. Only once you know what each part is responsible for can you really understand how the machine works as a whole.

The Layered Structure of a Computer System

A computer system is not one undifferentiated whole but a complex system assembled from several layers.

Layered Computer System Architecture

A computer system adopts a layered design: from the hardware at the bottom to the applications at the top, every layer is built on the layer below it and provides a service to the layer above. This design makes the system more modular, easier to maintain, and easier to upgrade.

The Five Main Layers

Application Software LayerUsed directly by the user
System Software LayerDevelopment tools, databases
Operating System LayerResource management
Microprogram LevelInstruction implementation
Hardware LevelPhysical devices

1. The Hardware Level (the bottom layer)

Function:

  • Provides the basic physical devices
  • Performs the most elementary electronic operations
  • Implements the physical storage and transfer of data

Composition: physical devices such as the CPU, main memory, the hard disk, and the motherboard

2. The Microprogram Level

Function:

  • Decomposes machine instructions into more basic micro-operations
  • Controls how the hardware components work together
  • Provides the low-level support for instruction execution

Characteristic: invisible to programmers, implemented by the hardware designer

3. The Operating System Level

Function:

  • Manages hardware resources (CPU, memory, I/O devices)
  • Provides a user interface (command line, graphical shell)
  • Coordinates the execution of multiple programs

Examples: Windows, Linux, macOS

4. The System Software Level

Function:

  • Provides program development tools (compilers, debuggers)
  • Manages database systems
  • Implements network communication functions

Examples: the GCC compiler, the MySQL database, the network protocol stack

5. The Application Software Level (the top layer)

Function:

  • Serves the user directly
  • Implements a particular application function
  • Provides a friendly user interface

Examples: a browser, an office suite, a game

Imagine a machine without any layering:

  • Every application would have to drive the hardware directly, which makes the programs enormously complicated
  • Different programs would compete for the same hardware resources and clash
  • After a hardware upgrade, every program would have to be rewritten

A layered design works like the floors of a building:

  • The lower floors supply the foundation (hardware)
  • The middle floors supply the infrastructure (the operating system)
  • The upper floors supply the actual services (application software)

Each layer only has to care about its own responsibility and talks to the other layers through standard interfaces, which drastically reduces the complexity of the whole system.

The Von Neumann Architecture

The basic structure of the modern computer descends from the design idea proposed by John von Neumann in 1945.

Von Neumann Architecture

The core idea of the von Neumann architecture is the stored program: both program instructions and data are kept in the same memory, and the computer executes the instructions automatically in the order in which they are stored.

This apparently simple idea is the foundation of the modern computer!

The Five Components of the Von Neumann Architecture

ControllerDirects the work of the whole computer
ALUPerforms arithmetic and logic operations
MemoryStores programs and data
Bus
Connects all components
Input DevicesKeyboard, mouse, and more
Output DevicesMonitor, printer, and more

1. The Arithmetic Logic Unit (ALU)

Main functions:

  • Performs arithmetic operations: addition, subtraction, multiplication, division
  • Performs logical operations: AND, OR, NOT, XOR
  • Performs shift operations: left shift, right shift

Main composition:

  • Arithmetic logic unit: the circuits that actually perform the operations
  • Accumulator (ACC): holds the result of the operation
  • General-purpose registers: hold operands temporarily
  • Status register: holds the status of the operation (carry, overflow, zero flag, and so on)

A real example: the ALU of an Intel Core i9 processor can execute several operations at the same time, which is one reason modern CPUs are so fast!

2. The Controller

Main functions:

  • Fetches instructions from memory
  • Analyses what the instruction means (decoding)
  • Issues control signals that coordinate the work of all components
  • Controls the order in which the program executes

Main composition:

  • Program counter (PC): holds the address of the next instruction
  • Instruction register (IR): holds the instruction currently being executed
  • Instruction decoder: analyses the operation code and the operands of the instruction
  • Timing controller: produces the various timing signals

A useful analogy: the controller is like the conductor of an orchestra. It never plays an instrument itself (it performs no arithmetic), but it directs every player (every component) so that they work together.

3. Memory

Memory

Memory is used to hold programs and data. The key innovation of the von Neumann architecture is that programs and data are both kept in the same memory, which allows a computer to treat a program much as it treats data.

Primary storage (main memory):

RAM (Random Access Memory):

  • Readable and writable
  • Loses its contents when the power is cut (volatile)
  • Fast to access
  • Example: a DDR4 memory module

ROM (Read-Only Memory):

  • Can only be read, never written
  • Keeps its contents when the power is cut (non-volatile)
  • Stores firmware such as the BIOS

Cache:

  • Sits between the CPU and main memory
  • Extremely fast but very small
  • Modern CPUs have three levels of cache: L1, L2, and L3

Secondary storage (auxiliary storage):

  • Hard disk drive (HDD): mechanical structure, large capacity, comparatively slow
  • Solid state drive (SSD): no mechanical parts, fast, more expensive
  • Optical discs, USB flash drives, and the like

4. Input Devices

Function: converts external information into digital signals the computer can recognise

Common devices:

  • Keyboard: enters text and commands
  • Mouse: drives a graphical interface, pointing and selecting
  • Touchscreen: operated by direct touch
  • Scanner: converts paper documents into digital images
  • Camera: captures video signals
  • Microphone: captures audio signals
  • Sensors: measure physical quantities such as temperature, pressure, and light

5. Output Devices

Function: converts the results of the computer’s processing into a form a human can understand

Common devices:

  • Monitor: displays images and text
  • Printer: produces paper documents
  • Speakers: output sound
  • Projector: displays on a large screen
  • 3D printer: produces physical models

The Relationship Between Software and Hardware

Categories of Software Systems

System software:

  • Operating systems: Windows, Linux, macOS, Android, iOS
  • Compilers: translate a high-level language into machine language (GCC, Clang)
  • Database management systems: MySQL, PostgreSQL, MongoDB
  • Network software: the TCP/IP protocol stack, firewalls

Application software:

  • Office software: Microsoft Office, WPS
  • Graphics software: Photoshop, AutoCAD
  • Development tools: VS Code, IntelliJ IDEA
  • Entertainment software: games, music players, video players

How Software and Hardware Work Together

Instruction Set Architecture (ISA)

The ISA is the interface between software and hardware. It defines:

  • The format and the function of the instructions
  • The number and the purpose of the registers
  • The data types and the addressing modes

Common ISAs: x86 (Intel, AMD), ARM (phones, tablets), RISC-V (open source)

How software controls the hardware:

  1. A programmer writes the program in a high-level language (such as C or Python)
  2. The compiler translates the high-level language into assembly language
  3. The assembler translates the assembly language into machine code
  4. The CPU executes the machine code and drives the hardware

How the hardware supports the software:

  1. The CPU provides the ability to execute instructions
  2. Main memory provides storage for programs and data
  3. I/O devices implement the interaction between human and machine
  4. The bus implements communication between the components

The running speed of a program depends on several factors:

Hardware factors:

  • CPU clock frequency: the higher the frequency, the faster instructions execute
  • CPU architecture: different architectures have different efficiency
  • Amount of memory: too little memory forces frequent writes to the hard disk
  • Disk speed: an SSD is far faster than an HDD

Software factors:

  • Compiler optimisation: a good compiler generates more efficient code
  • Algorithm efficiency: the difference between O(n) and O(n²) is enormous
  • Operating system scheduling: how resources are allocated in a multitasking environment

An example: running the same Chrome browser:

  • on a machine with an i9 CPU, 32 GB of memory, and an SSD: it opens in a second
  • on an older dual-core machine with 4 GB of memory and an HDD: you may wait several seconds

This is exactly why a hardware upgrade can produce a striking improvement in performance!

Examples of Real Computer Systems

The Intel Core i9 Processor

Specifications (using the i9-13900K as an example):

  • Cores: 24 cores (8 performance cores + 16 efficiency cores)
  • Threads: 32 threads
  • Clock frequency: 3.0 GHz base, up to 5.8 GHz
  • Cache: L1 1.5 MB, L2 32 MB, L3 36 MB
  • Process: Intel 7 (roughly 10 nm)

Where the five components appear:

  • ALU: 24 cores, each with its own ALU
  • Controller: each core has an independent control unit
  • Memory: three levels of cache plus support for DDR5 memory
  • Input/output: the motherboard connects the various I/O devices

A Complete PC

A sample configuration:

  • CPU: Intel Core i7-13700K (controller + ALU)
  • Motherboard: ASUS ROG STRIX Z790 (connects all components)
  • Memory: 32 GB DDR5-6000 (memory unit)
  • Graphics card: NVIDIA RTX 4070 (a dedicated ALU)
  • Storage: 1 TB NVMe SSD (secondary storage)
  • Power supply: 750 W (supplies the power)
  • Case: cooling and protection

Input devices: keyboard, mouse, microphone Output devices: monitor, speakers

Exercises

Basic Exercises (1-5)

Exercise 1

Briefly describe the layered structure of a computer system and state the main function of each layer.

Layered ArchitectureSystem LayersVon Neumann

Approach: Work upward from the bottom of the stack, naming each layer, the responsibility it carries, and a representative example, then summarise the property that the layering buys.

Steps:

  1. Hardware level:
    • Provides the basic physical devices
    • Performs the most elementary electronic operations
    • Examples: CPU, main memory, hard disk
  2. Microprogram level:
    • Decomposes machine instructions into micro-operations
    • Coordinates the hardware components
    • Invisible to programmers
  3. Operating system level:
    • Manages hardware resources
    • Provides a user interface
    • Examples: Windows, Linux
  4. System software level:
    • Provides development tools
    • Manages databases
    • Examples: compilers, database systems
  5. Application software level:
    • Serves the user directly
    • Implements a specific function
    • Examples: a browser, an office suite

Answer: The layered structure of a computer system consists, from bottom to top, of the hardware level, the microprogram level, the operating system level, the system software level, and the application software level. Its advantages are modularity, ease of maintenance, extensibility, and portability.

Exercise 2

What are the five components of the von Neumann architecture, and what does each of them do?

Von NeumannFive ComponentsALUController

Approach: List the five components in the order in which the data flows through them and attach the one-line responsibility of each.

Steps:

  1. Arithmetic logic unit (ALU):
    • Performs arithmetic operations (addition, subtraction, multiplication, division)
    • Performs logical operations (AND, OR, NOT)
    • Performs shift operations
  2. Controller:
    • Fetches and decodes instructions
    • Issues control signals
    • Controls the order in which the program executes
  3. Memory:
    • Stores programs and data
    • Includes main memory (RAM/ROM) and secondary storage (hard disk)
    • Provides the read and write operations
  4. Input devices: convert external information into digital signals; examples: keyboard, mouse, scanner.
  5. Output devices: convert the computed results into a form a human can understand; examples: monitor, printer, speakers.

Answer: The five components are the arithmetic logic unit, the controller, memory, input devices, and output devices. The core idea behind them is the stored program: instructions and data share one memory, and the controller fetches and executes them in order.

Exercise 3

What is the stored-program principle, and why is it so important?

Stored ProgramProgram and DataVon Neumann

Approach: State the principle in one sentence, then list the four consequences that follow from it and the historical effect it had.

Steps:

  1. Automatic execution: once a program is loaded it needs no human intervention, and the computer executes the instructions in order.
  2. The program can be modified: because the program is stored in memory it can be patched, which even allows self-modifying programs.
  3. Generality: the same machine can run different programs, and switching tasks only means loading a different program into memory.
  4. Flexibility: programs and data are stored in the same way, so a program can be handled just like data.

Answer: The stored-program principle means that both program instructions and data are kept in the same memory and that the computer executes the instructions automatically in the order in which they are stored. It is historically decisive because it turned a special-purpose machine into a general-purpose one, and it remains the basis of every modern computer.

Exercise 4

Distinguish between primary storage and secondary storage, and give examples.

Primary MemorySecondary MemoryRAMCache

Approach: Compare the two kinds of storage on the same five axes (speed, capacity, price, volatility, and how the CPU reaches them), then explain why a machine needs both.

Steps:

  1. Primary storage (main memory):
    • Fast
    • Smaller capacity
    • More expensive per byte
    • Volatile (lost when the power is cut)
    • Directly accessible by the CPU
    • Examples: RAM (DDR4 and DDR5 modules), ROM (the BIOS chip), and cache (the L1/L2/L3 levels)
  2. Secondary storage (auxiliary storage):
    • Slower
    • Large capacity
    • Cheaper per byte
    • Non-volatile (retains data when the power is cut)
    • Not directly accessible by the CPU, so the data has to be loaded into main memory first
    • Examples: a mechanical hard disk (HDD), a solid state drive (SSD), and USB flash drives or optical discs
  3. Why both are needed:
    • Primary memory is fast but expensive, so it holds the program and data currently in use
    • Secondary storage is large but slow, so it holds data over the long term
    • The two together balance speed against capacity

Answer: Primary storage is fast, small, expensive, volatile, and directly reachable by the CPU (RAM, ROM, cache), while secondary storage is slow, large, cheap, non-volatile, and reached only by loading into main memory (HDD, SSD, flash drives). A practical computer needs both, because neither the speed of primary memory nor the capacity of secondary storage is available anywhere else.

Exercise 5

What is an ISA (Instruction Set Architecture), and what is its role?

ISAInstruction SetHardware Interface

Approach: Define the ISA as an interface, enumerate what it fixes down, and then spell out the three consequences of having one.

Steps:

  1. Definition: the interface between software and hardware; it fixes the instruction formats, their functions, and the way they are executed.
  2. What it contains:
    • (a) Instruction format — how instructions are encoded
    • (b) Instruction function — what each instruction does
    • (c) Registers — how many, how wide, and what they are for
    • (d) Data types — which formats are supported
    • (e) Addressing modes — how an operand is located
  3. Its role:
    • (a) As the software/hardware interface, software is written to the ISA and hardware executes to the ISA
    • (b) As a compatibility guarantee, different CPUs that implement the same ISA run the same programs — every x86 CPU can run Windows
    • (c) As a standard, it lets hardware and software evolve independently, so a hardware upgrade does not break the software

Answer: An ISA is the interface between software and hardware that defines a processor’s instruction formats, its registers, its data types, and its addressing modes. It exists so that software written to it stays portable across implementations and so that hardware can be replaced without rewriting the programs.

Advanced Exercises (6-10)

Exercise 6

Why do modern CPUs have a multi-level cache (L1/L2/L3)?

Cache HierarchyL1 L2 L3Locality of Reference

Approach: Justify the cache from three directions — the raw speed gap, the principle of locality that makes caching worthwhile, and the way the levels are tuned — then show the effect and give a concrete analogy.

Steps:

  1. The speed gap: the CPU runs at 3-5 GHz, while a main memory access takes 10-100 ns; without a cache the processor would spend most of its time waiting.
  2. The principle of locality: temporal locality means data that was just accessed is likely to be accessed again, and spatial locality means nearby data is likely to be accessed next.
  3. The levels:
    • L1 is the fastest (1-2 clock cycles) and the smallest (32-64 KB), and is private to each core
    • L2 is faster (10-20 cycles) and larger (256 KB to 1 MB)
    • L3 is the slowest (30-50 cycles) and the largest (8-36 MB), and is shared by all cores
  4. The effect: with a hit rate above 90%, the average access time is close to that of L1, which lifts overall CPU performance dramatically.
  5. An analogy: your desk (L1), a bookshelf (L2), a library (L3), and an online bookstore (main memory) — the books you use often sit on the desk, the ones you use now and then sit on the shelf, the rare ones need a trip to the library, and only what is unavailable has to be bought.

Answer: Modern CPUs use a multi-level cache because processor speed has far outrun memory speed, because locality of reference makes caching effective, and because splitting the cache into levels lets each one trade capacity against latency optimally. The result is an average access time close to L1 while still backing a working set far larger than the cache itself.

Exercise 7

Compare the characteristics of the CISC and RISC instruction set architectures.

CISCRISCInstruction Set

Approach: Treat each architecture as a set of choices with a payoff and a cost, and finish with the state of the art.

Steps:

  1. CISC (Complex Instruction Set Computer):
    • Many instructions (hundreds)
    • Powerful instructions that accomplish complex operations in one step
    • Variable instruction length
    • Many addressing modes
    • Advantages: short code, simpler compilers, good compatibility
    • Disadvantages: complex hardware, inconsistent instruction timing, low pipeline efficiency
    • Representatives: Intel x86, x86-64
  2. RISC (Reduced Instruction Set Computer):
    • Few instructions (tens)
    • Simple instructions
    • Fixed instruction length
    • Simple addressing modes
    • Advantages: simple hardware, uniform instruction timing, high pipeline efficiency, low power consumption
    • Disadvantages: longer code, more complex compilers
    • Representatives: ARM, RISC-V, MIPS
  3. The present state: modern processors are mostly hybrid — CISC on the outside for compatibility, translated internally into RISC-like micro-operations for performance.

Answer: CISC buys code density and compatibility with a large instruction repertoire at the cost of complex decoding and uneven timing, while RISC buys simple, uniform, pipeline-friendly execution at the cost of code length and compiler complexity. Modern designs claim both sides of the trade-off by exposing a CISC interface and executing a RISC core.

Exercise 8

Explain what the “von Neumann bottleneck” is and how it is mitigated.

Von Neumann BottleneckBus BandwidthHarvard Architecture

Approach: Define the bottleneck, show its two concrete symptoms, and then list the mitigations with the mechanism each one uses.

Steps:

  1. Definition: because instructions and data share one memory and travel over one bus, the transfer of data between the CPU and memory becomes the performance bottleneck.
  2. Symptom one, bus bandwidth: the CPU runs far faster than memory, so the bus saturates.
  3. Symptom two, instruction and data conflict: fetching an instruction and fetching a data item compete for the bus and cannot proceed at the same time.
  4. Mitigations:
    • (a) Cache technology, a fast cache between the CPU and memory that reduces the number of main memory accesses
    • (b) The Harvard architecture, separate stores and separate buses for instructions and data so both can be fetched at once
    • (c) Pipelining, which splits instruction execution into stages so several instructions are in flight
    • (d) A multi-level memory system of registers, L1/L2/L3 cache, main memory, and disk that balances speed against capacity
    • (e) Prefetching, which predicts the data that will be needed and loads it into the cache early
    • (f) More bus bandwidth, a wider data bus and a higher bus frequency, which is why DDR5 is faster than DDR4
  5. The modern solution: a modern CPU combines all of the above and greatly reduces the bottleneck.

Answer: The von Neumann bottleneck is the contention that arises when instructions and data share a single memory and a single bus, so that the CPU-to-memory transfer, rather than the CPU itself, sets the pace. It is mitigated by caches, the Harvard separation of instruction and data paths, pipelining, multi-level memory, prefetching, and wider or faster buses — techniques a modern processor uses together.

Exercise 9

A computer is configured with an Intel i7-12700K CPU, 32 GB of DDR5 memory, and a 1 TB NVMe SSD. Analyse which of the five components each part of this machine provides.

Five ComponentsIntel Core i7Memory Hierarchy

Approach: Map every part of the specification onto one of the five components, then assess what the resulting machine is good at.

Steps:

  1. ALU: the ALUs inside the Intel i7-12700K — 12 cores (8 performance cores plus 4 efficiency cores), each core with its own ALU, supporting the AVX-512 instruction set for advanced arithmetic.
  2. Controller: the control units inside the same CPU — one controller per core, responsible for fetching, decoding, and issuing control signals, with hyper-threading giving 20 threads.
  3. Memory:
    • Primary storage of 32 GB DDR5 at DDR5-4800 or better (volatile)
    • Cache built into the CPU at roughly 1 MB of L1, 12 MB of L2, and 25 MB of L3
    • Secondary storage of a 1 TB NVMe SSD reading and writing at 3000-7000 MB/s (non-volatile)
  4. Input devices: not listed in the configuration; the usual ones are a keyboard, a mouse, a microphone, and a camera.
  5. Output devices: not listed either; the usual ones are a monitor, speakers, and a printer.
  6. Performance assessment: a high-end PC suited to gaming (with a discrete GPU added), video editing, 3D rendering, and software development.

Answer: The CPU package supplies both the arithmetic logic units and the controllers, the 32 GB DDR5 module and the on-chip cache supply the memory hierarchy together with the NVMe SSD, and the peripherals not listed would provide the input and output functions. Together they make a machine whose strength is general-purpose compute rather than any single workload.

Exercise 10

Why is it said that “programs and data are essentially the same”? What are the practical applications of this idea?

Stored ProgramProgram and DataSelf-Modifying Code

Approach: Answer the “why” with the four shared properties, then show where the idea is exploited deliberately and where it turns into a security problem.

Steps:

  1. Same storage form:
    • Programs and data are both stored in binary
    • Both live in the same memory
    • Both can be read and modified
    • The CPU cannot tell them apart by form alone
  2. Mutual convertibility: a program can be read and patched as if it were data, and data can be executed as if it were a program.
  3. Uniform handling: both can be loaded into memory, processed by the CPU, and written back to disk.
  4. Deliberate applications:
    • Compilers read source code (data) and emit an executable (program)
    • JIT compilers turn code (data) into machine code (program) at run time
    • Dynamic loading turns a plugin (data) into a program
    • Self-modifying code rewrites its own instructions
  5. Security consequences:
    • Viruses disguise themselves as data files and become malicious code once executed
    • Buffer overflows let data overwrite program code
    • Code injection writes malicious code into a data area and then runs it
  6. Virtual machines: a virtual machine treats a program as data in order to emulate a program written for another platform.

Answer: Programs and data are essentially the same because both are bit patterns stored in the same memory and processed by the same unit, so the CPU itself cannot distinguish them. The concept is what makes compilers, JIT compilation, dynamic loading, and virtual machines possible — and it is exactly why modern operating systems must mark memory regions as executable or not.


Found an issue with this content?

Tell us what could be improved.