Input, Output and Storage
Devices and their uses, magnetic, flash and optical storage, RAM and ROM, virtual storage and how to justify a choice.
Devices and how they work
Input devices
Convert a real world signal into data the computer can process.
- Keyboard: each key closes a circuit, producing a scan code translated by the driver
- Optical mouse: an LED and a small camera photograph the surface many times a second and compare successive images to detect movement
- Barcode scanner: a laser sweeps across the code and a sensor measures reflected light, since black absorbs and white reflects
- Microphone: a diaphragm vibrates, producing a varying voltage sampled by an analogue to digital converter
- Sensors: temperature, pressure, light, motion, converting a physical quantity into a measurable electrical value
Output devices
- LCD and OLED displays: an LCD uses a backlight with liquid crystals controlling how much light passes each subpixel, while OLED pixels emit their own light, so black pixels are simply off and contrast is far higher
- Laser printer: a laser draws the page as a static charge on a drum, toner sticks to the charged areas and is fused by heat
- Inkjet printer: droplets are fired from nozzles onto the paper
- 3D printer: builds an object layer by layer, usually by extruding molten material
Name the property that matters for the scenario. A laser printer suits an office because its cost per page is low over high volumes and it is fast, whereas an inkjet suits occasional photo printing because the initial cost is low and the colour quality is good.
- Optical mouse: an LED lights the surface, a tiny camera takes thousands of photos a second, and comparing them shows the movement.
- Barcode scanner: a laser sweeps across the bars, white reflects and black absorbs, and the sensor turns the pattern of light into 1s and 0s.
- Capacitive touchscreen: a finger changes the charge in the grid of wires, and the controller finds the row and column that changed.
- Laser printer: a laser draws the page on a drum as a charge, toner sticks to it, the paper picks the toner up and a fuser melts it in.
- LCD has a backlight that is always on, so black is dark grey. OLED pixels make their own light, so black is off and the contrast is higher.
- A 3D printer melts plastic filament and lays it down one layer at a time until the object is built.
Storage
Magnetic
Rigid platters coated in magnetic material spin at high speed while a read write head on an actuator arm magnetises regions to represent bits.
- Very high capacity at low cost per byte
- Slow relative to solid state, because access requires physical seek and rotation
- Vulnerable to shock, since the head hovers nanometres above the surface
- Magnetic tape is serial access, very cheap per terabyte, still standard for archives
Flash, solid state
Data is stored as charge trapped in floating gate transistors, arranged in NAND cells.
- No moving parts, so access time is uniform and shock resistance is excellent
- Far faster and lower power than magnetic
- More expensive per byte
- A finite number of program and erase cycles per cell, managed by wear levelling, which distributes writes across the drive rather than repeatedly hitting the same cells
Optical
A laser reads pits and lands burned into a reflective layer. Cheap, portable, low capacity, easily scratched, and read only formats cannot be altered.
RAM and ROM
- RAM is volatile and holds the operating system, running programs and their data. DRAM must be refreshed constantly and is used for main memory. SRAM is faster, needs no refresh, and is used for cache.
- ROM is non volatile and holds firmware such as the bootstrap. EEPROM and flash allow it to be rewritten for firmware updates.
Virtual storage
Virtual memory is secondary storage used as an extension of RAM. Pages not recently used are written to the page file, freeing physical memory. Excessive paging causes disk thrashing, where the system spends more time moving pages than executing instructions.
Cloud storage is a form of virtual storage: files appear local but are held on remote servers, giving access from any device and offsite backup, at the cost of requiring a connection and placing data under someone else's control.
- Magnetic: spinning platters with a head floating over the surface.
- Solid state: a grid of cells holding charge, with no moving parts.
- Optical: one spiral track of pits and lands, read by a laser.
- Which one depends on capacity, speed, durability and cost per gigabyte.
Key terms you must be able to define
- Analogue to digital converter
- Hardware that samples a continuous signal and outputs binary values.
- Magnetic storage
- Storage representing data by magnetising regions of a rotating platter or a tape.
- Solid state storage
- Storage using charge trapped in transistors, with no moving parts.
- Wear levelling
- Distributing writes across a flash device so no cells wear out prematurely.
- DRAM
- Dynamic RAM, which must be refreshed continuously and is used for main memory.
- SRAM
- Static RAM, faster and requiring no refresh, used for cache.
- EEPROM
- Electrically erasable programmable ROM, allowing firmware to be updated.
- Virtual memory
- Secondary storage used as an extension of RAM when physical memory is full.
- Disk thrashing
- Excessive paging between RAM and secondary storage, severely degrading performance.
Flashcards
Say the definition out loud before you flip the card. Retrieving it from memory is what builds recall, reading it again is not.
Reach the top grade on this topic
- Explain how a device works mechanically, not just what it is for
- Justify a storage choice by naming the property that matters in that scenario
- Distinguish DRAM from SRAM by refresh requirement and where each is used
- Explain wear levelling as the response to a finite number of write cycles
- Explain virtual memory as a paging mechanism with a performance cost, not as extra RAM
Mistakes that cost marks here
- Saying virtual memory 'adds RAM'. It substitutes far slower secondary storage for it.
- Saying SSDs never fail. Flash cells have a finite number of program and erase cycles.
- Confusing DRAM and SRAM. SRAM is the faster one used for cache.
- Describing an OLED as a backlit display. OLED pixels emit their own light, which is why black is truly black.
Solid state drives write data in pages but can only erase in much larger blocks. This mismatch is why an SSD slows down as it fills up, and why wear levelling exists to spread writes across the whole drive.
Knowledge check
Exam-style questions
Five written questions in the style of the real paper. Write a full answer, then let the marker check it against the mark scheme.
- LRigid platters coated with magnetic material rotate at high speed
- LA read write head on a moving arm passes over the surface
- LRegions of the surface are magnetised in one direction or another to represent 1 and 0
A magnetic hard disk drive contains one or more rigid platters coated with a magnetic material, which rotate at high speed, typically between five and fifteen thousand revolutions per minute. A read write head mounted on a moving actuator arm is positioned nanometres above the surface and can be moved radially to reach any track. To write data, the head produces a magnetic field that magnetises a tiny region of the coating in one of two directions, representing a 1 or a 0, and to read it the head detects the direction of magnetisation as the surface passes beneath it.
- LDRAM stores each bit as charge in a capacitor which must be refreshed
- LSRAM uses flip flops and needs no refresh, so it is faster
- LDRAM is denser and cheaper, so it is used for main memory
- LSRAM is more expensive and less dense, so it is used for cache
DRAM stores each bit as an electrical charge in a tiny capacitor. Because that charge leaks away, every cell has to be refreshed thousands of times per second, and this refresh cycle both consumes power and makes access slower. SRAM stores each bit using a small arrangement of transistors forming a flip flop, which holds its value as long as power is supplied and therefore needs no refreshing, making it considerably faster to access. The trade off is density and cost: a DRAM cell needs roughly one transistor and one capacitor while an SRAM cell needs about six transistors, so DRAM packs far more capacity into the same area at a much lower price. DRAM is therefore used for main memory where large capacity is essential, while SRAM is used for the small quantities of cache inside and beside the processor where speed matters far more than cost.
- LFlash memory cells tolerate only a finite number of program and erase cycles
- LWithout intervention frequently written areas would fail long before the rest
- LWear levelling distributes writes evenly across all cells to extend the drive's life
Each cell in flash memory can only be programmed and erased a finite number of times before it becomes unreliable, typically in the order of thousands of cycles for consumer drives. Without intervention this would be a serious problem, because file systems repeatedly rewrite certain areas such as directory structures and log files, so those particular cells would wear out and fail while the vast majority of the drive remained almost unused. Wear levelling is a technique implemented by the drive's controller that tracks how many times each block has been written and deliberately redistributes data so that writes are spread evenly across every cell in the device. This means the whole drive ages at approximately the same rate, which extends its usable life very substantially.
- LRecommends solid state storage
- LAccess time is uniform because there is no seek or rotational delay
- LRandom access performance matters most for a database with many small reads
- LAcknowledges the higher cost per byte as the accepted trade off
The company should use solid state storage, ideally NVMe drives. A database serving thousands of requests per second performs a very large number of small random reads scattered across the data, and this is precisely the workload magnetic storage handles worst, because every request requires the actuator arm to seek to the correct track and then wait for the platter to rotate the sector under the head, adding several milliseconds of latency to each access. Solid state storage has no moving parts, so access time is essentially uniform regardless of where the data sits and random reads are served hundreds of times faster, which translates directly into the number of queries the system can serve. The trade off is cost per byte, which is significantly higher than magnetic storage, but for a workload where response time determines whether the service is usable, that cost is easily justified, and the capacity required for a transactional database is generally modest compared with archival data.
- LVirtual memory is an area of secondary storage used as an extension of RAM
- LPages not recently used are written out to free physical memory
- LThey must be read back when needed, which requires further paging
- LSecondary storage is orders of magnitude slower than RAM, so the processor waits
Virtual memory is a region of secondary storage, known as the page file or swap space, which the operating system uses as an extension of physical RAM so that the total memory available to running processes can exceed the RAM actually installed. When physical memory is exhausted, the operating system selects pages that have not been accessed recently and writes them out to the page file, freeing those physical frames for other use. Performance suffers because those pages will usually be needed again, and retrieving them requires reading from secondary storage and typically evicting something else to make room. Secondary storage is orders of magnitude slower than RAM even when it is solid state, so every page fault stalls the process for a period during which the processor has nothing useful to do. When physical memory is very badly oversubscribed the system reaches a state called thrashing, in which almost all processor time is spent moving pages back and forth and almost none is spent executing the programs themselves.