分布式计算-Chang-Roberts算法

1、改进了Lelann算法,从环中删除了所有那些看起来将失去选举的进程的令牌。

2、算法

var statep;

 

begin if p is initiator then

            begin statep:=cand;send <tok,p> to Nextp;

                      begin receive <tok,q>;

                                if q=p then statep:=leader

                                else if q<p then

                                        begin if statep=cand then statep:=lost;

                                                 send <tok,q> to Nextp

                                       end

                      end

            end

          else while true do

                        begin receive <tok,q>;send <tok,q> to Nextp;

                                  if statep=sleep then statep:=lost;

                        end

end

你可能感兴趣的:(算法)