-
Notifications
You must be signed in to change notification settings - Fork 7
Exceptions
A exceptions are generated by the CPU when your program executes an action that is not allowed or erroneous. For example, if your program tries to divide an integer number by zero or it tries to access memory that does not exist.
Contrary to other systems like POSIX exceptions are not delivered as signals in Serena OS because signals are exclusively reserved as a high performance interprocess communication mechanism. Instead exceptions are delivered directly to a function defined by you that you specify with the excpt_sethandler function.
Exceptions are delivered synchronously. If a virtual processor executes an action that triggers an exception, the kernel suspends whatever code the virtual processor is executing and it then arranges for the invocation of the exception handler. The exception handler is executed and the original thread of execution is restored once the exception handler returns.
If a virtual processor triggers an exception and there is no exception handler set up for this virtual processor, then the kernel terminates the whole process.