1.2.1 Primary storage (memory)
A computer needs somewhere to keep the programs and data it is working on right now. That place is called primary storage. It is also called primary memory or main memory.
Why a computer needs primary storage
The CPU can only work on instructions and data that are in primary storage. It cannot run a program straight from a hard drive or a memory stick.
When you open a game, the computer copies it from secondary storage into primary storage. Then the CPU fetches the instructions from there, one at a time, and carries them out.
Primary storage is used because it is much faster than secondary storage. If the CPU had to wait for a slow device every time it needed an instruction, the whole computer would crawl.
The main types of primary storage are RAM and ROM. Computers also use virtual memory and cache to help them run well.
RAM
The key characteristics of RAM are:
- •It is volatile. When the power is turned off, everything in RAM is lost.
- •You can read from it and write to it. Its contents change all the time.
- •It is fast, and it can be added to or upgraded (for example 8 GB or 16 GB).
- •Any location can be reached quickly. That is what "random access" means.
ROM
The key characteristics of ROM are:
- •It is non-volatile. The contents stay when the power is off.
- •It is read only. The computer can read it, but normally cannot change it.
- •It is small, because it only holds a few essential instructions.
Many devices also keep fixed instructions in ROM. Examples are a washing machine, a microwave or a TV remote.
RAM and ROM compared
| RAM | ROM | |
|---|---|---|
| Volatile? | Volatile: contents lost when power is off | Non-volatile: contents kept when power is off |
| Read and write? | Can be read and written | Read only (normally cannot be changed) |
| What it holds | Programs and data in use right now | Start-up (boot) instructions |
| Size | Large (gigabytes) | Small |
| Contents change? | All the time | Rarely or never |
Virtual memory
RAM is limited. If you open many programs at once, the RAM can fill up. The computer could stop working. Instead, it uses virtual memory.
How virtual memory works
- 1.The RAM becomes full.
- 2.The computer picks some data in RAM that is not being used right now.
- 3.It moves that data from RAM to a space on the secondary storage.
- 4.This frees up space in RAM for the program or data that is needed.
- 5.Later, if the moved data is needed again, it is moved back into RAM. Something else may be moved out to make room.
The best fix for a computer that is slow because it keeps using virtual memory is to fit more RAM. Then less data needs to be moved to and from secondary storage.
Cache
The CPU is much faster than RAM. Without cache, the CPU would often have to wait for RAM. The cache keeps a copy of the instructions and data that are used again and again, such as the instructions in a loop. When the CPU needs them, it finds them in the cache and does not have to wait.
The key characteristics of cache are:
- •It is faster than RAM.
- •It is much smaller than RAM (usually a few megabytes, compared with gigabytes of RAM).
- •It costs more per gigabyte than RAM, which is why there is not more of it.
- •A bigger cache usually means a faster computer, because the CPU finds what it needs in the cache more often.
| Advantages of a larger cache | Disadvantages of a larger cache |
|---|---|
| The CPU waits less for instructions and data | It costs more |
| Programs usually run faster | It is still small compared with RAM |
The memory in order of speed
| Memory | Speed | Size |
|---|---|---|
| Cache | Fastest | Smallest |
| RAM | Fast | Large |
| Virtual memory (on secondary storage) | Slow | Depends on the free space |
Keep these apart
- ROM: start-up instructions, non-volatile, read only.
- Virtual memory: part of secondary storage used as extra RAM when RAM is full. It is slower than RAM.
- Cache: small, very fast memory next to the CPU for the instructions and data used most.
Exam technique
- •State and give questions need a short fact: "ROM is non-volatile" or "cache is faster than RAM".
- •Describe questions need you to say what something does or how it works. For virtual memory, describe the movement of data between RAM and secondary storage.
- •Explain questions need a reason as well. Write "because" and join two points: "RAM is volatile, so the boot program is kept in ROM".
- •For a compare question, always give a point about both items. Do not only say "RAM is volatile". Say "RAM is volatile but ROM is non-volatile".
- •Use the correct words: volatile, non-volatile, read only, boot program. Do not call ROM "permanent storage" or say that RAM "stores files".