Shop OBEX P1 Docs P2 Docs Learn Events
Cog Start and Stop question — Parallax Forums

Cog Start and Stop question

Don MDon M Posts: 1,653
edited 2012-09-24 13:38 in Propeller 1
I have a main object and within that main object I have a method that if I want to start calls object1 that launches in a new cog and within object1 it launches 2 additional identical objects (objects 2 & 3) into their own new cogs to work with object1.

My question is if I stop (cogstop) object1 does it automatically stop objects 2 & 3?

If it doesn't do I need to keep track of cog ID's so that I can stop them individually by number? I know I can get the ID's returned to me on startup so I am guessing I can assign them to a variable and address them (cogstop ID) that way if needed.

Thoughts?

Don

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-09-24 11:48
    If object1 is properly written, it will have a stop method that also stops anything that it started. But you will have to look at that object to see if it does that. There's no way that we can guess from your post how that object is written.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-09-24 12:08
    I think the question is whether a cogstop on one cog will also stop all the other cogs started by that cog. The answer is no. A cogstog will only stop one cog. As Phil suggested, you should have a stop method that will do an orderly shutdown of all the cogs you want to stop.
  • Don MDon M Posts: 1,653
    edited 2012-09-24 13:02
    If object1 is properly written, it will have a stop method that also stops anything that it started. But you will have to look at that object to see if it does that. There's no way that we can guess from your post how that object is written.

    -Phil

    It hasn't been written yet....
  • Don MDon M Posts: 1,653
    edited 2012-09-24 13:03
    Dave Hein wrote: »
    I think the question is whether a cogstop on one cog will also stop all the other cogs started by that cog. The answer is no. A cogstog will only stop one cog. As Phil suggested, you should have a stop method that will do an orderly shutdown of all the cogs you want to stop.

    Dave that is exactly what I was wondering. I think I know what to do. Thanks.
  • Don MDon M Posts: 1,653
    edited 2012-09-24 13:38
    Phil- I found your COG_counter.spin method. Works great to troubleshoot in this experiment. Thanks!
Sign In or Register to comment.