zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    2020-01月-02月
    Work needing Technologies
    gcc和 gdb工具(转)
    pyenv and grunt-contrib-testem
    Statistics Books
    HTML5学习--SVG全攻略(基础篇)
    一个完整的学院网站实现过程
    JavaScript 常用单词整理
    一张图教会CSS3倒影
    Python大数据处理案例
  • 原文地址:https://www.cnblogs.com/miaoyong/p/4996508.html
Copyright © 2011-2022 走看看