Shop OBEX P1 Docs P2 Docs Learn Events
Two cog questions — Parallax Forums

Two cog questions

acantostegaacantostega Posts: 105
edited 2006-09-30 21:44 in Propeller 1
Hi,
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

Sign In or Register to comment.