A protected mode client terminates by executing an Int 21H in
protected mode, passing the value 4CH in register AH and a return code
in register AL. (This mimics the Int 21H Function 4CH termination
used by DOS applications in real mode.> The client has the following
responsibilities before termination:
When the DPMI host detects an Int 21H Function 4CH termination
request, it takes the following actions (the detailed comparison of
DPMI version 0.9 and version 1.0 host termination handling is in
Appendix C, page 158>:
- any extended memory blocks that were previously allocated with Function 0501H or 0504H are unlocked and freed (this is the
only cleanup action required by a DPMI V 0.9 host>;
- the client's local descriptor table (LDT) is freed in its
entirety by DPMI 1.0 hosts. (A DPMI version 0.9 client should clean
up its own segment descriptors before its termination since some DPMI
version 0.9 hosts may not free the terminating client's segment
descriptors if the client is not the primary client);
- physical address mappings created with Int 31H Function 0800H are freed;
- mappings created with Int 31H Functions
0508H or 0509H are destroyed;
- the client's interrupt descriptor table (IDT) is freed in it's
entirety and any client exception handlers installed through Functions 0203H, 0212H and 0213H are deregistered;
- any real mode regions that were unlocked with Function 0602H are relocked;
- any real mode callbacks that were allocated with Function 0303H are deallocated;
- the client's shared memory block allocations and serializations
are freed;
- any debug watchpoints that were set with Function 0B00H are cleared;
- the coprocessor state (if any) is restored to the default.
After the DPMI host performs the cleanup activities listed above, it
will switch to real mode and re-issue the Int 21H Function 4CH
interrupt, passing the return code from the DPMI client down to DOS.
DOS will then terminate the client as a real mode process by releasing
its DOS memory blocks (whether allocated by real mode Int 21H Function
48H or by DPMI Function 0100H), flushing
file buffers, closing file and device handles, and so on.
Clients should only terminate from their main thread of execution, and
should not issue the protected mode Int 21H Function 4CH from within a
hardware interrupt handler, exception handler, or real mode callback.
Client may, however, terminate from within a protected mode routine
that has been entered via the DPMI raw mode switch service. Clients
which wish to terminate-and-stay-resident to provide services to
protected mode clients should use DPMI
Function 0C01H rather than Int 21H Function 31H.
Note: Although the DPMI host monitors for Int 21H Function 4Ch
in protected mode, it ignores all other Int 21H Functions. DOS
Extenders typically install an interrupt 21H handler of their own in
order to trap and service DOS function requests by a protected mode
application; thus, the DOS Extender's Int 21H handler will always see
the Function 4CH termination request first. The DOS Extender should
perform any cleanup activities of its own and then pass the
termination request to the DPMI host by chaining the original owner of
the protected mode Int 21H vector.