I/O Handling Methods

How does the CPU get notified of an I/O event?

  1. An OS is said to implement Polling I/O when the CPU continuously polls (= checks) whether an I/O device is ready to transfer data. Two main bits are involved in this procedure: the busy bit in the status register, and the command-ready bit in the control register. A typical output communication cycle (handshake) goes as follows:
    1. The CPU keeps looking into the busy bit until it turns to 0 (1 means busy and 0 means not busy anymore.)
    2. The CPU changes the write bit in the control register to 1, and writes the data to the data-out register.
    3. The CPU also changes the command-ready bit to 1 to indicate that it finished preparing data for the device.
    4. The device controller notices that write is on, so it reads the data-out register and performs the I/O action with the device (e.g., if the device is the screen, data is printed to the screen.)
    5. Finally, the controller puts 0 in the command-ready bit, puts 0 in the error bit to indicate that no errors happened, and puts 0 in the busy bit to indicate that the device is ready for new commands from the CPU.