80 likes | 160 Vues
Learn about the role of interrupts in Windows OS, including handling different types of exceptions and implementing exception handling mechanisms. Explore the importance of interrupt handlers and the structural exception handling approach in Windows. Dive into the concepts of interrupts for effective OS management.
E N D
Operating Systems Lesson 12
Plan • Interrupts • Windows and Interrupts • Structural Exception Handling • Exception Handling types • __try/__except • Sample: DivPtr
Interrupts • An event need an attention • Hardware event (pressed keyboard key) • Errors (division by zero) caused by specific CPU command • Timer (Check for context switch) • Software (not valid parameters to critical call) • Interrupt Handler • A routine to take care of interrupts • Address in interrupt dispatch table according to interrupt number • CPU save current state before invoking interrupt handler
Windows and Interrupts • Interrupt is very low level concept =>not directly exposed by user mode API’s • Hardware and Timer interrupts are supported through win32 synchronization objects (e.g. event) or Asynchronous Procedure Calls (APC) • Error handling interrupts are supported by Windows through Structural Exception Handling (SEH) mechanism.
Structural Exception Handling • An exception is an event that occurs during the execution of a program, and requires the execution of code outside the normal flow of control • Most of the exceptions are handled by debugger (check Debug/Exceptions menu of Visual Studio)
Exception Handling Types • Frame-based exception handling • Handle exceptions in particular code segment(‘frame”) • Vectored exception handling • Handles exceptions anywhere in applications • Windows: Frame-based exception handling implemented as C/C++ extension (new keywords)
__try/_except __try { // guarded body of code } __except (filter-expression) { // exception-handler block } Filter expression: Execute __except block Execute next command after erroneous Search for other exception handler