Shop OBEX P1 Docs P2 Docs Learn Events
More Cogs from One Prop — Parallax Forums

More Cogs from One Prop

HumanoidoHumanoido Posts: 5,770
edited 2010-08-14 14:58 in Propeller 1
Is it possible to create one or more extra tiny virtual cogs inside a Prop chip?

Humanoido

Comments

  • LeonLeon Posts: 7,620
    edited 2010-08-14 13:32
    You could create threads running on a cog.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-08-14 13:44
    Leon wrote: »
    You could create threads running on a cog.
    Leon, ok let's create one extra thread, with a drop-in path for more. Can one of the Forum prop software experts show how to get started and maybe create some simple example using SPIN?

    Humanoido
  • LeonLeon Posts: 7,620
    edited 2010-08-14 13:51
    I'm fairly sure that someone has already done it.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-14 14:00
    Humanoido,

    Have a look at FullDuplexSerial. Note the cunning way it has two threads of execution going on. One for transmit and one for receive. That technique is generally referred to as coroutines (as opposed to subroutines). One returns to the other which returns to the first and so on.

    Perhaps not quite inside a COG but you might think about making and LMM execution loop that has multiple LMM Program Counters and hence executes two or more threads of LMM code sort of at the same time.

    So four threads might look like so:

    LMM_loop    rdlong LMM_1, PC_1
                add    PC_1, #4
    LMM_1       nop
                rdlong LMM_2, PC_2
                add    PC_2, #4
    LMM_2       nop
                rdlong LMM_3, PC_3
                add    PC_3, #4
    LMM_3       nop
                rdlong LMM_4, PC_4
                add    PC_4, #4
    LMM_4       nop
                jmp    #LMM_loop
    

    Edit: Not sure it's possible to make a thread example in Spin. Someone here did recently post some ideas and code for implementing threads in COGs. Can't remember who...

    Edit: I hate those stupid code boxes with totally unnecessary scroll bars.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-08-14 14:02
    There is a Prop RTOS pointed to by the 2009/2010 Propeller Design Contest sticky thread.

    John Abshier
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-08-14 14:58
    Peter (pjv) - Prop RTOS " Depending on complexity and speed, a Cog can have any number of independent threads. Contrived applications such as simple LED flashers can have 128, but more intensive, practical, programs more likely 8 to 16 threads per Cog."

    Thanks Leon, Heater, John Abshier (and PJV). 8 to 16 threads per Cog, up to 128 for LEDs - This is fantastic! It puts this project in a new perspective. With a 320 Cog machine, tiny processor threads could yield totals ranging from 2,560 processors to 40,960 processors.

    [code]320
Sign In or Register to comment.