Shop OBEX P1 Docs P2 Docs Learn Events
how many cogs in example 03 — Parallax Forums

how many cogs in example 03

psavolaipsavolai Posts: 21
edited 2006-06-30 08:36 in Propeller 1
Hi ,
I gotta ask you this, since this is really bothering me.

in example 03 whe have our "main" like this

PUB Start
· CogNew (...
· CogNew ( ...

is it so that the main ("Start") is runnig in Cog0 and
the two new subprocesses are started in Cog1 and Cog2
so that I actually have 3 cogs running at some point of time.

When main reaches it's last line does Cog0 get stopped and freed ?
what happens to variables it reserved ?
what if the started processes were "functions" i.e. returning with a value·later ?
stack size of twenty longs, how come 20 why not 22, 200 or 2 ?

regards,

petri.
·

Comments

  • cgraceycgracey Posts: 14,206
    edited 2006-06-27 16:45
    psavolai said...

    Hi ,
    I gotta ask you this, since this is really bothering me.

    in example 03 whe have our "main" like this

    PUB Start
    · CogNew (...
    · CogNew ( ...

    is it so that the main ("Start") is runnig in Cog0 and
    the two new subprocesses are started in Cog1 and Cog2
    so that I actually have 3 cogs running at some point of time.
    That's right.

    When main reaches it's last line does Cog0 get stopped and freed ?
    Yes.

    what happens to variables it reserved ?
    They remain in RAM. It's possible that things were coded such that other COGs were executing Spin code and using the same object as their own scope.

    what if the started processes were "functions" i.e. returning with a value·later ?
    stack size of twenty longs, how come 20 why not 22, 200 or 2 ?
    No problem. They can share the scope of the launcher COG and write their results directly back into that object's VARs. The stack size requirement varies based on code complexity. 20 was probably more of a 'minimum' than a magic number.

    regards,

    petri.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • psavolaipsavolai Posts: 21
    edited 2006-06-30 08:36
    Thanks Chip.
    Now I can sleep without tossing and turning .

    petri.
Sign In or Register to comment.