ECM 1413 I/O devices Flashcards
What does an I/O device do?
I/O devices enable computers to receive or output information to humans or devices.
Types of I/O devices (+ examples for each)
human interface devices, such as screens or keyboards
storage devices, such as disks
transmission devices, such as network cards
What is communication between I/O devices performed over?
Buses
What does a controller do in the context of I/O devices?
The I/O devices are operated using controllers (embedded processors)
The processor communicates with the controller by reading and writing to the controller’s registers.
What are the registers in question?
data-in register — data coming from device
data-out register — data going to device
status register — indicating status of device
control register — commands to device
How can controller registers be accessed?
special instructions (port-based I/O):
the CPU uses special I/O instructions for transferring a small number of bytes to an I/O bus address
standard memory instructions (memory-mapped I/O):
the CPU treats the device “as memory”; control registers are mapped to specific memory addresses
Differences between Port-mapped I/O (PMIO) and Memory-mapped I/O (MMIO)
PMIO uses a separate IO address space; this is treated as part of memory space in MMIO.
MMIO only requires standard memory instructions to access registers as they are a part of main memory; PMIO needs special instructions to access the IO address space.
MMIO is more common than PMIO
The 2 approaches to controlling IO devices
1 polling
2 interrupts
Polling
The CPU repeatedly checks the controller’s status register to see whether the controller is busy
When the controller is ready and the CPU wants to give new instructions, the CPU writes to the data-out register and signals that is has done so through the control register
Interrupts
Interrupts The CPU regularly senses an interrupt-request line
When the CPU gets an interrupt signal through the interrupt-request line, it stops the current process and initiates a response
Differences between polling and interrupts
Interrupts can monitor the status of several devices at the same time, and serve them based on priority
Polling needs to check each device individually in a round-robin fashion
Interrupts are much more commonly used since this frees the CPU from polling devices that do not need service
Polling may be efficient if
the controller and the device are fast
the I/O rate is high
some I/O data can be ignored
the CPU has nothing better to do
Large Data Transfers
Some devices (e.g., disk drives) will often do large data transfers
The transfer will be inefficient if the CPU has to feed data, byte by byte, to the controller’s registers
A better approach is to offload this work to a special-purpose processor (a direct memory access (DMA) controller)
How does Direct Memory Access work
The CPU writes a command block into memory, specifying the source and destination of the transfer
The DMA controller can then perform multiple transfers via a single command
When the transfer is complete, the CPU receives an interrupt from the DMA controller
This enables the CPU to spend more resources on other tasks
What does a device driver do
A device driver hides differences between various device controllers by defining an interface between the OS and I/O devices for a specific class of I/O devices.