cognew stack, can someone please explain this?
Cobalt
Posts: 31
The question is simple, and I hope that the answer is simple too:
When launching a new cog, you use the cognew command (we're talking spin). The command requires you define it a stack to use, for example:
I have a program that I want to launch a cog to do some talking with Phil's Voice synth object while other things are going on in the main cog. It would look something like this:
cognew(t.say("Hello"), @stack)
thats for example, I don't know how "Hello" would sound...
anyhow, the @ stack would be defined in the VAR block, but how do i determine what type of var (i.e. byte, word, long) to use, and what its size would be? (ex. long stack[noparse][[/noparse]10])
I looked over the manual, and refered to the beginning of it where it gives the basics of spin language by making multiple LED's flash. It just makes no sence to me as to how to figure out the size of the stack.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
while alive = 1
wakeup
program(propeller)
eat(3)
sleep(7)
When launching a new cog, you use the cognew command (we're talking spin). The command requires you define it a stack to use, for example:
I have a program that I want to launch a cog to do some talking with Phil's Voice synth object while other things are going on in the main cog. It would look something like this:
cognew(t.say("Hello"), @stack)
thats for example, I don't know how "Hello" would sound...
anyhow, the @ stack would be defined in the VAR block, but how do i determine what type of var (i.e. byte, word, long) to use, and what its size would be? (ex. long stack[noparse][[/noparse]10])
I looked over the manual, and refered to the beginning of it where it gives the basics of spin language by making multiple LED's flash. It just makes no sence to me as to how to figure out the size of the stack.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
while alive = 1
wakeup
program(propeller)
eat(3)
sleep(7)
Comments
There are programs that have been posted here that will initialize a stack space to known values, then watch the running program to see how much is actually used over a period of time.
All black magic, eh ?
-- Don
pointer, the return var ptr, and the return object pointer).
But in general, be generous with stack until you're short of memory. That is, start with something like 100 words
and only decrease it if you really need to.
Also, beware of doing things like
pub myfunc(a, b) | va[noparse][[/noparse]100]
that is, putting too much on the stack.