I/O System Fundamentals
1. The Basic Concepts of the I/O System
The Definition of the I/O System
I/O system:
- Realises the exchange of information between the computer and the peripheral devices
- Has both a hardware part and a software part
- Is an essential part of the computer system
I/O devices:
- Input devices: bring external information into the computer
- Output devices: send the information of the computer out to the outside world
- External storage: stores large amounts of data
The Functions of the I/O System
Data exchange:
- Transfers data between the CPU and the I/O devices
- Supports different data formats
- Guarantees the reliability of data transfer
Device control:
- Controls the working state of the I/O devices
- Manages the start and the stop of a device
- Handles device exceptions
Information conversion:
- Converts the data formats
- Adapts to different device interfaces
- Handles signal level conversion
2. Peripheral Devices
Input Devices
Keyboard:
- A character input device
- Mechanical keyboards, membrane keyboards, capacitive keyboards
- Supports many input methods
Mouse:
- A graphical interface input device
- Mechanical mice, optical mice, laser mice
- Supports clicking, dragging, and other operations
Scanner:
- An image input device
- Flatbed scanners, handheld scanners
- Supports OCR text recognition
Camera:
- A video input device
- Digital cameras, network cameras
- Supports real-time video transmission
Output Devices
Monitor:
- An image output device
- CRT monitors, LCD monitors, LED monitors
- Supports different resolutions and refresh rates
Printer:
- A text and image output device
- Dot-matrix printers, inkjet printers, laser printers
- Supports colour and black-and-white printing
Speakers:
- An audio output device
- Active speakers, passive speakers
- Supports stereo and multi-channel audio
Projector:
- A large-screen display device
- LCD projectors, DLP projectors
- Supports high-resolution projection
External Storage
Hard disk:
- A large-capacity storage device
- Mechanical hard disks, solid state drives
- Supports fast reading and writing
Optical disc:
- A portable storage device
- CDs, DVDs, Blu-ray discs
- Supports both read-only and writable media
USB flash drive:
- A portable storage device
- Flash memory
- Supports hot plugging
Memory card:
- A small storage device
- SD cards, CF cards, memory sticks
- Used in digital devices
3. The I/O Interface
The Functions of the I/O Interface
Signal conversion:
- Converts the signal levels
- Adapts to different device interfaces
- Handles the signal timing
Data buffering:
- Buffers the data being transferred
- Balances the difference in speed
- Raises the transfer efficiency
Device control:
- Controls the working state of the device
- Manages the device registers
- Handles device interrupts
The Structure of the I/O Interface
Data lines:
- Transfer data information
- Support different data widths
- Transfer in both directions
Control lines:
- Transfer control signals
- Include read/write, interrupt, and other signals
- Coordinate the data transfer
Status lines:
- Transfer the status information of the device
- Include ready, busy, error, and other states
- Monitor the working state of the device
I/O Ports and Their Addressing
I/O port:
- Used for communication between the host and the peripherals
- Every port has a unique address
- Supports read and write operations
The addressing methods:
- Unified addressing: memory and I/O share one address space
- Independent addressing: memory and I/O are addressed separately
- Hybrid addressing: combines the two methods
The port types:
- Data port: transfers data
- Control port: transfers control information
- Status port: transfers status information
4. I/O Modes
Programmed I/O
Basic concept:
- The CPU actively polls the state of the device
- Checks whether the device is ready
- The efficiency is low
The working process:
- The CPU sends a command to the device
- The CPU polls the state of the device
- The data is transferred once the device is ready
- The polling repeats until the transfer is complete
Characteristics:
- Advantages: simple to implement, simple to control
- Disadvantages: low CPU utilisation, low efficiency
- Applications: simple systems, low-speed devices
Interrupt-Driven I/O
Basic concept:
- The device interrupts the CPU when it becomes ready
- The CPU responds to the interrupt and handles it
- Raises the CPU utilisation
The working process:
- The CPU sends a command to the device
- The CPU continues to execute other tasks
- The device raises an interrupt when it becomes ready
- The CPU responds to the interrupt and handles the data transfer
Characteristics:
- Advantages: high CPU utilisation, high efficiency
- Disadvantages: complex to implement, interrupt handling is needed
- Applications: most I/O devices
The DMA Mode
Basic concept:
- Direct memory access
- The data is transferred directly between memory and the peripheral
- The CPU only initiates and terminates the transfer
The working process:
- The CPU sets the parameters of the DMA controller
- The DMA controller takes over the bus
- The data is transferred directly between memory and the peripheral
- The DMA controller releases the bus once the transfer is complete
Characteristics:
- Advantages: a light load on the CPU, the highest efficiency
- Disadvantages: complex hardware, high cost
- Applications: high-speed devices, bulk data transfers
5. I/O System Performance
The Performance Metrics
Throughput:
- The amount of data transferred per unit of time
- Unit: MB/s, GB/s
- Reflects the overall performance of the I/O system
Response time:
- The time from the request to its completion
- Includes the queueing time and the service time
- Impacts the user experience
Utilisation:
- The rate at which the I/O devices are used
- Reflects the efficiency of the devices
- Impacts the performance of the system
Performance Optimisation
Hardware optimisation:
- Use high-speed interfaces
- Add more cache
- Optimise the device scheduling
Software optimisation:
- Optimise the I/O scheduling algorithms
- Reduce the number of I/O operations
- Use asynchronous I/O
System optimisation:
- Balance the performance of the components
- Reduce the I/O bottlenecks
- Raise the overall efficiency
Exercise 1
Briefly describe the basic functions of the I/O system.
Approach: List the five functions in the order in which the I/O system uses them — moving the data, controlling the devices, converting the information, managing the device resources, and handling the errors — and attach the concrete work of each.
Steps:
- Data exchange:
- Transfers data between the CPU and the I/O devices
- Supports different data formats
- Guarantees the reliability of data transfer
- Device control:
- Controls the working state of the I/O devices
- Manages the start and the stop of a device
- Handles device exceptions
- Information conversion:
- Converts the data formats
- Adapts to different device interfaces
- Handles signal level conversion
- Device management:
- Manages the device resources
- Handles device conflicts
- Provides the device drivers
- Error handling:
- Detects device errors
- Handles transmission errors
- Provides an error recovery mechanism
Answer: The basic functions of the I/O system are data exchange between the CPU and the I/O devices, device control that manages the working state, the start and the stop of a device, and its exceptions, information conversion of data formats, device interfaces, and signal levels, device management that allocates the device resources, resolves conflicts, and supplies the drivers, and error handling that detects device and transmission errors and provides a recovery mechanism.
Exercise 2
Give examples of input devices, output devices, and external storage.
Approach: Split the answer into the three categories the question asks for, and for each category give five concrete devices together with the capability that makes them worth naming.
Steps:
- Input devices:
- Keyboard: a character input device that supports many input methods
- Mouse: a graphical interface input device that supports clicking and dragging
- Scanner: an image input device that supports OCR text recognition
- Camera: a video input device that supports real-time video transmission
- Microphone: an audio input device that supports speech recognition
- Output devices:
- Monitor: an image output device that supports different resolutions
- Printer: a text and image output device that supports colour printing
- Speakers: an audio output device that supports stereo
- Projector: a large-screen display device that supports high resolution
- Plotter: a graphics output device used for engineering drawings
- External storage:
- Hard disk: a large-capacity storage device that supports fast reading and writing
- Optical disc: a portable storage device that supports read-only and writable media
- USB flash drive: a portable storage device that supports hot plugging
- Memory card: a small storage device used in digital devices
- Magnetic tape: a large-capacity backup device with a low cost
Answer: Input devices include the keyboard, the mouse, the scanner, the camera, and the microphone. Output devices include the monitor, the printer, the speakers, the projector, and the plotter. External storage includes the hard disk, the optical disc, the USB flash drive, the memory card, and the magnetic tape.
| Term | Abbreviation | Explanation |
|---|---|---|
| Input/Output system | IO | The interface system between the computer and the peripheral devices |
| Input device | - | A device that feeds data into the computer |
| Output device | - | A device that carries data out of the computer |
| Peripheral device | - | A device outside the host of the computer |
| I/O interface | - | The connecting circuit between the host and the peripherals |
| Port | - | An addressable register in the interface |
| Data port | - | The port that transfers data |
| Status port | - | The port that reads the state of the device |
| Control port | - | The port that sends control commands |
| Programmed I/O | PIO | The CPU polls the device state |
| Interrupt driven I/O | - | The device interrupts the CPU once it is ready |
| Direct Memory Access | DMA | The device accesses memory directly |
| Channel I/O | - | A dedicated I/O processor controls the I/O |
| Interrupt | - | Suspending the current program to handle an urgent event |
| Interrupt source | - | The origin that raises an interrupt request |
| Interrupt request | IRQ | The interrupt request signal raised by a device |
| Interrupt response | - | The process in which the CPU responds to an interrupt |
| Interrupt vector | - | The entry address of the interrupt service routine |
| Interrupt vector table | IVT | The table that stores the interrupt vectors |
| Interrupt priority | - | The ranking of the interrupts |
| Interrupt mask | - | The mechanism that forbids certain interrupts |
| Interrupt nesting | - | Responding to a higher-priority interrupt while handling one |
| DMA controller | DMAC | The hardware that controls a DMA transfer |
| Cycle stealing | - | The DMA borrows bus cycles from the CPU |
| Bus stealing | - | The DMA takes over the control of the bus |
| Simultaneous Peripheral Operations On-Line | SPOOLing | The virtual device technique |
