Two cog questions
acantostega
Posts: 105
Hi,
I have a couple of doubts regarding how cogs execute code. Say I have something like this:
Let's suppose this code started on cog 1 and function2 was launched on cog 2.
When I called function1 from within function2 (which is running in cog 2) does it run on cog 1 or cog 2?
When I called function1 from within Start, what happens if it is still running from when I called it in function2? Are two versions running in "parallel" (with which I guess I mean each cog sets up function1's local variables in their own stack and they don't interfere with each other)?
An example case would be having one "Timing" object, which provides functions such as pause1ms(ms). Can any function, regardless of what cog it is running in, call pause1ms without it interfering with any other cog using the same function?
Thanks in advance!
I have a couple of doubts regarding how cogs execute code. Say I have something like this:
PUB Start cognew(function2,@stack1) function1 ' a call to function1 PUB function1 'some code PUB function2 'some code function1 ' a call to function1
Let's suppose this code started on cog 1 and function2 was launched on cog 2.
When I called function1 from within function2 (which is running in cog 2) does it run on cog 1 or cog 2?
When I called function1 from within Start, what happens if it is still running from when I called it in function2? Are two versions running in "parallel" (with which I guess I mean each cog sets up function1's local variables in their own stack and they don't interfere with each other)?
An example case would be having one "Timing" object, which provides functions such as pause1ms(ms). Can any function, regardless of what cog it is running in, call pause1ms without it interfering with any other cog using the same function?
Thanks in advance!
Comments
The Cog that call the function will be processing that function. It doesn't really run "on the cog", the cogs simply interpret the same code.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
AppBee - XBee ZigBee / IEEE 802.15.4 Adapters & Devices