Unable to open this exercise
Common exam pitfall
Students often confuse virtual memory with cache memory.
The Central Processing Unit (CPU) is built to execute instructions at lightning speed. However, it can only directly access data located in primary memory (also known as immediate access storage). Primary memory resides on the computer motherboard directly connected to the CPU system buses.
Learning Objectives
- Compare and contrast Random Access Memory (RAM) and Read-Only Memory (ROM).
- Define and distinguish between volatile and non-volatile storage.
- Differentiate between Dynamic RAM (DRAM) and Static RAM (SRAM).
- Explain the operation, necessity, and risks of Virtual Memory and Disk Thrashing.
1. Random Access Memory (RAM)
Random Access Memory (RAM) is the computer's temporary high-speed working memory:
- Volatile: RAM requires continuous electrical power to maintain its state. When the computer is turned off or suffers a power cut, all contents stored in RAM are lost immediately.
- Read and Write: The CPU can both read data from RAM and write new data to RAM at any time.
- Contents: Stores the operating system kernel, currently running application programs, and open user files and variables.
- Random Access: Any memory address in RAM can be read from or written to in the exact same amount of time, regardless of where the address is physically located.
Optional extension: DRAM vs SRAM
RAM is manufactured in two primary varieties:
Feature | Dynamic RAM (DRAM) | Static RAM (SRAM) |
|---|---|---|
Circuit Design | 1 transistor + 1 microscopic capacitor per bit. | 4 to 6 transistors forming a flip-flop circuit per bit. |
Refresh Need | Capacitors leak charge; must be refreshed thousands of times per second. | Does not require refreshing while power is supplied. |
Access Speed | Slower access times ($\sim 10-20\text{ ns}$). | Extremely fast access times ($\sim 1\text{ ns}$). |
Cost & Density | Inexpensive, high storage density (billions of bits per chip). | Expensive, lower storage density per chip. |
Usage | Main system memory (e.g. 8 GiB, 16 GiB RAM sticks). | High-speed CPU Cache memory (L1, L2, L3 cache). |
2. Read-Only Memory (ROM)
Read-Only Memory (ROM) is permanent semiconductor memory:
- Non-Volatile: Does not require power to preserve data. When the computer is turned off, the contents of ROM remain intact indefinitely.
- Read-Only: Once programmed at the factory, data in ROM cannot be altered or overwritten during normal computer operation.
- Contents: Stores the bootstrap loader—the startup program and basic input/output firmware (BIOS / UEFI) executed the moment the power button is pressed.
- Runs hardware diagnostic checks (POST - Power-On Self-Test) to verify RAM, keyboard, and graphics card.
- Locates the operating system kernel on secondary storage (SSD/HDD) and loads it into RAM.
Summary Comparison: RAM vs ROM
Attribute | Random Access Memory (RAM) | Read-Only Memory (ROM) |
|---|---|---|
Volatility | Volatile (data lost when powered down). | Non-Volatile (data permanently retained). |
Read / Write | Read and Write. | Read-Only. |
Typical Capacity | $8\text{ GiB} - 64\text{ GiB}$. | $4\text{ MiB} - 32\text{ MiB}$. |
Typical Contents | Active OS, open applications, user variables. | BIOS/UEFI firmware, bootstrap startup code. |
Can be altered? | Yes, constantly modified by CPU. | No, fixed at manufacture or updated via flashing. |
3. Virtual Memory & Disk Thrashing
When a computer runs multiple heavy programs simultaneously (e.g. video editor, web browser with 30 tabs, game), the total memory required may exceed the capacity of installed physical RAM.
How Virtual Memory Works:
- Extension of RAM: The operating system allocates a dedicated partition of secondary storage (SSD or HDD), called a swap file or paging file, to serve as virtual memory.
- Paging:
- Both physical RAM and virtual memory are divided into equal-sized chunks called pages (typically 4 KiB each).
- The OS memory management unit tracks which pages are actively in use and which pages belong to background or idle applications.
- Swapping:
- When RAM becomes full and a new program requires memory, the OS identifies inactive pages in RAM and copies them out to secondary storage (page out).
- The freed physical RAM space is immediately allocated to the active application.
- When the user switches back to the background application, the OS swaps out other idle data and copies the needed pages back from secondary storage into RAM (page in).
+---------------------------+ Page Out (Inactive data) +---------------------------+
| PHYSICAL RAM (Full) | -----------------------------------> | VIRTUAL MEMORY |
| Active Apps | Idle Apps | | (Swap file on SSD/HDD) |
| | <----------------------------------- | |
+---------------------------+ Page In (When app resumed) +---------------------------+
The Problem of Disk Thrashing:
- Secondary storage (even fast NVMe SSDs) is hundreds to thousands of times slower than physical DRAM.
- If physical RAM is severely undersized for the current workload, the operating system spends more time constantly reading and writing memory pages back and forth between disk and RAM than actually executing application instructions.
- This condition is called disk thrashing. The computer freezes, disk activity lights remain solid on, and responsiveness slows to an unbearable crawl.
- Solution: The only permanent fix is installing more physical RAM or closing memory-intensive applications.
Written practice and self-review
A user attempts to run several demanding software applications simultaneously on a computer with only 4 GiB of physical RAM.
- Explain how the operating system utilizes virtual memory to allow programs to continue running even though their combined memory requirements exceed 4 GiB.
- Explain what causes disk thrashing and describe its effect on system responsiveness.
Write an explanation before checking the theory. Check that each claim answers the question, uses the correct concept and explains why it applies. Discuss uncertain points with a teacher. The structured exercise below checks specific facts; it does not automatically mark this explanation.
AI Socratic Tutor
Need guidance? Ask a question or use the hint below.
AI Socratic Tutor is an All-Access Benefit
Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.
You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.
Exam-Style Question: Primary Memory Terms & Classifications
Complete each statement regarding primary storage:
- Memory that loses all stored binary data when computer power is removed is described as [Space 1].
- The non-volatile semiconductor memory that permanently stores the bootstrap loader / BIOS firmware is [Space 2].
- When physical RAM is fully occupied, the operating system allocates a portion of secondary storage as [Space 3] memory.
Interactive exercises for Module 2 and beyond require an active plan.