I/O Handling Methods

How does the CPU read data from an I/O device?

  1. When a CPU reads data one byte at a time, we say that the OS uses Programmed I/O. Here, the CPU gets direct access to each piece of the transferred data.
  2. In order to 'free' the CPU from reading all the data, an OS might introduce an additional processor called a direct-memory access controller or DMA controller whose sole purpose is to manage I/O data. The process goes as follows:
    1. The main CPU issues a command to the DMA controller with the following info: (1) the device to which data should be transferred, (2) the location to the beginning of the data within memory, and (3) the total number of bytes to be transferred. Note that (2) and (3) tell precisely what chunk of data should be transferred.
    2. The DMA controller proceeds to handle the I/O, while the main CPU continues executing other instructions.
    3. When the DMA finishes its work, it raises an interrupt to inform the CPU that the data transfer is complete.