Simplest possible voting/synchronization algorithm
- by Domchi
What would be a simplest algorithm one or more people could use to decide who of them should perform some task? There is one task, which needs to be done only once, and one or more people. People can speak, that is, send messages one to another. Communication must be minimal, and all people use the exact same algorithm.
One person saying "I'm doing it" is not good enough since two persons may say it at a same time.
Simplest that comes to my mind is that each person says a number and waits a bit. If somebody responds in that time, the person with lower number "wins" and does the task. If nobody responds, person says that she's doing it and does it. When she says that she does it, everybody else backs off. This should be enough to avoid two persons doing the task in the same time (since there is wait/handhake period), but might need a "second round" if both persons say the same number.
Is there something simpler?
For those curious, I'm trying to synchronize several copies of SecondLife LSL script to do something only once.