OCR H446, section 1.1.3 (c)
A computer needs fast memory that the processor can reach directly. There are two main kinds, and they do different jobs.
RAM: random access memory
RAM is the computer's main memory. It holds the programs and data that are being used right now.
- Volatile: its contents are lost when the power is turned off.
- Read and write: the processor can both read and change the contents.
- Random access: any location can be reached directly in about the same time, in any order.
- Fast, much faster than secondary storage, but more expensive per gigabyte and of limited size.
When you start a program, the operating system loads it from secondary storage into RAM, where the processor can fetch its instructions. Data that is being edited is held there too.
Two types of RAM
| DRAM (dynamic RAM) | SRAM (static RAM) | |
|---|---|---|
| How a bit is stored | A charge in a capacitor, which leaks and must be refreshed many times a second | A circuit of transistors (a flip-flop) that holds its state as long as there is power |
| Speed | Slower | Faster |
| Cost | Cheaper | More expensive |
| Size per bit | Smaller, so higher capacity | Larger |
| Power | Needs constant refreshing | Uses less power when idle |
| Used for | Main memory (the gigabytes of RAM in a computer) | Cache memory in the processor |
ROM: read-only memory
ROM holds data that is permanently stored, and is not normally changed.
- Non-volatile: its contents are kept when the power is off.
- Read-only in normal use: the processor can read it, but can't write to it, so the contents are protected from accidental change.
- Also directly addressable, and fast to read.
- Usually small.
What ROM is used for
- The bootstrap (start-up) program. When the computer is switched on, RAM is empty, so the first instructions must come from ROM (the BIOS or similar firmware, see 1.2.1 (f)). They test the hardware and load the operating system.
- Firmware in embedded systems: the fixed program in a washing machine, a microwave, a remote control or a calculator.
- Fixed data, such as character fonts or look-up tables.
Types include PROM (programmed once), EPROM (erased with ultraviolet light and reprogrammed) and EEPROM and flash (erased and rewritten electrically, as when updating firmware).
Comparison
| RAM | ROM | |
|---|---|---|
| Full name | Random access memory | Read-only memory |
| Volatile? | Yes: loses data without power | No: keeps data |
| Read and write? | Both | Read only (normally) |
| Holds | Running programs and current data | Start-up program and fixed firmware |
| Typical size | Large (gigabytes) | Small (kilobytes to megabytes) |
| Cost per GB | Higher | Lower for small sizes |
| Contents change? | Constantly | Rarely or never |
Where they fit
RAM is not the same as secondary storage. RAM is fast and volatile, and holds what is being used now. Secondary storage is slower but permanent, and holds everything else.
Worked example
Task: explain what happens in RAM and ROM when a computer starts up and a user opens a word processor.
- The computer is switched on. RAM is empty, as it is volatile.
- The processor starts running the bootstrap program stored in ROM, which checks the hardware and finds the operating system.
- The operating system is loaded from the disk into RAM, and takes control.
- When the user opens the word processor, its program is copied from the disk into RAM, and the processor fetches its instructions from there.
- As the user types, the document is held in RAM. If the power fails before it is saved to storage, it is lost, because RAM is volatile.
Exam tip: the key words are volatile (RAM) and non-volatile (ROM), and read/write against read-only. Always give the purpose: RAM holds the programs and data in use, and ROM holds the bootstrap and fixed firmware.
Check yourself
What does it mean to say RAM is volatile?
Its contents are lost when the power is turned off.
Give one use of ROM
Storing the bootstrap program that starts the computer (or the firmware of an embedded system, such as a washing machine).
Why does a computer need ROM at start-up?
RAM is empty when the power comes on, so the first instructions must be stored in non-volatile memory, ROM, to start the computer and load the operating system.
Which type of RAM is used for cache, and why?
SRAM, because it is faster than DRAM, although it is more expensive.