Shop OBEX P1 Docs P2 Docs Learn Events
Which cog runs? — Parallax Forums

Which cog runs?

pacmanpacman Posts: 327
edited 2010-08-12 14:04 in Propeller 1
Just thinking (and I'm on site in another state so I don't have acces to all my usual documentation). So I'll ask the " 'sperts "

Lets say that cog0 starts a seperate process (in cog1). The new process is basically a repeat loop.

Now if cog0 references a function of the new cog1 (cog0var := cog1.value) where does that 'code' run?

Does cog1 pause it's repeat loop and service the request from cog0? or does cog0 run the code in cog1? or does a whole new cog start (invisibly) run the code in cog1 and pass the value back to cog0 (and then 'disappear')?

Thanks in advance

Comments

  • BeanBean Posts: 8,129
    edited 2010-08-12 03:26
    I don't see how cog0 "could" call a function is in cog1.

    In PASM cog0 does not have access to cog1 code.

    In SPIN all code is global because it is stored in the hub not in the cog.

    Maybe I'm just not understanding the question correctly ???

    Bean
  • Heater.Heater. Posts: 21,230
    edited 2010-08-12 03:33
    When working in Spin don't confuse objects and cogs.

    When you call a method in an child object your calling cog is running the code of that method. In your example cog0 is executing the code of that method and cog1 continues doing whatever it was doing.

    It matters not what other cogs are running what ever methods in that child object. Or if there are no cogs executing anything else.

    If there is some other cog running a method in that child object it knows nothing about you calling any other methods in the object. It just continues on it's merry way.

    Of course now your two cogs are probably exchanging data through the variables in that child object.
  • pacmanpacman Posts: 327
    edited 2010-08-12 14:04
    Heater. wrote: »
    When working in Spin don't confuse objects and cogs.

    When you call a method in an child object your calling cog is running the code of that method. In your example cog0 is executing the code of that method and cog1 continues doing whatever it was doing.

    Thanks Heater. That answers it.
Sign In or Register to comment.