Exceptions

Prev: Exceptional Control Flow
TOC: Exceptional Control Flow
Next: Processes

Pasted image 20260428114420.png

  • Exceptions are a form of exceptional control flow (ECF) that are implemented partly by hardware and partly by the operating system, with details that can vary from system to system.
  • It's an abrupt change in the processor's control flow in response to some change in processor's state.
  • In the figure above as the processor is executing some current instruction Icurr when a significant change in processor's state occurs, the state is encoded in bits and signals, and the change of state is known as event.
  • The even could be related to the execution of current instruction like page fault or it could be unrelated to current instruction execution like some system timer going off or some I/O request's completing.
  • When processor detects that some event has occurred, it makes an indirect procedure class (exception) through a jump table called exception table, to an operating system subroutine (the exceptional handler) that is specifically designed to process this particular event.
  • When the exception handler is done processing, one of these three things can happen:
  • the handler returns control to the current instruction Icurr, the instruction that was executing when thee vent occurred.
  • The handler returns control to Inext, the instruction that would have executed next had thee exception not occurred.
  • The handler aborts the interrupted program.
  • Exception Handling

    Pasted image 20260428170640.png

    Classes of Exceptions

    Pasted image 20260428190851.png

    Interrupts:

    Pasted image 20260428192326.png

    Traps and System Calls

    Pasted image 20260428210446.png

    Faults

    Pasted image 20260428210821.png

    Aborts

    Pasted image 20260428211001.png

    Exceptions in Linux/x86-64 Systems

    In x86-64 systems:

    Pasted image 20260428211122.png

    Linux/x86-64 System Calls:

    Pasted image 20260428215400.png

    Prev: Exceptional Control Flow
    TOC: Exceptional Control Flow
    Next: Processes

    Powered by Forestry.md