Study Guide

Primary Storage and Virtual Memory

The memory the CPU can reach directly: what RAM and ROM are, how they differ and why a computer needs both; and what virtual memory is, how it is created and used, and why it is needed when RAM runs out.

Lesson 3.6 Computer Systems

For: Cambridge IGCSE Computer Science learners

Stage: Think

The desk and the locker

A pupil (a made-up one) is doing homework. The books and notes needed right now are on the desk. Everything else is in a locker down the corridor. A printed card of rules is stuck firmly to the lid of the desk, and nobody ever writes on it. At the end of the day, the cleaner clears the desk completely.

Think it through

Why is it quicker to work from what is on the desk than from the locker? And what is the drawback of keeping something only on the desk?

Show what happens

Things on the desk are within reach, with no trips down the corridor. But the desk is cleared every evening, so anything left only on it is lost. The locker is slower to use, but what is in it is kept. A computer’s memory has the same pattern.

Primary storage is memory that the CPU can access directly: it can fetch from it, along the address and data buses, without any other device being involved. It is the desk. In a computer, it consists of RAM and ROM.

Secondary storage, such as a hard disk drive or a solid-state drive, is not accessed directly by the CPU. It is the locker: it keeps programs and files permanently, but a program has to be copied from it into primary storage before the CPU can run it. (How secondary storage works belongs to a later lesson.)

Check your understanding

Which statement describes primary storage?
Show the answer

Answer: C. Memory that the CPU can access directly, such as RAM and ROM.

Primary storage is memory the CPU accesses directly.

Stage: Predict

The desk: RAM

Think it through

A pupil has typed half an essay and has not saved it. The power fails. What do you expect has happened to the unsaved essay? Why?

Show what happens

The essay is lost. It was held in the memory the computer uses for work in progress, which is cleared when the power goes off, like the desk at the end of the day.

RAM (random access memory) is the computer’s main working memory. It holds the programs and data that are in use at the moment: the operating system, the programs that are running, and the files that are open. The CPU can both read from RAM and write to it, very quickly, so the contents change all the time. “Random access” means that the CPU can go straight to any location by its address, and it takes the same time whichever it is.

RAM is volatile: it loses its contents when the power is switched off. That is why unsaved work is lost in a power cut, and why files must be saved to secondary storage.

Check your understanding

Which statement about RAM is correct?
Show the answer

Answer: B. It can be read from and written to, and it loses its contents when the power is off.

RAM is volatile.

Stage: Think

The card on the desk lid: ROM

Think it through

When a computer is switched on, RAM is empty, because it loses its contents when the power is off. Yet the CPU starts working straight away. Where could its very first instructions come from?

Show what happens

They must be in memory that keeps its contents without power, and that is put there when the computer is made. That memory is ROM, like the card of rules that stays stuck to the desk.

ROM (read-only memory) is memory whose contents are fixed during normal use: the computer can read it, but the programs it runs do not change it. ROM is non-volatile: it keeps its contents when the power is switched off.

ROM holds the start-up instructions (the bootstrap program) that run when the computer is switched on. They check that the hardware is working and then load the operating system from secondary storage into RAM, after which the operating system takes over. ROM is also where the fixed program of an embedded system is usually kept, so that the washing machine is ready to work the moment it is switched on.

ROM and secondary storage both keep their contents without power, so the two can be mixed up. But ROM is primary storage that the CPU reads directly, holds only a small amount of fixed start-up instructions, and is not used for the user’s files. Secondary storage holds a very large amount of changeable programs and files that are copied into RAM before they are used.

Check your understanding

What is ROM used for in a computer?
Show the answer

Answer: A. Holding the start-up instructions, which stay when the power is off.

ROM holds the start-up instructions.

Stage: Discover

Why a computer needs both

Think it through

Imagine one computer built with only ROM, and another with only RAM. What would be the problem with each?

Show what happens

The computer with only ROM could not hold anything that changes: no open documents, no running programs. The computer with only RAM would lose its start-up instructions every time the power was switched off, so it would have nothing to tell it what to do when it was switched on. So both are needed.

Do not confuse: RAM and ROM

Can it be changed?RAM
Yes. It is read and written all the time, as programs run.An open document and the running program.
Can it be changed?ROM
No, not in normal use. The contents are fixed and only read.The start-up instructions.
Kept without power?RAM
No: it is volatile.Unsaved work is lost in a power cut.
Kept without power?ROM
Yes: it is non-volatile.The start-up instructions are there at switch-on.
Is each description true of RAM or ROM? Type RAM or ROM.
DescriptionRAM or ROM
Loses its contents when the power is switched off
Holds the start-up instructions
Holds the programs and data currently in use
Its contents are not changed while the computer is running
Can be written to as well as read from during normal use

    Show the completed table
    DescriptionRAM or ROM
    Loses its contents when the power is switched offRAM
    Holds the start-up instructionsROM
    Holds the programs and data currently in useRAM
    Its contents are not changed while the computer is runningROM
    Can be written to as well as read from during normal useRAM

    Apply it

    A designer builds a computer with RAM and no ROM at all. What is the most likely problem?
    Show the answer

    Answer: D. There would be nothing in memory to tell the CPU what to do at switch-on, as RAM starts empty.

    Without ROM, the computer has nothing to start from.

    Stage: Predict

    When the desk is full

    The pupil’s desk has room for four books. The teacher hands out a fifth, and it is needed right now.

    Think it through

    What could the pupil do, so that all five books can be used? What is the cost of doing it?

    Show what happens

    Move a book that is not needed right now from the desk to the locker, put the new one on the desk, and fetch the book from the locker again when it is needed. The cost is time: every trip to the locker is slower than reaching across the desk.

    RAM has a limited size, and the programs and data a user opens can need more than it holds. Virtual memory is the solution. The operating system sets aside a space on the secondary storage (the hard disk drive or the solid-state drive) and uses it as if it were an extension of RAM. That is how virtual memory is created.

    It is used in this way. Programs and data are divided into blocks of the same size called pages. When RAM is full, the operating system moves pages that are not being used at the moment out of RAM and into virtual memory, to make room, and copies them back into RAM when they are needed again. The CPU can only use pages that are in RAM.

    A made-up RAM with room for four pages

    Real RAM holds a very large number of pages, but it behaves in the same way when it is full.

    1. RAM

      Step 1 of 6: RAM is full

      RAM holds four pages, A, B, C and D, from the programs that are open. There is no free space.

    2. The user

      Step 2 of 6: A new page is needed

      The user opens a program that needs a fifth page, E. RAM has no room for it.

    3. Operating system

      Step 3 of 6: A page is moved out

      The operating system picks a page that is not needed right now, say C, and copies it into virtual memory on the secondary storage.

    4. Operating system

      Step 4 of 6: The new page is loaded

      Page E is loaded into the space that C used. RAM now holds A, B, D and E.

    5. Operating system

      Step 5 of 6: A page is brought back

      Later the CPU needs C. The operating system moves another idle page out to virtual memory, and copies C back into RAM.

    6. Secondary storage

      Step 6 of 6: The cost is time

      Everything still works, but each move is much slower than reading RAM, because secondary storage is much slower than RAM.

    Check your understanding

    What is virtual memory?
    Show the answer

    Answer: B. Space on secondary storage used by the operating system as an extension of RAM.

    Virtual memory is secondary storage used as an extension of RAM.

    Check your understanding

    What is moved between RAM and virtual memory?
    Show the answer

    Answer: C. Pages not needed at that moment are moved out, and brought back when they are needed.

    Pages are swapped between RAM and virtual memory.

    Stage: Apply

    A laptop that slows to a crawl

    Virtual memory is not extra RAM and it does not make a computer faster. It lets a computer cope with more than fits in RAM, at the price of speed: the more the operating system has to move pages in and out, the slower the computer feels.

    Apply it

    A laptop has only a little RAM. After many programs are opened, its drive light flashes constantly and everything slows down. What is the most likely cause?
    Show the answer

    Answer: A. RAM is full, so pages are swapped to and from the drive as virtual memory, which is much slower.

    Constant swapping of pages makes a computer slow.

    Apply it

    Which change is most likely to reduce the slowdown on that laptop?
    Show the answer

    Answer: D. Adding more RAM, so that fewer pages need to be moved out.

    More RAM means fewer pages to move.

    Apply it

    Dev says: “Virtual memory is just extra RAM, so it works just as fast as RAM.” What is wrong with this?
    Show the answer

    Answer: C. It is part of secondary storage, which is much slower than RAM.

    Virtual memory gives size, not speed.

    Stage: Consolidate

    Show what you know

    Think it through

    Explain to a younger pupil, using the desk and the locker, why a computer needs both RAM and ROM, and what it does when RAM is full.

    Show a model answer

    A good answer covers both parts. For example: “RAM is like the desk: it holds what you are working on, and it is cleared when the power goes off. ROM is like the card stuck to the lid: it stays, and it tells the computer how to start. A computer needs the desk to work on, and the card to know how to begin. If the desk is full, the computer moves books that are not needed to the locker, which is virtual memory on the drive, and brings them back when needed. That works, but it is slower.”

    Check your understanding

    Which statement about primary and secondary storage is correct?
    Show the answer

    Answer: B. The CPU accesses primary storage directly; programs are copied from secondary storage into RAM before use.

    The CPU works from primary storage.

    • Primary storage is memory the CPU accesses directly: RAM and ROM. Secondary storage is not accessed directly, and keeps programs and files permanently.
    • RAM holds the programs and data in use, can be read and written, and is volatile: it loses its contents when the power is off.
    • ROM holds the start-up instructions, is read-only in normal use, and is non-volatile.
    • A computer needs both: RAM for work that changes, and ROM so that it has instructions at switch-on.
    • Virtual memory is space on secondary storage that the operating system sets aside and uses as an extension of RAM. Pages that are not needed are moved out of RAM, and brought back when they are.
    • It is needed because RAM is limited. It is slower than RAM, so a computer that depends on it too much slows down.

    Sources and scope

    • What this lesson is. The sixth lesson of the Computer Systems module, written for this site. It teaches Cambridge IGCSE Computer Science (0478) points 3.3.1 and 3.3.4 (2026 to 2028, version 6): primary storage, RAM and ROM, and virtual memory. The other parts of point 3.3 are left to later lessons. Its curriculum links are provisional and imply no endorsement by any examination board. It has not been approved by the site owner.
    • Original material. The pupil’s desk and locker, the four-page RAM, and the people named are fictional and were written for this lesson.
    • Simplified on purpose. ROM is described as read-only in normal use; in many real computers the start-up instructions are kept in memory that can be rewritten by a special update, and the start-up sequence has more stages than the two named here. Paging is shown with four pages, and real operating systems use more careful rules to choose which pages to move. Secondary storage is only contrasted with primary storage here.