Memory · Cambridge syllabus 3.3 · Lesson 1 of 2
Primary Memory
RAM holds currently used programs and data and is volatile. ROM retains its contents without power and holds the start-up instructions. Both are primary storage, which the CPU accesses directly. When RAM is full, the operating system can use part of secondary storage as virtual memory, moving pages of data between it and RAM when they are needed.
By the end, you can
- Understand the purpose of RAM.
- Explain why RAM is volatile.
- Understand how RAM affects system operation.
- Understand the purpose of ROM.
- Explain why ROM is non-volatile.
- Compare ROM and RAM.
- Describe what virtual memory is.
- Explain how virtual memory is created and used.
- Explain why virtual memory is necessary.
RAM
Primary memory is the memory the CPU can address directly. Random access memory holds the programs and data currently in use — the operating system, every open application, and the documents being worked on.
The processor can read from and write to any location in RAM directly, and any address takes the same time to reach, which is where the name comes from. Data has to be in RAM for the CPU to work on it at all, so anything opened is copied there from storage first.
RAM is volatile: it needs a constant supply of power to hold its contents, and everything in it is lost the instant the power goes. This is precisely why unsaved work disappears in a power cut — saving is the act of copying from volatile RAM to non-volatile storage.
How much RAM a machine has decides how much can be open at once. When it is full, the operating system can use virtual memory, which is described in the last section of this lesson.
Worth remembering
- RAM holds the programs and data currently in use, directly accessed by the CPU.
- Volatile: contents are lost when power is removed, so work must be saved.
- RAM and ROM are both primary storage.
ROM
Read-only memory holds data that the computer needs before anything else is available, and that must survive being switched off. It is non-volatile, so its contents are there the moment power arrives.
Its main job is the start-up instructions. When a computer is switched on, RAM is empty and the operating system is on a disk the computer does not yet know how to read. The CPU therefore starts executing from a fixed address in ROM, which runs a check of the hardware and then loads the operating system from storage into RAM. Without something non-volatile to start from, a computer could not start at all.
ROM also holds the permanent program of an embedded system: the control program of a washing machine or a microwave is in ROM, because it never needs to change and must be there instantly.
The two are easiest to separate by three questions. Volatile or not: RAM loses its contents, ROM does not. Writable or not: RAM is read and written constantly, ROM is effectively read only, though modern firmware can be reflashed deliberately. And size: RAM is measured in gibibytes and ROM in a few mebibytes, because it only holds start-up code.
Worth remembering
- ROM is non-volatile and holds the start-up instructions, so it can boot the machine.
- RAM is volatile, large and constantly written; ROM is small and effectively read only.
- Embedded systems keep their permanent control program in ROM.
Virtual memory
Virtual memory is part of secondary storage, a hard disk or an SSD, that the operating system uses as if it were extra RAM. It is needed because RAM is limited: with many programs and large files open, RAM can fill up, and without virtual memory no more could be opened, or the computer could stop responding.
It is created by the operating system, which sets aside an area of secondary storage for it. Data in RAM is divided into fixed-size blocks called pages. When RAM is full and more space is needed, the operating system moves pages that are not being used at that moment from RAM to virtual memory. When one of those pages is needed again, it is moved back into RAM, and another page that is not in use is moved out to make room.
The CPU can only work on data in RAM, so a page in virtual memory must be moved back before it can be used. Secondary storage is far slower than RAM, so if pages are moved back and forth constantly, the computer becomes very slow. The cure is more RAM; virtual memory only keeps the computer working when RAM runs out.
Worth remembering
- Virtual memory is secondary storage used as extra RAM when RAM is full.
- Pages of data are moved between RAM and virtual memory when needed.
- It lets more programs run, but it is much slower than RAM.
Worked example
A program is loaded from an SSD into RAM before the CPU works with its instructions and data.
Practice
Warm-up · not marked
Check your understanding
Answer in your own words, then compare with the worked answer. Nothing here is saved or scored.
Worked answer
It may exist only in volatile RAM and has not been written to non-volatile storage.
Check your method, units and explanation against it.
Marked practice
Set 1 of 5 · easiest first · Checked as you go, with the worked answer. Sign in or create a free account to save your progress.