Lamport时钟和矢量时钟 [英] lamport clock and vector clock
本文介绍了Lamport时钟和矢量时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请给我代码在分布式系统中实现Lamport时钟和矢量时钟的代码.
please give me the code for implementation of lamport clock and vector clock in distributed system.
推荐答案
^ ]
德语Wiki为此提供了伪代码:
正在发送:
http://en.wikipedia.org/wiki/Lamport_timestamps[^]
the German wiki gives a pseudo code for it:
Sending:
time = Time+1;
time_stamp = time;
send(Message, time_stamp);
接收:
receiving:
(message, time_stamp) = receive();
time = max(time_stamp, Time)+1;
http://en.wikipedia.org/wiki/Vector_clocks [
http://en.wikipedia.org/wiki/Vector_clocks[^]
are a bit more complicated:
sending:
time[PID]= time[PID]+1;
time_stamp= time;
send(message,time_stamp);
接收:
receiving:
(message,time_stamp)= receive();
time[PID]= time[PID]+1;
for (Process P) do begin
time[P]= max(time[P],time_stamp[P]);
end;
还有其他链接@ Wikipedia-关注它们并阅读!
There are additional links @ wikipedia - follow them and read!
//------------------ -------------------------------------------------- --------
//
// ----------------------------------------------------------------------------
//
Id:Node.java,v 1.4 1997/11/14 16:38:59 schreine Exp schreine
Id: Node.java,v 1.4 1997/11/14 16:38:59 schreine Exp schreine
这篇关于Lamport时钟和矢量时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文