exceptions & interrupts
Concept
Exceptions
- might occur when executing machine level instructions
- arithmetic errors:
- overflow, underflow, divide by zero
- memory errors:
- illegal mem address, mis-aligned memory access
- synchronous, occurs due to program execution
- program is terminated and exception handler is executed automatically
Interrupts
- external events that interrupt the program execution
- e.g. timer, mouse movement, keyboard input
- program is suspended and interrupt handler is executed automatically
ctrl + cto interrupt programs in the terminal
Handlers
- save register and CPU state
- perform handler routine
- restore register and CPU
- return
- control is transferred to the handler automatically on exception/interrupt
Application
Program that cannot be interrupted by ctrl + c