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?
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.
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.
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.
Comments
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_loopEdit: 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 Abshier
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