Process O turns red ; records no =0,| sent (0,1)|=1, and | received (2,0)|=0; and sends the marker along (0,1). 2. Process 1 receives the token and forwards it along (1,2) before receiving the marker . Then , it receives the marker ; turns red ; records n1=0,| received (0,1)|=1, and t ,2= l ; andsends the marker along (1,2). 3. Process 2 receives the token and forwards it along (2,0) before receiving the marker . Then , it receives the marker ; turns red ; records n2=0,| received (1,2)=1, and | sent (2,0)|=1; and forwards the marker to process 0. 4. Process O receives the token and then receives the marker along (2,0). The algorithm terminates here .The total number of tokens recorded is as follows :( no + n ]+n2)+(| sent (0,1)- received (0,1)|)+(| sent (1,2)|-| received (1,2)|)+(| sent (2,0)|-| received (2,0)|)=1. This is consistent with the expected outcome .. Let machine i start Chandy-Lamport snapshot before it has sent M along ch1. Also, let machine j receive the marker after it sends out M’ along ch2. Observe that the snapshot state is down ∅ up M’ Doesn’t this appear strange? This state was never reached during the computation!再举至少两个运行场景的例子,并分析它们的特征,说明是否仍然是循环的;若有循环,循环的规律是什么等等,用中文回答
时间: 2024-01-06 22:05:35 浏览: 69
A1333-Datasheet.pdf
这段文字描述了使用Chandy-Lamport快照算法来记录分布式系统中消息传递的情况。在运行过程中,每个进程都会记录自己发送和接收的消息,并在收到“标记”(marker)时进行快照,记录此时的状态。根据记录的信息,可以计算出总共传递的消息数量。
针对题目中的问题,如果让i在发送M之前进行快照,而让j在发送M'之后接收标记,那么快照记录的状态将会是“down ∅ up M'”,即表示在M'之前没有任何消息被接收,但是M'已经被发送出去了。这看起来确实有些奇怪,因为这个状态在正常的运行过程中不可能出现。
举例来说,如果我们把上述场景中的进程和通道抽象成一个有向图,那么就可以得到以下两个运行场景的例子:
1. 场景一:进程0先发送消息,然后进程1接收消息并发送给进程2,最后进程2接收消息。此时进行快照,记录的状态为“down 0 up 2”,表示进程0已经发送消息,进程2已经接收消息,但是进程1发送的消息还没有被接收。
2. 场景二:进程0和进程1同时发送消息,然后进程2接收这两个消息并发送标记,最后进程0和进程1都接收标记。此时进行快照,记录的状态为“down 0,1 up 2”,表示进程0和进程1都已经发送了消息,但是进程2还没有收到标记。
这两个场景中都存在循环,因为消息在不同进程之间来回传递。循环的规律是进程之间通过通道传递消息,每个进程都会收到来自其他进程的消息,并将自己的消息发送给其他进程。这个过程会一直重复,直到满足一定的条件才会停止。
阅读全文