You are typing a message to a friend. In the background a 700 MB file is downloading, and a song is playing in your earphones. The processor under your keyboard performs about three billion clock cycles every second, and yet the moment you press the letter A, it appears on the screen. Nobody told the processor to look at the keyboard at that exact instant. A quick typist manages about six keys a second, so between two keystrokes the processor lets 500 million clock cycles go by. How does it notice the one that matters? And how do the download and the song get into memory without the processor carrying every byte itself?
This is the problem of input and output, I/O for short. Devices are slow, they come in many shapes, and they decide for themselves when they have something to say. The processor is fast and always busy. This chapter gives three answers, and each one repairs a flaw in the one before. The processor can keep asking the device whether it is ready, which is polling.
The device can ring a bell when it is ready, which is an interrupt. Or the processor can hand the whole job to a helper that moves a block of data by itself, which is DMA. Exams ask about all three, nearly always in the form "which is better, and why?", and we will answer that with real CPU-time sums.
By the end of the chapter you will be able to say what an I/O module is and what its registers do, and you will recognise input, output and storage devices. You will describe programmed I/O, interrupt-driven I/O and DMA, and work out how much of the CPU each one costs. You will sort interrupts into their kinds, list the steps the CPU takes when one arrives, and show what happens to the stack.