Shop OBEX P1 Docs P2 Docs Learn Events
Stacks — Parallax Forums

Stacks

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2006-05-11 16:21 in Propeller 1
What I have for reference seems a bit thin on stacks.

I see the Blinking LED routines using 20 longs each to just turn on and off an LED.· With only 512 longs, it seems very wasteful to use 40 longs for such mundane uses.

You see stacks identified in VAR, but no discussion of the them under that heading.
The listing _STACK presents the concept of setting space aside, but then again no basic criterial for sizing individual stacks.

When must a stack be used?· Always, sometime?
What is the minimum size?
How does one decide to allocate size? Pro and Con?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

Comments

  • CJCJ Posts: 470
    edited 2006-05-11 10:09
    stacks are in main memory, and only used by spin, the 512 only applies to asm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-05-11 14:27
    kramer said...

    when must a stack be used?· always, sometime? for spin, always
    what is the minimum size? depends on what the code is doing
    how does one decide to allocate size? Pro and con? phipi has posted a stack monitor program which tracks the number of stack elements used. You can use this program to optimize the size of your stacks.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-11 15:34
    In your multi-LED program each cog is actually running the Spin interpreter, not the method that you pass to the cog. That method resides in global memory with the stacks.

    Phil Pilgrim wrote a simple object that let's one monitor the stack used by an object; with this tool you can set your stacks to what the program actually needs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-05-11 16:21
    Sorry about the 512 number, but since stacks are assigned to COGs it still seems to average out to that if all the COGs are running.
    I guess you could have a biggie, like 4000 longs.

    At this point, I am merely requesting some introduction as neither the BasicStamp's PBasic or the SX/B employ the concept. It really is about bringing those users into SPIN.

    Obviously, there are occasions were less than 8 COGs will be needed and there are situations where COGs start up and stop. I am not exactly sure if RAM is dynamically reassigned or if once the program creates these dimensions, that the space is reserved.

    What say you guys?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.