home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14890 < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.2 KB  |  63 lines

  1. Path: sparky!uunet!crdgw1!newsun!damurphy
  2. From: damurphy@wc.novell.com (Duane A Murphy)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: How to increase stack size ???
  5. Message-ID: <1992Sep2.154822.12924@novell.com>
  6. Date: 2 Sep 92 15:48:22 GMT
  7. References: <1992Sep1.145611.1@uwovax.uwo.ca>
  8. Sender: usenet@novell.com (The Netnews Manager)
  9. Organization: Novell, Inc. - Walnut Creek
  10. Lines: 50
  11. Nntp-Posting-Host: optics
  12.  
  13. In article <1992Sep1.145611.1@uwovax.uwo.ca> tschneid@uwovax.uwo.ca writes:
  14. >
  15. >I am working on a port of Gunplot 3.2 to the Mac. So far I have most
  16. >of the basics working (only a few bugs left) ... however, I keep
  17. >running out of stack space. I did some reading and found out that the
  18. >Mac only provides 8k of stack space and that it can be changed by doing
  19. >something like (in VERY rough C pseudo-code)
  20. >
  21. >        THz newapplimit;
  22. >
  23. >        newapplimit = 300*1024;    /* give app 300k */
  24. >        SetApplLimit(ApplLimit()+newapplimit);
  25. >        MaxApplLimit();
  26. >
  27. >Unfortunately, this does not work ...
  28. >
  29. >Can anyone enlighten me? I would like to set up a fixed stack size of
  30. >32k (i.e. not dependent on the memory allotted by the user in the 
  31. >applications info box). I am using Think C 5.02.
  32. >
  33. >Thanks,
  34. >Todd Schneider
  35.  
  36. I also ran into a stack limitation problem.  Actually the stack is handled 
  37. differently on different machines.  It is not consistent.  "Small" machines
  38. have an 8K stack.  "Large" machines have a 24K stack.  There is a low memory
  39. global "DefltStack" that determines the stack size at startup.  Dont mess 
  40. with this, it affects everyone.
  41.  
  42. After a few days of trying to figure out how the stack space is managed; 
  43. that is what pointers in the heap kept track of the stack to detect a
  44. stack heap collision, we came up with the following very simple solution.
  45.  
  46. #define STACK_MIN 0x8000L
  47. pascal Ptr StackPtr(void) = {0x2e8f};    /* MOVE A7, (A7) */
  48.  
  49. int main(void)
  50. {
  51.     SetApplLimit(StackPtr() - STACK_MIN);
  52. ...
  53.  
  54. The StackPtr() function came from the net (thanks to whomever suggested
  55. this).  The stack has no direct pointers to set its limits.  It is actuall
  56. controlled by heap limit pointers, namely ApplLimit.  This moves ApplLimit
  57. the where the current stack is at down the size of the stack that you
  58. want.
  59.  
  60. Hope this helps,
  61. ...Duane Murphy
  62. Novell, Walnut Creek
  63.