Data Storage
Primary and secondary storage, how magnetic, optical and flash storage work, virtual memory, and the cloud.
WATCH IT EXPLAINED
EXPLORE IT IN 3D
Where data lives
A PC is opened up on the bench with its drives cabled beside it, and a data centre stands across the room. Boot it, read a file from a spinning disk, a laser and a flash chip, then decide where data should live.
Primary and secondary storage
The CPU works only with primary storage, so anything on secondary storage must be copied into RAM first.
Primary storage is storage the CPU can access directly. Secondary storage is not directly accessed by the CPU.
| Primary storage | Secondary storage | |
|---|---|---|
| Examples | RAM and ROM | a hard disk drive (HDD), a solid-state drive (SSD), an optical disc, a USB flash drive |
| Can the CPU access it directly? | yes | no |
So a program or file on secondary storage must be copied into RAM before the CPU can use it.
Secondary storage is needed for more permanent storage of data:
- it keeps data with the power off
- it holds far more than RAM
Example:In the figure, the photo editor never goes from the SSD straight to the CPU.
RAM
RAM holds the programs and data in use right now, and it loses everything when the power goes off.
Random access memory (RAM) is the computer's working space, like a desk where you spread out today's homework.
- RAM is volatile: its contents are lost when the power is switched off.
- It can be read from and written to.
- It holds the programs and data in use at the moment, including parts of the operating system. So its contents change all the time.
More RAM lets more of the programs and data in use be held at once, without fetching them from secondary storage first.
ROM, and why a computer needs both
ROM keeps the start-up instructions safe with the power off, so a computer needs both RAM and ROM.
Read only memory (ROM) is non-volatile: it keeps its contents without power. Its contents cannot normally be changed.
ROM stores the start-up instructions, such as the BIOS and the bootloader. The computer needs them the moment it is switched on, while RAM is still empty.
| RAM | ROM | |
|---|---|---|
| Volatile? | yes | no |
| Read/write | read and write | read only |
| Holds | programs and data in use now | start-up instructions |
| Contents | change all the time | fixed |
| Needed for | working data that changes constantly | start-up, which must survive power-off |
A computer needs both:
- RAM, because working data changes all the time, and ROM cannot be written to.
- ROM, because the start-up instructions must survive with the power off, and RAM cannot keep them.
Press Power on and Power off in the figure, and watch which one changes.
Magnetic storage: hard disk drives
A hard disk stores data as tiny magnetised areas on spinning platters, read and written by a moving head.
A hard disk drive (HDD) stores data on platters (disks) coated with magnetic material. The platters spin at high speed.
- Each platter surface is divided into circular tracks.
- Each track is divided into sectors.
Read/write heads on a moving arm use electromagnets. To write, they magnetise tiny areas in one of two directions, for 1s and 0s. To read, they detect those directions.
To reach some data, the arm moves the head to the right track. Then the drive waits for the right sector to spin under it.
- Good: HDDs are cheap for their large capacity.
- Bad: their moving parts make them slower to access than SSDs, noisy, and easily damaged if knocked.
Optical storage: CD, DVD and Blu-ray
Optical discs store data as pits and flat lands along a spiral track, and a laser reads them.
Optical discs (CD, DVD and Blu-ray) store data in a spiral track of pits (dips) and lands (the flat parts between them).
- A laser shines on the spinning track.
- Pits and lands reflect the light differently.
- A sensor reads the changes in reflection as binary.
To write data, the laser burns pits into the disc.
| CD | DVD | Blu-ray | |
|---|---|---|---|
| Laser | red | red | blue-violet |
| Holds | the least | more than a CD | far more than a DVD |
Optical discs are cheap per gigabyte. But they are slower to access than SSDs, and less durable.
Solid-state (flash) storage
Flash storage keeps data in grids of transistors, with no moving parts, and keeps it without power.
Solid-state storage (an SSD, an SD card or a USB flash drive) has no moving parts. It uses flash memory, built with NAND or NOR technology.
- The cells are transistors laid out in a grid.
- Each cell has a control gate and a floating gate.
- The gates control the flow of electrons through the transistor. This sets the cell to a 1 or a 0.
Flash is non-volatile: the data is not lost when the power is turned off.
| Good | Bad |
|---|---|
| fast, silent and low-power | costs more per gigabyte than an HDD |
| survives knocks | each cell can be rewritten only a limited number of times |
Virtual memory
When RAM is full, the operating system uses part of secondary storage as extra RAM, but it is much slower.
The operating system sets aside part of secondary storage (an HDD or SSD) as virtual memory: an extension of RAM. It uses it when RAM is full.
- Programs and data are divided into pages.
- Pages not needed at the moment are moved out to virtual memory. This frees RAM.
- When a page is needed again, it is swapped back into RAM, because the CPU can only use it from RAM.
- Good: a computer can run more programs than would fit in RAM.
- Bad: secondary storage is much slower than RAM.
Watch out:If pages swap back and forth constantly, the computer slows down. A Level calls this disk thrashing. More RAM means fewer swaps.
Cloud storage
Cloud storage keeps your files on a company's servers, and you reach them over the internet.
Cloud storage means keeping your files on storage that a company owns and runs. You access it remotely, over the internet. You do not store the files locally, on a device you have with you.
Remember:The cloud is still physical. The data is kept on real servers and storage in data centres.
Providers usually back up the data. So one broken server does not lose your files.
Cloud or local?
Cloud files are easy to reach and share anywhere, but they need the internet and a provider you trust.
| Cloud | Local | |
|---|---|---|
| Reach files | from any device with an internet connection; easy to share | only where the device is |
| Internet | needed | not needed |
| Speed | only as fast as your connection | fast |
| Cost | you do not buy or look after the storage; you keep paying a subscription, and can pay for more space when you need it | buy the device once |
| Backups | by the provider | by you |
| Risks | your data's security depends on the provider; it could be hacked or close down | no copy unless you back it up yourself |
Example:A 1 GiB file takes about 859 seconds (about 14.3 minutes) to upload at 10 000 000 bits per second. It takes about 2.15 seconds to copy to a local SSD.
Choosing storage for a job
Compare capacity, speed, cost, portability and durability, then pick the storage that fits the scenario.
Compare the options on capacity, speed, cost, portability, durability and reliability. Then justify the choice from the scenario.
| HDD | SSD | Optical | Cloud | |
|---|---|---|---|---|
| Capacity | very large | large | small | pay for more |
| Speed | medium | fast | slow | your link |
| Cost | lowest per GB | more per GB | cheap per GB | a fee |
| Portable | fairly | yes | yes | any device |
| Durable | knocks harm it | no moving parts | less robust | provider backs up |
- A laptop or phone suits solid-state storage. It is fast, survives being carried and uses little power.
- A server holding huge archives suits HDDs. They are the cheapest per gigabyte for large capacity.
- Optical discs are cheap per gigabyte, but slower and less robust.
- Cloud storage suits files that must be shared, or reached from many places.
KEY TERMS
CHECK YOURSELF
1.Which statement about RAM is true?
2.Why is an SSD more robust than a hard disk drive?
3.What is moved between RAM and virtual memory when it is needed?
4.Which storage can the CPU access directly?
5.Where is virtual memory created?
6.Why does a computer need ROM as well as RAM?
7.How does an optical disc store data?