Reputation: 21
I am doing a homework assignment containing the Peterson's leader election algorithm. I am very confused to why you need such an algorithm to choose a leader. Why not choose one at random? Or the first one in a queue or something.
Any clarification would be great, thanks in advance
Upvotes: 2
Views: 861
Reputation: 986
Try to think through your suggested random approach executing in a system with five nodes (processes/computers). Which node will make the random decision? Before you can decide that, you must have a leader. If all nodes try to choose randomly at once, they will come up with different answers, and no leader will be jointly recognized.
With the queue idea, where is the queue held? You have to think about the system as having no central point of control - this central point is what we're trying to determine by electing a leader. If we ask each node to apply the same queue-based selection process, how do we guarantee their queues have the same ordering?
Leader elections are about choosing a leader when no central control exists, and when all processes need to agree on the result.
Upvotes: 5