Chapter 1 · Operating Systems: Structure and Services
1.4Memory
What RAM does, how virtual memory helps when RAM is full, and why virtual memory makes the computer slower.
Written and checked by Muhammad Raheel(opens in a new tab)
Full Stack Developer · AI Engineer · Reviewed 6 Oct 2026 · 3 min read
On this page
The CPU needs a place to keep the data and instructions it is working on. That place is memory. It lets the CPU get information quickly while a program runs. In this topic you will meet two kinds: primary memory (RAM) and virtual memory.
Primary Memory (RAM)
RAM is the computer's main working area. It is very fast. But it only keeps data for a short time, so we call it temporary. When you switch off the computer, everything in RAM is lost.
Virtual Memory
RAM has a limit. What happens when it is full? The OS borrows some space from the storage drive and uses it as extra RAM. This borrowed space is called virtual memory. The storage drive can be a hard drive, a solid-state drive (SSD) or a Non-Volatile Memory Express (NVMe) drive.
With virtual memory, you can run more programs at the same time. But there is a cost. Storage drives move data more slowly than RAM. They also take longer to reach the data. So when the OS uses virtual memory, the whole system can become slower.
Suppose you have many programs open. The OS may move data from the programs you are not using right now into virtual memory. This frees space in RAM for the programs you are actively using. The downside: those less active programs may respond more slowly when you go back to them.
RAM vs Virtual Memory
| RAM | Virtual Memory | |
|---|---|---|
| What it is | Main working area of the computer | Part of the storage drive used as extra RAM |
| Speed | Fast | Slower |
| When it is used | Always, for running programs | When RAM is full |
| Effect | Programs run quickly | More programs can run, but performance drops |
Practice this topic
Short questions
1.Why is virtual memory slower than RAM?2 marks
Answer
From the book: virtual memory is "part of the computer's storage drive (like Hard drives, solid-state drives (SSD), or Non-Volatile Memory Express (NVMe))". "Storage drives operate at lower data transfer speeds and have higher access times as compared to RAM; that's why the use of virtual memory can result in reduced system performance."
2.Define Memory in a computer system.2 marks
Answer
Memory is a fundamental component of a computer system, used to store data and instructions required for processing. It ensures that the CPU can access information quickly during program execution.
3.Define Primary Memory (RAM).3 marks
Answer
Primary memory, also called Random Access Memory (RAM), is the main working area of a computer. It is a fast storage area where the computer keeps the data and instructions temporarily. Its data is erased when the computer is turned off.
4.Give one example of RAM in use, based on the book.2 marks
Answer
When you open a Word document, the computer quickly places the program and the document into RAM so the CPU can work on them right away.
5.Define Virtual Memory.3 marks
Answer
When the RAM is full, the operating system uses part of the computer's storage drive (like Hard drives, solid-state drives (SSD), or Non-Volatile Memory Express (NVMe)) as virtual memory. This extra space acts like temporary RAM, allowing more programs to run at the same time.
6.How does the operating system manage memory when several programs are open at the same time?3 marks
Answer
When several programs are open simultaneously, the operating system may transfer data from less active programs to virtual memory. This frees up space in RAM for the programs you are currently using, but may make those fewer active programs slower to respond.
Long questions
1.Differentiate between RAM and virtual memory, and explain how multithreading improves performance.8 marks
Answer
This question spans topic 1.4 (Memory) and topic 1.5 (Processes and Threads). Cover three parts with the book's text:
-
Primary Memory (RAM) (1.4, pages 9 to 10): "Primary memory, also called Random Access Memory (RAM), is the main working area of a computer. It is a fast storage area where the computer keeps the data and instructions temporarily. Its data is erased when the computer is turned off." Example: "When you open a Word document, the computer quickly places the program and the document into RAM so the CPU can work on them right away."
-
Virtual Memory (1.4, page 10): "When the RAM is full, the operating system uses part of the computer's storage drive (like Hard drives, solid-state drives (SSD), or Non-Volatile Memory Express (NVMe)) as virtual memory. This extra space acts like temporary RAM, allowing more programs to run at the same time. Storage drives operate at lower data transfer speeds and have higher access times as compared to RAM; that's why the use of virtual memory can result in reduced system performance." Key differences from these lines: RAM is the fast main working area and is erased when the computer is turned off; virtual memory is part of the storage drive, used when the RAM is full, and is slower.
-
How multithreading improves performance (1.5, pages 11 to 12): "Multithreading is an operating system technique that allows a single process to perform multiple tasks at the same time by dividing its work into smaller units called threads." "Each thread runs independently but shares the same memory and resources of the process, enabling faster execution, better responsiveness, and efficient use of system resources." Benefits: "Enhanced Performance: Tasks can be divided into multiple threads and executed in parallel, allowing complex operations to complete more quickly and improving overall system efficiency." "Improved Responsiveness" (example: "A word processor enables continuous typing while another thread checks spelling in the background."), "Support for Concurrent (parallel) Operations", "Efficient Use of Resources".
Aim for 300-400 words.
-
2.Explain how the operating system manages memory when many programs are open at the same time. State the trade-off it makes.8 marks
Answer
Use the book's text (topic 1.4, page 10):
- Transfer mechanism (verbatim): "When several programs are open simultaneously, the operating system may transfer data from less active programs to virtual memory. This frees up space in RAM for the programs you are currently using, but may make those fewer active programs slower to respond."
- The trade-off (from the book's lines):
- Gain: virtual memory "acts like temporary RAM, allowing more programs to run at the same time", and RAM is freed "for the programs you are currently using".
- Cost: the less active programs may become "slower to respond".
- Reason: "Storage drives operate at lower data transfer speeds and have higher access times as compared to RAM; that's why the use of virtual memory can result in reduced system performance."
Aim for 200-280 words.