Shop OBEX P1 Docs P2 Docs Learn Events
How many cogs are running — Parallax Forums

How many cogs are running

Brian_BBrian_B Posts: 842
edited 2007-02-12 08:32 in Propeller 1
Hi,
·Is there a fast way to look at code and tell how many cogs are being used ?

Thanks,Brian

Comments

  • cgraceycgracey Posts: 14,209
    edited 2007-02-11 02:05
    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):
    ·

    attachment.php?attachmentid=45414

    ·


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


    Chip Gracey
    Parallax, Inc.

    Post Edited (Chip Gracey (Parallax)) : 2/11/2007 2:17:29 AM GMT
    930 x 542 - 54K
  • Brian_BBrian_B Posts: 842
    edited 2007-02-11 03:05
    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 HebelMartin Hebel Posts: 1,239
    edited 2007-02-11 03:27
    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
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • Brian_BBrian_B Posts: 842
    edited 2007-02-11 03:58
    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
  • parskoparsko Posts: 501
    edited 2007-02-11 14:56
    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
  • Stan671Stan671 Posts: 103
    edited 2007-02-11 17:53
    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_BBrian_B Posts: 842
    edited 2007-02-12 02:40
    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
  • parskoparsko Posts: 501
    edited 2007-02-12 08:32
    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
Sign In or Register to comment.