INF: Avoid Using C Run-Time Library Routines in TSRs

ID Number: Q47105

5.10 6.00 6.00a 6.00ax 7.00

MS-DOS

Summary:

Microsoft does not recommend using standard library routines in

terminate-and-stay-resident (TSR) programs at all, even though they

may appear to be safe. The main problem is that although the library

routines may be safe in this version of the compiler, they may change

in future versions. Microsoft does not support using the run-time code

in a TSR.

In particular, you can have severe problems with chkstk(), sprintf(),

malloc(), realloc(), and free(). It is likely that the other routines

won't cause big problems, but without going through the source and

knowing EXACTLY what you're doing, there is no way to be sure.

There is, however, an excellent alternative. Microsoft offers the

run-time library source for sale. Call our Microsoft Sales number

for pricing and to order. With this source, you have almost total

control over what your TSR looks like and how it acts. You can

inspect each routine you use to ensure that it won't cause any

interactions you don't want, and you can modify those routines that

do. You're also better insulated against later modifications to the

run-time library; since you control the code, you can modify it when

you need to. This is by far your best alternative. You'll KNOW what's

going on and you'll be able to ensure that you can maintain your

applications. The only routines not included in this source are the

floating-point and graphics routines.

You may be able to find a source for routines written to support TSR

programming even though Microsoft does not offer such software. Look

for ads in the programmer-oriented PC magazines or call some of the

programming-oriented software dealers.

The run-time source allows you to determine which functions call

MS-DOS through INT 21h and which don't. Having the source also allows

you to come up with alternative strategies for those functions that

make calls.

The "MS-DOS Encyclopedia" (published by Microsoft Press) is an

excellent source of information about writing TSRs.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00