简体   繁体   中英

Leader election algorithms, the point of it

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM