Shop OBEX P1 Docs P2 Docs Learn Events
Cog use status — Parallax Forums

Cog use status

Chuck RiceChuck Rice Posts: 210
edited 2008-02-15 10:28 in Propeller 1
Tried searching for this, but cog and status are just too common.

How can in get information on cogs currently in use, and the max cogs used?

Is it as Hackish as looping to start cogs with a dummy routine till I get a bad return code then free them again? -Chuck-

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2008-02-14 23:03
    Chuck Rice said...
    Is it as Hackish as looping to start cogs with a dummy routine till I get a bad return code then free them again?
    No other way, I think.
    COGs are VERY segregated and very few things can be done without their co-operation. There is a chance to shoot them down, but even then you will get no feedback...
  • Mike CookMike Cook Posts: 829
    edited 2008-02-14 23:34
    Take a look at this message, I've used this method·to see how many cogs are in use:

    http://forums.parallax.com/showthread.php?p=631581

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • HarleyHarley Posts: 997
    edited 2008-02-14 23:47
    Chuck,

    Don't recall where I ran across this info, but I use
    id := cognew ()

    and after the last cognew, display 'id' via
    Display.dec(id + 1)

    I'm using TV_text to display this and lots other values.

    Hope this is helpful for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-15 00:01
    The ID returned to COGNEW has nothing to do with the number of running IDs. It will most likely be the lowest ID free, but I know of no evidence for that.

    The code Mike quoted is really nice, so I post it here:
    PUB free_cogs : free | i, cog[noparse][[/noparse]8], jmp_0
    
      jmp_0 := %010111_0001_1111_000000000_000000000
      repeat while (cog[noparse][[/noparse]free] := cognew(@jmp_0, 0)) => 0 
        free++
      if free
        repeat i from 0 to free - 1
          cogstop(cog[noparse][[/noparse] i ])
      return free
    


    It shows excellent understanding of many Propeller features, but it can be accomplished in other ways as well smile.gif

    ---
    Edit: Oh, I just see it's by PhiPi smile.gif
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-02-15 00:29
    Mike Cook said...
    Take a look at this message, I've used this method to see how many cogs are in use:

    http://forums.parallax.com/showthread.php?p=631581


    That is exactly what I needed. Thanks! -Chuck-
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-15 10:28
    This is my pet version BTW smile.gif
    PUB free_cogs : free
      x~
      REPEAT WHILE cognew(@cog, @x)+1 
        free++
      x~~   
    DAT
       ORG       0
    cog
       RDLONG  x,  PAR
       TJZ     x,  #cog
       COGID   x
       COGSTOP x
    x  LONG    0
    
Sign In or Register to comment.