In: Computer Science
does the exception handler run in kernel mode?
Yes, the exception handler run in kernel mode.
There is a way to get into kernel mode from user mode and that is when an exception occurs on the cpu.
If the running program performs some illegal operation eg:a divide by zero, then the cpu issues an exception. Again the cpu switches to kernel mode and is diverted to some location unknown to the program where the machine code exists to deal with the exception.
The exception handler's job is to decide if the problem is recoverable or not. If the problem cannot be recovered, the program is terminated without the cpu ever returning back to the program.
If the exception can be recovered, the handler takes the steps required to do this and returns the cpu back to the culprit instruction, so that it can be percormed again.
In this situation, the program will have no idea that anything went wrong.