Shop OBEX P1 Docs P2 Docs Learn Events
Question About Cog(0) — Parallax Forums

Question About Cog(0)

ThePenguinMasterThePenguinMaster Posts: 89
edited 2008-09-12 22:25 in Propeller 1
so I read in the user manual that when the propeller starts up, the interpreter is loaded into cog zero, and the program is run from main memory, now my question is, if I loaded a program into the propeller and that program loaded a function to run in cog(1) would cog (1) run faster? Is cog (0) slower because the interpreter is loaded onto it? I'm looking to make a setup where timing is curtail, and I want it to be as fast as possible, so I was wondering if I should not rely on loading part of the program into cog(0).

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2008-09-12 17:57
    The only significance cog(0) has is that it is the startup cog.

    A cog is either running the interpeter, or doing nothing, or running assembly language programs written by the user. Each cog that is running spin programs, will be running the interpeter, which gets loaded at the time the cog is started.

    So, no it won"t be slower.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
  • ThePenguinMasterThePenguinMaster Posts: 89
    edited 2008-09-12 18:51
    Ok so that makes a lot of sense, each cog runs the interpreter unless the function it is running is entirely in ASM, but I thought each object had to start off with some spin? Is it possible to do an object or program completely in ASM and have a cog run it to eliminate the interpreter from a cog all together? Is this pointless? It seems like the answer is don’t worry about trying to eliminate the interpreter. I’ll be doing some in ASM but I didn’t plan on trying to do it all. Ok I guess that answers my question, thanks!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-12 18:52
    Any programs you write should be cog-agnostic. In other words, they should not be dependent on running in any particular cog. This means never using COGINIT to start a cog. Always use COGNEW instead.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • heaterheater Posts: 3,370
    edited 2008-09-12 19:10
    When a SPIN program loads ASM code into a COG that ASM code replaces the interpreter. So no need to worry about eliminating it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • heaterheater Posts: 3,370
    edited 2008-09-12 19:12
    Oh, and when you have a program that is part Spin and part ASM each part will be running in a different COG. Many such examples in OBEX I suspect.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-12 22:25
    If you have a program that runs entirely in PASM, you still need to load the spin interpreter in cog(0), which will do nothing more than a COGNEW() launch the PASM in another cog. Then cog(0) can be loaded with something else or allowed to stop. Once a PASM function is running in a cog, it can launch other PASM functions in other cogs too without using SPIN because there's a COGINIT function in PASM. So SPIN is only needed for the initial boot process.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
Sign In or Register to comment.