Primary and secondary storage
Primary storage is directly accessible by the processor. RAM is volatile — its contents vanish when the power goes — and holds whatever is currently running. ROM is non-volatile and holds the start-up instructions the machine needs before it can load anything else.
Secondary storage is not directly accessible by the processor; data must be copied into RAM first. It is non-volatile, far larger and far slower, and it is where everything lives when the machine is off.
| RAM | ROM | Secondary | |
|---|---|---|---|
| Volatile? | yes | no | no |
| Can be written to? | yes | not normally | yes |
| Size | gigabytes | small | hundreds of gigabytes upward |
| Speed | fast | fast | slow |
| Holds | programs currently running | boot instructions | all files permanently |
ROM does not hold the operating system
It holds the small program that starts the machine and knows how to find the operating system on the disk. The operating system itself is far too large for ROM and is loaded into RAM during booting. Answers claiming the OS lives in ROM are a standing error.
The three secondary storage technologies
Each stores data by a completely different physical mechanism, and the mechanism explains every one of its characteristics.
Magnetic storage — a hard disk — magnetises tiny regions on spinning platters, read by a head that moves across them. The moving parts make it slower and vulnerable to being dropped, but it is cheap per gigabyte and available in very large capacities.
Optical storage — CD, DVD, Blu-ray — burns pits into a reflective surface, read by the way a laser reflects off pits and flat areas. It is cheap, portable and long-lasting, but slow and small by modern standards.
Solid state storage — SSDs and flash drives — traps charge in transistors with no moving parts at all. Fast, silent and shock-resistant, but dearer per gigabyte, and each cell tolerates only a limited number of writes before it wears out.
A film crew needs storage for footage shot on location, and separately for a video archive kept at the office. Recommend a technology for each.
- On location: solid state.It has no moving parts, so it survives being carried, dropped and vibrated in a vehicle.
- It is also fast, which matters when writing high-bitrate video in real time.A magnetic disk might not keep up and would risk dropped frames.
- For the archive: magnetic hard disks.Capacity per rupee is what matters for an archive, and the drives sit still in a rack.
- The speed disadvantage is irrelevant for material accessed occasionally, and the cost saving over SSDs at that capacity is large.Matching the technology to the actual demand is the whole question.
Solid state on location for durability and speed; magnetic at the office for capacity and cost.
Virtual memory
A machine may be asked to run more programs than its RAM can hold. Rather than refusing, the operating system uses virtual memory: a region of secondary storage treated as though it were extra RAM.
Pages of memory not currently being used are written out to disk, freeing real RAM for what is active. When a page is needed again it is read back, and something else is written out to make room. That exchange is called paging or swapping.
It works, and it is slow. Disk access is thousands of times slower than RAM, so a machine paging heavily becomes dramatically sluggish — the familiar symptom of a slow computer with a constantly busy disk light. The cure is more RAM, which removes the need to page at all, rather than a faster disk, which only shortens each delay.
Why virtual memory is worth having anyway
Without it, opening one program too many would simply fail. With it, the machine slows down but keeps working, and the user can close something. Graceful degradation under pressure is nearly always preferable to an outright refusal, which is why every modern operating system does this.
Before you leave this chapter
- RAM is volatile and holds what is running; ROM is non-volatile and holds boot instructions.
- ROM does not hold the operating system — that is loaded into RAM at boot.
- Magnetic: cheap and large, but moving parts. Optical: portable but slow and small. Solid state: fast and durable but dearer with limited writes.
- Virtual memory uses secondary storage as extra RAM, moving pages in and out.
- Heavy paging means a slow machine with a busy disk. More RAM removes the cause.
Choosing storage for a purpose
Questions in this topic describe a use and ask which storage suits it. Four considerations settle almost every case, and naming which one dominates is what turns a recommendation into a justified one.
- Capacity — how much must be stored? Archives favour magnetic disks, which are far cheaper per gigabyte at large sizes.
- Speed — how quickly must it be read or written? Solid state is dramatically faster, which matters for an operating system or live video.
- Portability and durability — will it be carried? Solid state and optical survive handling; a hard disk does not enjoy being dropped.
- Cost — per gigabyte, magnetic is cheapest, then optical, then solid state.
| Purpose | Best choice | Deciding factor |
|---|---|---|
| Operating system drive | solid state | speed |
| Large video archive | magnetic | capacity per rupee |
| Carrying files between sites | solid state or optical | portability and durability |
| Distributing software to customers | optical | cheap to duplicate in quantity |
| Recording video on location | solid state | no moving parts to fail |
Say which factor decided it
A recommendation without a reason earns half the marks. "Solid state, because there are no moving parts to fail when the equipment is being carried" is a complete answer; "solid state, because it is better" is not. Identify the factor that actually dominates in the situation described, and say so.