Chinaunix首页 | 论坛 | 博客
  • 博客访问: 55740
  • 博文数量: 47
  • 博客积分: 2095
  • 博客等级: 大尉
  • 技术积分: 560
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 18:42
文章分类

全部博文(47)

文章存档

2011年(1)

2008年(46)

我的朋友

分类: LINUX

2008-05-09 00:47:21

Interrupts and Exceptions

The Intel documentation classifies interrupts and exceptions as follows:

Intel文档将中断和异常这样分类:

·         Interrupts:

Maskable interrupts

可屏蔽中断

All Interrupt Requests (IRQs) issued by I/O devices give rise to maskable interrupts. A maskable interrupt can be in two states: masked or unmasked; a masked interrupt is ignored by the control unit as long as it remains masked.

所有由I/O设备提出的IRQ(中断请求)产生可屏蔽中断。可屏蔽中断可以有两种状态:已屏蔽和未屏蔽;一个已屏蔽中断被控制单元忽略,只有它一直保持在屏蔽状态。

Nonmaskable interrupts

不可屏蔽中断

Only a few critical events (such as hardware failures) give rise to nonmaskable interrupts. Nonmaskable interrupts are always recognized by the CPU.

只有少数关键事件(比如硬件故障)产生不可屏蔽中断。不可屏蔽中断总是可以被CPU识别。

·         Exceptions:

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.

CPU在执行某个指令,检测到一个不寻常的状态时产生。当CPU控制单元产生异常时,根据存放在内核栈内的eip寄存器的值,又分为三种:

Faults

Can generally be corrected; once corrected, the program is allowed to restart with no loss of continuity. The saved value of eip is the address of the instruction that caused the fault, and hence that instruction can be resumed when the exception handler terminates. As we'll see in the section "Page Fault Exception Handler" in Chapter 9, resuming the same instruction is necessary whenever the handler is able to correct the anomalous condition that caused the exception.

通常可以被纠正;一旦被纠正,程序就允许重新开始而不失连续性。保存的eip的值是引起fault的指令地址,因此当异常处理结束时,这个指令可以被恢复。无论何时,引起异常的不寻常状态被异常处理纠正,恢复同一个指令是必要的。

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 purposes. 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.

在陷阱指令执行后立刻发出;在内核回到程序的控制时,容许继续执行而不失连续性。保存在eip中的值是引起陷阱那个指令后应该执行的指令的地址。陷阱的主要作用是为了调试。这种情况下中断信号的角色是通知调试器一个特定的指令被执行了(比如,到了程序的某个断点)。一旦用户检查完了调试器提供的数据,她可能要求被调试的程序从下一条指令开始继续运行。

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.

发生一个严重的错误;控制单元遇到麻烦,它可能不能够将引发这个异常的指令的准确位置存放eip寄存器中。Abort用来报告错误,比如硬件故障,系统表中无用或不一致的值。控制单元发送的这个中断信号是紧急信号,用来切换控制到对应的abort异常处理函数。这个函数没有选择只能强迫受到影响的进程终止。

Programmed exceptions

可编程异常

Occur at the request of the programmer. They are triggered by int or int3 instructions; 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 (see Chapter 10).

发生自程序员的请求。它们是通过int或者int3指令触发的;into(检查溢出)和bound(进程地址边界)指令,在发现检查条件不为真时,也会产生一个可编程异常。可编程异常由控制单元处理为陷阱;它们经常叫做软件中断。这种异常有2中常见的用途:实现系统调用和通知调试器一个特定的事件。

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 nonmaskable interrupts and exceptions are fixed, while those of maskable interrupts can be altered by programming the Interrupt Controller (see the next section).

每个中断或异常由一个范围在0255之间的数字标识;intel称这个8bit的无符号数为向量。不可屏蔽中断和异常的向量是固定的,而可屏蔽中断的向量可以通过设置中断控制器来修改。

阅读(453) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~