Shop OBEX P1 Docs P2 Docs Learn Events
Stack Size object — Parallax Forums

Stack Size object

James LongJames Long Posts: 1,181
edited 2009-04-16 05:58 in Propeller 1
Ok, I'm not a noob, but I have a question..

I have a program that I would like to test the required stack size. The program has multiple tiers, what is the best way to test?

Would I need to test each object independently, or test the whole group at once?

James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer

Lil Brother SMT Assembly Services

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-15 20:40
    I'm a noob with the propeller and my idea would be:
    Create a stack. Usually variable space is initialized with zeros. Run whatever test-code you want to run and then check the stack. The stack position with the last non-zero value should give you a good indication for the maximum stack size.
  • James LongJames Long Posts: 1,181
    edited 2009-04-15 20:43
    MagIO2 said...
    I'm a noob with the propeller and my idea would be:
    Create a stack. Usually variable space is initialized with zeros. Run whatever test-code you want to run and then check the stack. The stack position with the last non-zero value should give you a good indication for the maximum stack size.

    Well there is a stack object already, I just wondering if I can test with it using the total code, or must test each object separately.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-15 21:31
    I think it's not necessary to know how big the size of the stack needs to be per object or method. You need the big picture - you need to know how big the stack has to be for your usecases. Often objects provide more public functions than you use in your code. Often objects call private functions or their own public functions. And objects might use other objects. So, I'd simply call all functions you need to use and see how much stack they consume.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-16 05:58
    Hello,

    You have to test with the hole program. If you want the absolute maximum stacksize you have to make sure
    that the program runs in that way that it branches to that methods that will cause the maximum of nested calls
    with the maximum of parameters.

    This means to find out the REAL maximum you have to let it run in a lot of variants of how to branch to different methods

    A pragmatic solution to this is: as long as you are not running out of RAM is to set the stack to secure big values

    use the stacksize-object with an average program-run and add 20-30%

    best regards

    Stefan
Sign In or Register to comment.