I want to do the following:
I have a number of computers. On each computer a programm will run. There is no centralized server.
The program can choose by defined criteria to give another computer specified data. While doing so, the other computer should not do the same. (A sort of 2 way synchronize)
Let's make an example. (C1 .. Cn are the programs running on different computers)
C1 sends C2 updated data. While processing is active, C2 should not ask C1 for update something else.
The idea was:
C1 sends a message to C2: PauseExecution() C1 sends to C2 items to be processed (updates some data on C2) C1 sends a message to C2: ResumeExecution(). C2 sends a message to C1: PauseExecution() C2 sends to C1 items to be processed (updates some data on C1) C2 sends a message to C1: ResumeExecution(). But now the biggest problem arises.
If C1 sends a message to C2 to Pause, and C22 sends at the same tiem a message to C1 to Pause, both would block.
There is no centralized server / shared memory for keeping a semaphore.
Is there another pattern which can be used, so that n computers will not block?
So this question is about algorithmic exclusion.
Or is there another workaround for this problem, if no semaphore or mutex can be used?