[comp.sys.ibm.pc.programmer] Turbo C 2.0 stdio re-entrancy

mbeck@wheaties.ai.mit.edu (Mark Becker) (06/09/90)

Hello *

I'm trying to do two things at once... keeping a time-of-day clock
running in the background and having the same program do some useful
work in the foreground.

This is all in small model.

My first naive try at this crashed out with a Stack Overflow error.

My second try had me reading the Waite Group's MS-DOS Developer's
Guide (Second edition, the sections on TSR's and DOS internal data
structures - InDos and Critical Error flags) and doing some reasonable
things associated with interrupt-driven procedures (saving registers,
switching PSP's, switching DTA's, establishing a separate stack, etc).

Stack Overflow again.

I get the impression that trying to use the same stdio routines
(printf et al) in background as foreground is getting me in trouble
but am unsure of a workaround for this.

Pointers would be appreciated.

Regards,
Mark Becker
mbeck@ai.mit.edu

smm@acd4.UUCP ( Steve McCoole ) (06/10/90)

In article <8930@rice-chex.ai.mit.edu> mbeck@wheaties.ai.mit.edu (Mark Becker) writes:
>
>I'm trying to do two things at once... keeping a time-of-day clock
>running in the background and having the same program do some useful
>work in the foreground.
>
>I get the impression that trying to use the same stdio routines
>(printf et al) in background as foreground is getting me in trouble
>but am unsure of a workaround for this.
>

You can't use printf or any other routine that tries to malloc memory
while you are in a TSR.  This may well be at least part of your problem.

>Pointers would be appreciated.

No problem.

Steve McCoole | Applied Computing Devices | smm@acd.com / uunet!acd.com!smm

mark@intek01.UUCP (Mark McWiggins) (06/14/90)

It doesn't make any difference whether or not Turbo 2.0 is re-entrant,
because DOS isn't.

This is a challenging problem, although there are "TSR kits" that have
been published in magazines and are probably archived in all the normal
places.  Perhaps best to start with one of those.

-- 
Mark McWiggins			Integration Technologies, Inc. (Intek)
+1 206 455 9935			DISCLAIMER:  I could be wrong ...
1400 112th Ave SE #202		Bellevue WA  98004
uunet!intek01!mark		Ask me about C++!