5.2.2 Types of Unwind

There are two types of unwind requests; general unwind and exit unwind:

General Unwind

A general unwind transfers control to a specified location in a specified procedure invocation.

The target procedure invocation is specified by a frame pointer.

The target location is specified with an absolute PC value.

When a general unwind is completed, the registers are updated from the invocation context for the target frame. Register R0 obtains its value from the ReturnValue argument to unwind, allowing a status to be returned to the target of the unwind.

Exit Unwind

It is valuable for a thread that is terminating execution to be able to clean up its use of shared resources. In a single-threaded process, these might be global resources shared among processes, such as files, locks, or shared memory. For multithreaded processes, global resources plus processwide resources like a heap might need to be restored to a known state.

Because of this, user mode thread exit may be accomplished only by unwinding. A special case form of unwind, termed exit unwind, invokes all established frame-based handlers with an exception record specifying that an exit unwind is in progress, terminates all procedure invocations up to the beginning of the call chain, and terminates execution of the thread. Threads that use any other mechanism are not considered standard and their behavior is undefined.