Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/36311

From BetaArchive Wiki

Implicit Resetting of the DTA in PSP by MS-DOS ID Number: Q36311

2.x 3.x 4.00 MS-DOS


Whenever MS-DOS loads a program, it sets the default DTA to offset 80h in that program’s PSP (program segment prefix). It does not, however, necessarily reset the DTA at program termination. Specifically, when the program is run through interrupt 21h service 4Bh (a.k.a. Execute Program or EXEC), on return to the parent program, the DTA is left pointing to the child’s DTA.

This can cause problems if the parent subsequently requests memory allocations that result in MS-DOS creating a memory paragraph header at the location of the child’s DTA and then issues a MS-DOS request that uses the DTA. The result is a “Fatal Memory Allocation Error,” which requires a reboot of the system. Is there a valid reason for MS-DOS to leave the DTA pointing into free memory upon termination of a program run through the EXEC service?


It is presumed that a MS-DOS program that uses the EXEC service is a “new” program. The DTA is primarily used by the “old” FCB-style calls. MS-DOS assumes that a program that is smart enough to use EXEC is not going to use the old FCB calls.

There is only one set of “new” calls that use the DTA. These calls are interrupt 21h service 4Eh (File Handle Find First) and interrupt 21h service 4Fh (File Handle Find Next). You should make sure that the DTA is explicitly set before making calls to these services.

MS-DOS does not explicitly reset the DTA pointer because the investment of time to save/restore the DTA address per task is an extremely poor use of limited space and time. There are more important things for MS-DOS to do than this. As stated above, a program should explicitly call interrupt 21h service 1Ah (Set DTA) to explicitly set the DTA to a known area before calling any MS-DOS services that use the DTA.