Cog use status
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-
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
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...
http://forums.parallax.com/showthread.php?p=631581
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
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
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 freeIt shows excellent understanding of many Propeller features, but it can be accomplished in other ways as well
---
Edit: Oh, I just see it's by PhiPi
That is exactly what I needed. Thanks! -Chuck-
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