ULK --- Chap 4: Interrupts and Exceptions (Note)

The Intel documentation classifies interrupts and exceptions as follows:

1. Interrupts:

Maskable interrupts: All Interrupt ReQuests (IRQs) issued by I/O devices give rise to maksable

interrupts. A maskable interrupt can be in two states: maksed or unmasked; a masked interrupt

is ignored by the control unit as long as it remains masked.

Nonmaskable Interrupts: Only a few critical events (such as hardware failures) give rise to non-

maskable interrupts. Nonmaskable interrupts are always recognized by the CPU. 

2. Exceptions

(1) Processor-detected exceptions: Generated when the CPU detects an anomalous condition while

executing an instruction. These are further divided into three groups, depending on the value of

the eip register that is saved on the Kernel Mode Stack when the CPU control unit raises the

exception.

Faults: Can generally be detected; once occurred, the program is allowed to restart with no loss of

continuity. The saved value of eip is the address of the instruction that causes the fault, and hence

that instruction can be resumed when the exception handler terminates. As we will see in the section

Page Fault Exception Handler, resuming the same instruction is necessary whenever the handler is

able to correct the anomalous condition that caused the exception.

Traps: Reported immediately following the execution of the trapping instruction; after the kernel

returns control to the program, it is allowed to continue its execution with no loss of continuity. The

saved value of eip is the address of the instruction that should be executed after the one that caused

the trap. A trap is triggered only when there is no need to reexecute the instruction that terminated.

The main use of traps is for debugging purpose. The role of the interrupt signal in this case is to

notify the debugger that a specific instruction has been executed (for instance, a breakpoint has been

reached within a program). Once the user has examined the data provided by the debugger, she may

ask that execution of the debugged program resume, starting from the next instruction.

Aborts: A serious error occurred; the control unit is in trouble, and it may be unable to store in the eip

register the precise location of the instruction causing the exception. Aborts are used to report severe

errors, such as hardware failures and invalid or inconsistent values in system tables. The interrupt signal

sent by the control unit is an emergency signal used to switch control to the corresponding abort exception

handler. This handler has no choice but to force the affected process to terminate.

(2) Programmed Exceptions

Occur at the request of the programmer. They are triggered by int or int3 instruction; the into (check for

overflow) and bound (check on address bound) instructions also give rise to a programmed exception when

the condition they are checking is not true. Programmed exceptions are handled by the control unit as traps;

they are often called software interrupts. Such exceptions have two common uses: to implement system calls

and to notify a debugger of a specific event.

Each interrupt or exception is identified by a number ranging from 0 to 255; Intel calls this 8-bit unsigned

number a vector. The vectors of nonmakable interrupts and exceptions are fixed, while those of maskable

interrupts can be altered by programming the Interrupt Controller.

posted on 2015-11-26 05:18  Persistence  阅读(212)  评论(0编辑  收藏  举报

导航