title: Synchronization of execution between 2 microcontrollers in C
body: <p>I'd like to use this question as a way to debate an algorithm for synchronization over network of 2 or more microcontrollers. </p>
  
  <p>I started thinking of the problem this afternoon, where I'd have 2 different microcontrollers exchange data then synchronize execution to start doing the work at the same time and finishing at approximately the same time. This is a way to guarantee that the code that you are running is correct and possibly there are no errors in the memory (the chance of having the exact same error on both microcontrollers is extremely low as you may imagine). </p>
  
  <p>I thought about just sending a message with microcontroller 1's timestamp, then the second microcontroller would receive it and compare it with its own timestamp and then resend it to microcontroller1. </p>
  
  <p>At that point they would both start exectuing the same code and they would synchronize at the end, where they would exchange each other'a results and then they'd come to the conclusion if there is something wrong, or everything's working alright. </p>
  
  <p>I thought this would be a "decent" way to achieve synchronization of execution between both microcontrollers, but I can't get out of my head that there might be a better and smarter way of doing this. </p>
  
  <p>This "might" work alright with 2 microcontrollers, but what about when I want to do it with more microcontrollers? What if I want to implement a 5 core system (5 arm9 cores for example) in the way I've explained before. I don't see this working for several microcontrollers. Not even if I wanted to implement a 5 core system in which all microcontrollers would do different work (I think synchronization must be the best possible in all cases .... I really don't know I've never needed more than one core, but I'll need to do it from now on)</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'd like to use this question as a way to understand algorithms for synchronization over network, or on the same board, of 2 or more microcontrollers. </p>
  
  <p>I started thinking of the problem this afternoon, where I'd have 2 different microcontrollers exchange data then synchronize execution to start doing the work at the same time and finishing at approximately the same time. This is a way to guarantee that the code that you are running is correct and possibly there are no errors in the memory (the chance of having the exact same error on both microcontrollers is extremely low as you may imagine). </p>
  
  <p>I thought about just sending a message with microcontroller 1's timestamp, then the second microcontroller would receive it and compare it with its own timestamp and then resend it to microcontroller1. </p>
  
  <p>At that point they would both start exectuing the same code and they would synchronize at the end, where they would exchange each other'a results and then they'd come to the conclusion if there is something wrong, or everything's working alright. </p>
  
  <p>I thought this would be a "decent" way to achieve synchronization of execution between both microcontrollers, but I can't get out of my head that there might be a better and smarter way of doing this. </p>