废止算法应用于回波算法

1、不管开始多少次波动,只有一个波动进行判定,即:具有最小初始进程的波动进行判定。在发生判定之前,所有其他波动将会被中止。

2、假设对于所有p∈P,udef>q。一旦接收带有r<cawp的消息<tok,r>,由于稍早对cawp的赋值,就会执行条件为r=cawp的if语句。当进程p当选时,接收到来自每个近邻的消息<tok,p>,p将消息<ldr,p>分散到所有进程中,通知它们是领导人,使得它们终止算法的执行。

3、算法

var  cawp:P init udef;

      recp:integer init 0;

      fatherp:P init   udef;

      lrecp:integer init 0;

     winp:P  init udef;

begin if p is initiator then

         begin cawp:=p;

                   forall q∈Neighp do send <tok,q> to q

         end;

         while lrecp<#Neighp do

                  begin receive msg form q;

                            if msg=<ldr,r> then

                               begin if lrecp=0 then

                                           forall q∈Neighp do send <ldr,r> to q;

                                           lrecp:=lrecp+1;winp:=r

                               end

                            else

                               begin if r<cawp then

                                         begin cawp:=r;recp:=0;fatherp:=q;

                                                   forall s∈Neighp,s≠q

                                                             do send <tok,r> to s     

                                         end;

                                         if r=cawp then

                                            begin recp:=recp+1;

                                                      if recp=#Neighp then

                                                         if cawp=p

                                                            then forall sNeighp

                                                                    do send <ldr,p> to s

                                                           else send <tok,cawp> to fatherpo

                                                         end

                                                  end

                                     end;

                                   if winp=p then statep:=leader else statep:=lost

             end

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值