The layer below the File System is the Input/Output (I/O) system which controls all physical communication with external devices, such as disk drives, keyboard, printers and displays. If a higher layer requires access to a device, eg: if the file system wants to read a block from disk, a request is sent to the I/O layer.
Processes in the I/O layer are usually activated by means of interrupts. An interrupt occurs when an external device, such as a disk drive or communications port signals that it is ready to send or receive data. When the Kernel receives an interrupt it determined which device it came from and then calls upon the correct I/O process to handle the transfer.
There are two main categories of Input/Output: Character I/O, where the data is in the form of single numbers or characters (eg: keys pressed on a keyboard) and Block I/O, where larger blocks of data are to be transferred at the same time (eg: reading or writing a block from disk).
With Character I/O, only small amounts of data, normally a single byte, are transferred on each interrupt. The total amount of data to be transferred may be large, but it is broken into small quantities. The commonest character-mode devices are the keyboard, mouse, joysticks, communications ports and printers.
Block I/O is used when large amounts of data (eg: a 2,048 byte disk block) need to be read into or written back out from memory. Block-mode I/O could be carried out in the same way as character I/O, by reading or writing the data one byte at a time, but this is a waste of processor time.
Instead, the interrupting device carries out the transfer of the data into memory by itself. This is known as Direct Memory Access (DMA) and is used wherever large amounts of data need to be transferred between a device and contiguous memory locations as a block. All that the I/O process needs to do is tell the device where in memory to start writing the data and when to start. Another interrupt is sent when the device has finished transferring the data, and the I/O process informs the higher-level requesting process that data has been written or read.
Next: Device Drivers