Acore responsibility of any operating system kernel is managing the hardware con- nected to the machine—hard drives and Blu-ray discs, keyboards and mice, 3D processors and wireless radios.To meet this responsibility, the kernel needs to communicate with the machine’s individual devices. Given that processors can be orders of magnitudes faster than the hardware they talk to, it is not ideal for the kernel to issue a request and wait for a response from the significantly slower hardware. Instead, because the hardware is com- paratively slow to respond, the kernel must be free to go and handle other work, dealing with the hardware only after that hardware has actually completed its work. How can the processor work with hardware without impacting the machine’s overall performance? One answer to this question is polling. Periodically, the kernel can check the status of the hardware in the system and respond accordingly. Polling incurs overhead, however, because it must occur repeatedly regardless of whether the hardware is active or ready.A better solution is to provide a mechanism for the hardware to signal to the kernel when attention is needed.This mechanism is called an interrupt. In this chapter, we discuss interrupts and how the kernel responds to them, with special functions called interrupt handlers.
操作系统的核心任务是管理和机器相连的硬件,磁盘,麦克等。为了能够完成这个任务,内核需要和特定的设备打交道。