Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!PT!b.gp.cs.cmu.edu!ralf From: ralf@b.gp.cs.cmu.edu (Ralf Brown) Newsgroups: comp.sys.ibm.pc Subject: Re: signal() for Turbo C Message-ID: <88@b.gp.cs.cmu.edu> Date: Thu, 27-Aug-87 21:13:00 EDT Article-I.D.: b.88 Posted: Thu Aug 27 21:13:00 1987 Date-Received: Sun, 30-Aug-87 03:05:01 EDT References: <1009@bsu-cs.UUCP> <2670002@hpsrla.HP.COM> <1059@bsu-cs.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 45 In article <1059@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: >In article <2670002@hpsrla.HP.COM> darrylo@hpsrla.HP.COM (Darryl Okahata) >writes about my signal() for Turbo C: >> [...] > >When I tested the signal() handler code, I did run out of stack space. >Then I initialized _stklen to a bigger value and the program ran >correctly. So any shortage of stack space is occurring simply because >the Turbo C stack is not big enough. The default stack, if you don't >create _stklen, is only 128 bytes, which is peanuts. NO! The default stack length is 4096 bytes (there is a module in the library whose sole purpose is to define _stklen). The 128 bytes is the initial startup stack, which gets moved as soon as C0.ASM figures out where to place it. No matter what value you give _stklen, the startup stack stays 128 bytes. >Also note that I believe that the small model start-up code for Turbo C >does not properly handle _stklen to set a bigger stack. I changed and >recompiled the startup module for the small memory model to fix this >apparent bug. I made the following changes in C0.ASM: Actually, the bug is in determining how much memory to allocate to the program. The problem is that when less than 64K is available in tiny model, the code does not use all available memory, but only CODE+DATA+minSTACK, where minSTACK is 256 bytes. My fix for this (posted some time ago) is to change the two lines in C0.ASM between the two "ja ExcessOfMemory" statements to mov di,bp cmp bp,bx DI contains the amount to allocate, BP contains the amount available, and BX contains the minimum amount needed. (Which is too little, because it only allocates 256 bytes for the stack). Note that this patch can also be applied to the .COM file, as the instructions are the same size as those they replace. >-- >Rahul Dhesi UUCP: {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi -- -=-=-=-=-=-=-=-= {harvard,seismo,ucbvax}!b.gp.cs.cmu.edu!ralf =-=-=-=-=-=-=-=- ARPAnet: RALF@B.GP.CS.CMU.EDU BITnet: RALF%B.GP.CS.CMU.EDU@CMUCCVMA AT&Tnet: (412) 268-3053 (school) FIDOnet: Ralf Brown at 129/31 DISCLAIMER? Who ever said I claimed anything? "I do not fear computers. I fear the lack of them..." -- Isaac Asimov