Edexcel International Advanced Level Computer Science, point 11.2.1
Definition and function
I/O device management is how the operating system and system software control the input, output and storage devices connected to a computer: keyboards, mice, screens, printers, disks, network cards and so on. (The OS's peripheral management role was introduced in 1.2.1.)
Why needed: there are thousands of different devices, all much slower than the CPU and using different signals and formats. Without management, every program would need to know about every device, and the CPU would waste time waiting.
a. The role of device drivers
- Definition: a device driver is a small program that lets the operating system communicate with a particular hardware device, translating general OS commands into the specific signals the device understands.
- Operation: an application asks the OS to "print this". The OS passes the request to the printer's driver, which sends the right commands to that printer model.
- Benefits: the OS and applications don't need to know the device's details (abstraction, 10.1.1), new devices can be added by installing a driver (plug and play), and drivers can be updated to fix bugs or add features.
- Drawbacks: a faulty or malicious driver can crash the system or compromise security (it runs with high privilege), a missing or incompatible driver means the device won't work, and drivers must be written for each OS.
b. The basic input/output system (BIOS)
- Definition: the BIOS is firmware stored on a chip on the motherboard, which runs when the computer is switched on. (Modern machines use its successor, UEFI, with the same purpose.)
- Functions:
- POST (power-on self test): checks the hardware (memory, CPU, keyboard).
- Initialises hardware so that it is ready to use.
- Finds the boot device and loads the bootstrap loader, which loads the operating system into RAM.
- Provides basic low-level I/O routines, and stores settings (boot order, system time) that can be changed in a setup screen.
- Characteristic: it is stored in non-volatile memory (flash), so it is available before any OS or disk is loaded.
c. The role of buffering
- Definition: a buffer is a temporary area of memory that holds data while it is being moved between two components that work at different speeds.
- Operation: the fast CPU puts data into the buffer and carries on with other work. The slow device reads from the buffer at its own pace (or the reverse for input).
- Benefits: the CPU doesn't wait for slow devices, data flows smoothly (streaming video buffers ahead so playback doesn't stutter), and transfers can be done in efficient blocks.
- Drawbacks: uses memory, adds a small delay, and data in the buffer is lost if there's a power failure (so buffers are flushed before ejecting a USB drive).
- Double buffering: two buffers: one is filled while the other is emptied, so there's no waiting.
- Spooling (1.2.1) is buffering to disk for devices such as printers.
d. The role of caching
- Definition: caching stores copies of frequently or recently used data in faster storage (see the memory hierarchy, 1.1.6).
- In I/O: a disk cache keeps recently read disk data in RAM, so repeated reads don't touch the slow disk. Write caching collects writes and sends them to disk later in a batch. Read-ahead loads the next blocks before they are asked for.
- Benefits: much faster access to repeated data, and fewer physical disk operations (longer drive life).
- Drawbacks: stale data if the original changes, uses RAM, and cached writes can be lost in a power cut.
Buffering and caching compared
| Buffer | Cache | |
|---|---|---|
| Purpose | Smooth the speed difference while moving data | Speed up repeated access to the same data |
| Holds | Data in transit, usually used once | Copies of data likely to be reused |
| Example | Print job waiting, video stream | Recently read disk blocks |
e. Interrupt handling in device management
- Definition: devices use interrupts to tell the CPU that they need attention (1.2.2), instead of the CPU repeatedly checking them (polling).
- Operation in I/O:
- The CPU starts an I/O operation (for example "read this disk block"), then carries on with other work.
- The device does the transfer (often directly with memory, using DMA).
- When finished, the device sends an interrupt.
- The CPU finishes its current instruction, saves its state, runs the interrupt service routine (ISR) for that device (from the interrupt vector table), then restores and resumes.
- The ISR may move data between the device and a buffer and make the waiting process ready to run again.
- Examples: a key press, a mouse click, the printer is out of paper, a disk transfer is complete, a network packet has arrived.
- Priorities: urgent interrupts (hardware failure) are served before routine ones (keyboard).
- Benefits: efficient use of the CPU and fast response.
A diagram of I/O in a computer system
You may be asked to complete or interpret such a diagram, so know where the driver, buffer and interrupt fit.
Worked example
Task: a user prints a 50-page document while continuing to type in another program. Explain how drivers, buffering and interrupts make this possible.
- The word processor asks the OS to print. The printer driver converts the document into printer commands.
- The commands are placed in a buffer (spooled to disk), and the CPU is free again almost at once.
- The printer takes data from the buffer at its own slow speed.
- Meanwhile, typing causes keyboard interrupts: for each key press the CPU runs the keyboard ISR, stores the character and returns to its work.
- When the printer needs more data (or finishes, or runs out of paper), it sends an interrupt, and the printer ISR responds.
Without the buffer, the user would wait for the printer. Without interrupts, the CPU would have to keep checking the printer and keyboard. Without the driver, the OS wouldn't know how to talk to this printer.
Exam tip: be able to state the role of each (driver: translates; BIOS: starts the computer and loads the OS; buffer: smooths speed differences; cache: keeps copies for reuse; interrupt: signals the CPU). Don't confuse buffer and cache. For interrupts, show save state, run the ISR, restore, resume.
Check yourself
What does a device driver do?
It lets the operating system communicate with a particular device, translating general OS commands into the signals that device understands.
What does the BIOS do when a computer starts?
It runs a power-on self test, initialises the hardware, and finds the boot device so the bootstrap loader can load the operating system.
Why is a buffer used between the CPU and a printer?
The printer is much slower than the CPU, so the CPU puts data in the buffer and carries on while the printer reads from it at its own pace.
What is the difference between buffering and caching?
A buffer holds data in transit between devices of different speeds. A cache keeps copies of data likely to be reused so repeat access is faster.
Why do devices use interrupts instead of the CPU polling them?
The CPU doesn't waste time repeatedly checking devices, and it can respond promptly when a device needs attention.