Storage Devices and File Systems
The CPU does not work directly with program files on a hard drive.
Two Jobs, Two Memory Systems
A running program needs data close to the CPU so that the CPU can access it quickly. A computer also needs to retain programs and files after power is removed. One type of memory cannot provide both requirements equally well, so computers use multiple memory systems. Main memory supports fast active work, while secondary memory supports long-term storage.
Main memory is fast and nearly as quick as the CPU, but it is volatile. Secondary memory is much slower, but it retains data without power.
A Program’s Route to the CPU
The CPU does not work directly with program files on a hard drive. When you start a program, the operating system copies the program from secondary memory into main memory. The CPU then executes the program code from main memory. The same pattern applies to data: information needed for active processing must be placed in main memory before the CPU works with it.
Opening a Web Browser
Trace what happens when a user opens a browser, loads a webpage, and then closes the browser without saving the page.
- 11. Start the browser
The browser application is stored on secondary memory, such as a hard drive. When the browser icon is selected, the operating system copies the application into main memory.
- 22. Execute the application
The CPU executes the browser code from main memory.
- 33. Request a webpage
When the user enters a web address, the browser sends a request over the network.
- 44. Receive webpage data
The web server sends webpage data back over the network. The data arrives in main memory, where the CPU processes it and the computer displays it.
- 55. Close without saving
The webpage data held in main memory is lost when the browser closes without saving it. The browser application remains on secondary memory and can be loaded again later.
The browser application persists because it is stored in secondary memory, while the unsaved webpage data was only part of the active information in main memory.
Saving Across the Power Boundary
Volatility describes whether memory keeps its contents when power is removed. Main memory requires constant power, so cutting power causes all data in it to be lost. Secondary memory is non-volatile: it retains data indefinitely without power. Saving is therefore an explicit transfer from main memory to secondary memory.
Document data is in main memory. Power is available.
The data is available for active processing but is volatile.
Document data remains in secondary memory. Power can be removed.
The saved data persists after shutdown because it was copied to secondary memory.
For the same reason, a program that reads a large file must first read that file from secondary memory into main memory. If the program produces results that must still exist after the program finishes, it must explicitly write those results to secondary memory.
Choosing Secondary Memory
Secondary memory is designed for long-term storage because it keeps data without power. Common examples include disk drives, specifically hard disk drives and solid-state drives, as well as flash memory found in USB sticks and portable music players. These technologies are appropriate for retaining programs and files rather than for the CPU’s immediate processing work.
| Storage type | Source-described use | Persistence |
|---|---|---|
| Hard disk drive | Long-term storage of programs and files | Retains data without power |
| Solid-state drive | Long-term storage of programs and files | Retains data without power |
| Flash memory | Storage in USB sticks and portable music players | Retains data without power |
Examples of secondary memory and their appropriate long-term storage role
The important classification is not simply the device’s physical form. Secondary memory is identified here by its role: it retains data without power and provides long-term storage.
Networks as Remote Storage
A network connection can act as a form of secondary memory because it provides access to data stored somewhere else. The data is remote rather than already present on the computer’s local storage. The computer requests the data, receives it over the network, and places it into main memory so the CPU can process it.
What do you think happens?
A webpage has arrived from a server over the network. Where must the webpage data be placed before the CPU processes it?
Reveal answer
In main memory
The webpage data arrives over the network and is placed into main memory. The CPU then processes the data from main memory.
Mistakes About Persistence
Common mistake Assuming that data the CPU is using is automatically permanent
What it looks likeA document is open and visible, so a learner assumes it will survive a power cut.
Why it failsActive data is held in main memory, which is volatile and loses its contents when power is removed.
Do this insteadExplicitly save the document to secondary memory when it must persist.
Common mistake Thinking the CPU executes a program directly from a hard drive
What it looks likeDescribing a browser as running straight from its stored program file.
Why it failsThe operating system copies the program from secondary memory into main memory before the CPU executes it.
Do this insteadTrace the route as secondary memory to main memory to CPU.
Common mistake Treating network access as equally reliable and immediate as local active memory
What it looks likeDesigning a critical, time-sensitive operation as though remote data will always arrive instantly.
Why it failsThe source describes network connections as slow and unreliable.
Do this insteadUse network connections for remote access while recognizing their speed and availability limitations.
Common mistake Assuming that closing a program saves every piece of data it used
What it looks likeExpecting an unsaved webpage to remain after closing the browser.
Why it failsData that remains only in main memory can be lost when it is no longer active or when power is removed.
Do this insteadSave important results explicitly to secondary memory.
Apply the Memory Model
A program reads a file, changes its data, and produces a result that must still exist after the computer is turned off. Describe the movement of the data through the memory systems. Then identify what could be lost if the program ends before it saves the result.
Hints
- Begin with where the original file is stored.
- Identify where the CPU must find the data while processing it.
- Finish by identifying where the result must be written for persistence.
- 1Read the file from secondary memory into main memory.
- 2The CPU processes the data in main memory.
- 3Write the result from main memory to secondary memory if it must persist.
- 4Remember that unsaved data in main memory is vulnerable to power loss.
Memory Hierarchy Summary
- 1Main memory is fast and close to the CPU, so the CPU uses it for active program execution and data processing.
- 2Main memory is volatile: its contents are lost when power is cut off.
- 3Secondary memory is slower but non-volatile, so it retains programs and files for long-term storage.
- 4Disk drives and flash memory are examples of secondary memory.
- 5Network connections provide remote access to data, but their slowness and unreliability make them unsuitable for critical, time-sensitive operations.
At a glance
- The CPU works with data in main memory rather than directly with files on secondary memory.
- Main memory provides speed but loses its contents without power.
- Secondary memory provides persistence but is much slower than main memory.
- Saving explicitly copies data from main memory to secondary memory.
- Network connections can provide remote data access, but they are slow and unreliable compared with local active processing.