Chapter 4. Interrupts and Exceptions
An interrupt is usually defined as an event that alters the sequence of instructions executed by a processor. Such events correspond to electrical signals generated by hardware circuits both inside and outside the CPU chip.
Interrupts are often divided into synchronous and asynchronous interrupts :
1、Synchronous interrupts are produced by the CPU control unit while executing instructions and are called synchronous because the control unit issues them only after terminating the execution of an instruction.
2、Asynchronous interrupts are generated by other hardware devices at arbitrary times with respect to the CPU clock signals.
NOTE : 两者的来源不同,一个是源自CPU,一个是源自其他的**hardware devices**
Intel microprocessor manuals designate synchronous and asynchronous interrupts as exceptions and interrupts, respectively. We'll adopt this classification, although we'll occasionally use the term "interrupt signal" to designate both types together (synchronous as well as asynchronous).
英特尔微处理器手册分别将同步和异步中断指定为异常和中断。 我们将采用这种分类,尽管我们偶尔会使用术语“中断信号”来指定两种类型(同步和异步)。
Interrupts are issued by interval timers and I/O devices; for instance, the arrival of a keystroke from a user sets off an interrupt.
Exceptions, on the other hand, are caused either by programming errors or by anomalous(异常的) conditions that must be handled by the kernel. In the first case, the kernel handles the exception by delivering to the current process one of the signals familiar to every Unix programmer. In the second case, the kernel performs all the steps needed to recover from the anomalous condition, such as a Page Fault or a request via an assembly language instruction such as int
or sysenter
for a kernel service.
We start by describing in the next section the motivation for introducing such signals. We then show how the well-known IRQs (Interrupt Requests) issued by I/O devices give rise to interrupts, and we detail how 80x86 processors handle interrupts and exceptions at the hardware level. Then we illustrate, in the section "Initializing the Interrupt Descriptor Table," how Linux initializes all the data structures required by the 80x86 interrupt architecture. The remaining three sections describe how Linux handles interrupt signals at the software level.
NOTE: 思考Unix signal和exceptions和interrupts之间的关系。Unix signal都对应的是exceptions?关于这个问题,参加《docs/Programming/Signal/Signal.md》