[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] stack size!



I delete a lot of messages yesterday, trying to catch up on my email,
but I hope I didn't miss anything relevant to this.

> I would love to know how to determine the stack size (maybe there´s a
> compiler switch for generating additional code that would check the
> stack during program run and list the stack usage at the program exit?).

Lattice C can at least inform you when you overrun your stack, if you
tell it to do so.
Finding out how much stack is actually needed is of course another matter,
but adding a little code to fill the entire (too large) stack area with
something recognizable (and unlikely to occur spontaneously (my favourite
is $BADCODE1 ;-)) and then looking for that after the program has ended
should work well. Naturally, some programs may use different amounts of
stack on different runs...

> Real solution would be to make the stack dynamical, but this would
> probably slow the applications down quite a bit :-(

I don't think that would even be possible.
There is often data on the stack that can't be relocated (without extra
information which normally isn't available), and current Atari 'standards'
place the stack either in the BSS section or simply adds the space to the
end of the memory area otherwise in use (CODE/DATA/BSS).
Neither of those methods makes it possible for the OS to do anything about
the size.  :-(


Since this is obviously a problem, I think it would be very useful to
define a new standard way of allocating the stack. A way that can be
modified to dynamically extend the stack once we get proper virtual
memory support (we may already have that for '030s, but I can't run it on
my AB040 so I've never tested it).
We could of course not expect this method to be supported by old
software or all operating systems. However, it should not be harder to have
multiple behaviours for this than for other MiNT/TOS differences in the
libs and/or startup code.

-- 
  Chalmers University   | Why are these |  e-mail:   rand@cd.chalmers.se
     of Technology      |  .signatures  |            johan@rand.thn.htu.se
                        | so hard to do |  WWW/ftp:  rand.thn.htu.se
   Gothenburg, Sweden   |     well?     |            (MGIFv5, QLem, BAD MOOD)