Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!pyramid!decwrl!smaug.dec.com!desmond From: desmond@smaug.dec.com Newsgroups: comp.sys.ibm.pc Subject: MSC medium model TSR questions Message-ID: <8711130253.AA04513@decwrl.dec.com> Date: Thu, 12-Nov-87 21:53:00 EST Article-I.D.: decwrl.8711130253.AA04513 Posted: Thu Nov 12 21:53:00 1987 Date-Received: Sun, 15-Nov-87 03:09:16 EST Organization: Digital Equipment Corporation Lines: 30 I am working on a program that I want to terminate and stay resident and I have several questions that I would like answers to. First some background. The program will be written in a combination of Microsoft C v4.0 and 8086 assembly. It will be compiled under medium model in C and the .EXE will be approximately 200K. Now the questions: 1) How does one figure out where to mark the end of resident memory? I believe all data is loaded above the code so in small model I would probably be safe to take the address in DS plus 64K as the end of the image but what about the stack? Also since this is a medium model program, where are the far data elements loaded and how can I find out the highest address needed by my program after termination? 2) Once the program is resident, can it be terminated a second time with a normal exit thereby releasing all of its memory back to the system? Or is the only way to get back all available memory a reboot? I know there are some PD utilities that supposedly remove TSRs but I don't want to use something like that. I want a way for my program to remove itself if possible. 3) If after termination, the resident C code does some calls to malloc(), how is that allocation handled? If I confine my malloc calls to only near data, will all the data which is dynamically allocated come from my data segment? The problem is that once I terminate and give back all the memory I'm not using, some other application may take it. I don't want my malloc calls to fail because of insufficient memory. I would appreciate any information about these questions and anything else I should know about writing a TSR. Thanks. John