- Forward


Exceptions and Interrupts
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Review
Back SMYC Forward
  • Notation:
    • The sequence of addresses are denoted by \(a_0, a_1, \dots, a_{n-1}\)
    • \(a_k\) denotes the address of instruction \(I_k\)
  • Control Transfer:
    • A transition from \(a_k\) to \(a_{k+1}\) is called a control transfer and denoted by \(t_k\)
  • The Flow of Control:
    • A sequence of control transfers is called the flow of control (or control flow) of the processor
Smooth and Non-Smooth Control Flow
Back SMYC Forward
  • Smooth Flow:
    • \(I_{k+1}\) is adjacent to \(I_{k}\) (i.e., \(a_{k+1} = a_k + S(I_k)\), where \(S(I_k)\) denotes the size of instruction \(I_k\))
  • Some "Normal" Causes of Abrupt Changes:
    • jumps, calls, returns
  • Some "Exceptional" Abrupt Changes:
    • Abrupt changes that are not captured by internal program variables (e.g., dealing with a hardware timer)
    • Abrupt changes that are not related to the execution of the program (e.g., data arriving at a network adapter)
Exceptions and Interrupts
Back SMYC Forward
  • Defined:
    • An abrupt change in the control flow as a result of a change in the processor's state (called an event)
  • What Happens (assuming \(I_k\) is executing):
    1. The processor detects that an event has occurred
    2. A jump table is used to transfer control to a handler (which runs in kernel mode)
    3. The program is aborted OR control is returned to \(I_k\) OR control is returned to \(I_{k+1}\) (in user mode)
  • Exceptions vs. Interrupts:
    • Exceptions (including traps, faults, and aborts) are said to be synchronous (i.e., due to the execution of an instruction)
    • Interrupts are said to be asynchronous (i.e., not due to the execution of any instruction)
Exceptions and Interrupts (cont.)
Back SMYC Forward
  • At "Design Time":
    • Each exception/interrupt is assigned a unique nonnegative integer
  • At Boot Time:
    • A jump table is created that associates exception/interrupt \(i\) with the address of the appropriate handler
    • The starting address of the jump table is stored in the exception/interrupt table base register
Interrupts
Back SMYC Forward
  • Cause:
    • A signal (not caused by the execution of any particular instruction) from an I/O device that is external to the processor
  • Return Behavior:
    • Return to \(I_{k+1}\)
Traps
Back SMYC Forward
  • Cause:
    • An intentional result of executing an instruction
  • An Example:
    • System calls
  • Return Behavior:
    • Return to \(I_{k+1}\)
Faults
Back SMYC Forward
  • Cause:
    • A potentially recoverable error
  • An Example - Page Faults:
    • An instruction that references a virtual address whose corresponding page is not resident in memory (and must be retrieved from disk)
  • Return Behavior:
    • Return to \(I_{k}\) (if the fault can be corrected)
Aborts
Back SMYC Forward
  • Cause:
    • Unrecoverable error
  • Examples:
    • Parity errors resulting from corrupted bits in DRAM or SRAM
    • Divide errors
    • Segmentation "faults" (i.e., a reference to an underfined area of virtual memory)
  • Return Behavior:
    • Does not return
There's Always More to Learn
Back -