Objects sharing Main Ram
Bob Drury
Posts: 236
Is there an explanation on how Propeller spin code runs multiple objects with the stack space
Thanks for your help
Thanks for your help
Comments
Basically, when you do a COGNEW or COGINIT, the Spin interpreter starts a new cog using a COGNEW/COGINIT instruction. The program started is the Spin interpreter from the Propeller's ROM. There's some information passed to the new cog which includes the starting address of the interpretive code to use and the start of a stack space for the interpreter to use.
I have looked at the manual discussing Hub and resources but Iwas just wondering if there
might be a discussion of how spin interperter waits for the hub time to process spin, it also
looks like the cogs when running spin are actually clocking at 200khz while the cog assembler
would be cloking at 80MHZ I will download tutorials
The Spin interpreter uses the same hub instructions as any other assembly program (RDxxxx / WRxxxx). These
wait automatically for the cog to have its access slot.
The Spin interpreter runs at the same clock speed as everything else (normally 80MHz). It's just that, to process
one Spin byte code instruction takes several assembly instructions (usually a 20:1 ratio on average ... typical for
most interpreters). At 80MHz, most assembly instructions take 4 clock cycles or 50ns to execute. On average,
most Spin byte code instructions should take about 1us to execute (20 x 50ns). Any Spin statement consists
of several byte code instructions, so the simplest Spin statement may take 5-10us to execute. I may be off a
little in these times, but they're the right order of magnitude.
thanks for the info this propeller chip is very intriguing
best Regards
Bob Drury
Fisrtly, an aside for anyone who wants to throw in their two cents : What is the terminology for something which is running in parallel in a Cog - process, task, thread, something else ?
I'll call them processes here.
When the first process runs, the main program, it will have memory space allocated for the variables and arrays it uses and there is also a stack space it uses at run time. When the first process launches a second process it will tell that process where the second process's stack space is. This is often an array of longs called "stack[noparse]/noparse" or similar which is part of the first processes memory space. When the new process runs it will use that memory space as its own stack, the stack used by the first process is used only by the first process.
Another way of looking at it is that any process which launches a sub-process has to have set aside some of its own memory space for each sub-process to use as a stack, that Stack[noparse]/noparse array as is often seen in example code ...
"Stack[noparse]/noparse" is only stack for the second process, it is part of the memory space for the first process.
regards bob drury