PDA

View Full Version : How many cogs are running



Brian_B
02-11-2007, 07:44 AM
Hi,
·Is there a fast way to look at code and tell how many cogs are being used ?

Thanks,Brian

cgracey
02-11-2007, 09:05 AM
Brian,

It's helpful if the initial documentation for an object spells this out right away, so you'll know. Because cogs are started at run-time, this could be hard to track down, otherwise.

Here's from an object I wrote (this is the coolest software I've ever written):
·

http://forums.parallax.com/attachment.php?attachmentid=45414

·


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Chip Gracey
Parallax, Inc.

Post Edited (Chip Gracey (Parallax)) : 2/11/2007 2:17:29 AM GMT

Brian_B
02-11-2007, 10:05 AM
Thank's Chip,
I think I might have phrased the question wrong .If you have five objects are they all using differnt cogs ,or does the propeller tools compress the code to less cogs. Example : Chris Savage's PING demo ,I believe 5 objects total .But not one cognew, is everything running on on cog ?

Thank's Brian

Martin Hebel
02-11-2007, 10:27 AM
If the code is written in Spin, it resides in the main (hub) memory and Cog 0 runs the interpreter to read and execute the byte tokens. This spin code can be 1 or 50 objects. It makes no difference.

Using the cognew instruction you can start a 2nd cog running the same, or other spin methods.

If object contains assembler, a cog must be used to hold the machine code (the spin interpreter is dumped and loaded with the machine code).

So, certain objects, such as video, require one or more cogs to handle the high speed assembler code needed.

Other objects strictly using spin may or may not need their own cogs depending if parallel processing is needed.

Look over the 1st couple chapters of the propeller manual.

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting, and XBee Wireless Adapters (http://www.selmaware.com/)
Southern Illinois University Carbondale, Electronic Systems Technologies (http://www.siu.edu/~isat/est)

Brian_B
02-11-2007, 10:58 AM
Martin,
Chip and the guys (and Gals), made the propeller to easy to work with. I've made up my mind to stop and reread the manual (I'll probally get more out of it this time).

Thanks,Brian

parsko
02-11-2007, 09:56 PM
Brian,

PhiPi wrote a clever routine a while back that I use regularly to check the amount of cogs available. The code I add to call it is below. Uses the TV object.

See his code attached...




Pub CogCounter
TextXY(1,13)
text.str(string("Number of Cogs"))
TextXY(20,13)
text.dec(CogCnter.free_cogs)

Pub TextXY(column,row)
text.out($0A)
text.out(column)
text.out($0B)
text.out(row)




You can call it any time. Add some delays and you can track a routine.

Hope it helps...

-Parsko

Stan671
02-12-2007, 12:53 AM
Brian, A cog is not started and put into service unless and until the programmer writes code to do so.· In other words, the programmer is in complete control of how many and which Cogs are pressed into service for his program.

There is no relationship between the number of objects in a Spin program and the number of Cogs used.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski

Brian_B
02-12-2007, 09:40 AM
Thank's Everybody,
Hey parsko ,I figured you being a fellow gearhead that you would like this video of my modified garden tractor.

http://www.youtube.com/watch?v=iWU12rMj03c

ps.might take a few minutes before it's there.


Brian

parsko
02-12-2007, 03:32 PM
Brian Beckius said...
Thank's Everybody,
Hey parsko ,I figured you being a fellow gearhead that you would like this video of my modified garden tractor.

http://www.youtube.com/watch?v=iWU12rMj03c


ps.might take a few minutes before it's there.



Brian


Garden Tractor?!?


Anything that produces noxious gases and smoke is cool! I'm impressed!

-Parsko