How OS/2 Chains Exception Handlers

When you register an exception handler, you place the address of the handler and the chain pointer from the thread information block (TIB) in an EXCEPTIONREGISTRATIONRECORD structure, and then update the TIB to point to the new EXCEPTIONREGISTRATIONRECORD. The operating system finds exception handlers by following a chain rooted in the TIB.

Here is a diagram of the TIB chain:

 

Each EXCEPTIONREGISTRATIONRECORD is chained to the next. When an exception occurs, the operating system begins at the TIB and goes to each EXCEPTIONREGISTRATIONRECORD in turn. It calls the exception handler and passes it the exception information.

The exception handler either handles the exception or tells the operating system to pass the exception to the next handler in the chain. If the last exception handler in the chain, identified by chain pointer with value -1, does not handle the exception, the operating system takes the default action.

An EXCEPTIONREGISTRATIONRECORD must be on the stack, and each record must be at a higher address than the previous one.



Signals and Exceptions


Write or Register an Exception Handler


OS/2 Default Exception Handling
Prototype of an OS/2 Exception Handler
Exception Information Provided by OS/2
Prototype of an OS/2 Exception Handler
OS/2 APIs That Interfere with Exception Handling