Shop OBEX P1 Docs P2 Docs Learn Events
Sync'ing Code Execution — Parallax Forums

Sync'ing Code Execution

TomMTomM Posts: 2
edited 2006-04-11 17:05 in Propeller 1
Is it possible to synchronize the execution of code between Cogs?

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-04-11 15:50
    Have all cogs to be synchronized execute a WAITCNT such that all cogs execute the command at least 5 cycles before the count value occurs. This technique is only effective for cogs running assembly, since Spin requires central hub access and would serialize each cog running spin code.

    Another technique would be to use WAITPE or WAITPNE if you want a master/slave arrangement, the master could be another cog or an external device.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10

    Post Edited (Paul Baker) : 4/11/2006 3:53:26 PM GMT
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2006-04-11 16:12
    One counter module in one COG could provide a sync pulse to all the others, which would hold on a WAITPEQ or WAITPNE in either Spin or assembly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-04-11 16:19
    One caviat to stress is that spin code cannot operate in true synchronization because each interpretor must fetch byte codes from the hub memory, which is serialized (each cog gains access to the hub in round robin fashion). Additionally spin commands are not equal execution paths (an addition does not take the same amount of time a multiplication takes), though if you synchronize each and every spin command, you could get a little closer to synchronization.

    It all depends on how you define synchronization, and how much jitter you can get away with.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10
  • TomMTomM Posts: 2
    edited 2006-04-11 16:29
    Thanks, I am not interested in Spin only Assembly.
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2006-04-11 17:05
    Agreed, it would depend on time scale, what you mean by sync. Two identical assembly programs could exactly synced, instruction for instruction. Whereas two identical Spin programs could be off by wherever the hub happened to be when the sync pulse came along, as much as 16 clock cycles latency. That isn't much on a glacial time scale. I've seen some interesting earlier threads here on this board about real problems in synchronization.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.