Definition. The relation "->"on the set of events of a system is the smallest relation satisfying the following three conditions:
(1) If a and b are events in the same process, and a comes before b, then a->b.
(2) If a is the sending of a message by one process and b is the receipt of the same message by another process, then a->b.
(3) If a->b and b->c then a->c.
If two entities do not exchange any messages, then they probably do not need to share a common clock; events occurring on those entities are termed as concurrent events.”
【3】逻辑时钟
论文原文中有这样一句:We begin with an abstract point of view in which a clock is just a way of assigning a number to an event, where the number is thought of as the time at which the event occurred. 这句话的意思是,可以把时间进行抽象,把时间值看成是事件发生顺序的一个序列号,这个值可以<20190515,20190516,20190517>,也可以是<1,2,3>。后面就有了逻辑时钟的概念。定义如下:
we define a clock Ci for each process Pi to be a function which assigns a number Ci(a) to any event a in that process.
Clock Condition. For any events a,b: if a->b then C(a) < C(b).
C1. If a and b are events in process Pi, and a comes before b, then Ci(a) < Ci(b).
C2. If a is the sending of a message by process Pi and b is the receipt of that message by process Pi, then Ci(a) < Ci(b).
单机多进程程序可由锁进行同步,那是因为这些进程都运行在操作系统上,有center为它们的请求排序,这个center知道所有需要进行同步的进程的所有信息。但是在分布式系统中,各个进程运行在各自的主机上,没有一个center的概念,那分布式系统中多进程该怎么进行同步呢?或者说分布式锁该怎么实现呢?论文中提出了解决这一问题的算法要满足下面三个条件:
(I) A process which has been granted the resource must release it before it can be granted to another process.
(II) Different requests for the resource must be granted in the order in which they are made.
(III) If every process which is granted the resource eventually releases it, then every request is eventually granted.
为了简化问题,我们做如下假设:
To request the resource, process Pi sends the message Tm:Pi requests resource to every other process, and puts that message on its request queue, where Tm is the timestamp of the message.(请求资源,发送请求给其他进程,在自己的请求队列中添加该请求)
When process Pj receives the message Tm:Pi requests resource, it places it on its request queue and sends a (timestamped) acknowledgment message to Pi.(收到其他进程的请求,放到请求队列中,回应发起请求的进程)
To release the resource, process Pi removes any Tm:Pi requests resource message from its request queue and sends a (timestamped) Pi releases resource message to every other process.(释放资源,从请求队列中移除该资源请求,发送给其他进程,告诉它们我释放了该资源)
When process Pj receives a Pi releases resource message, it removes any Tm:Pi requests resource message from its request queue.(收到其他进程释放资源的消息,从请求队列中移除该资源请求)
Process Pi granted the resource when the following two conditions are satisfied:
(i) There is a Tm:Pi requests resource message in its request queue which is ordered before any other request in its queue by the relation ⇒ .
(ii) Pi has received a message from every other process timestamped later than Tm.
(判断自己是否可以获得该资源,有两个条件:其一,按全序排序后,Tm:Pi请求在请求队列的最前面;其二,自己Pi已经收到了所有其他进程的时戳大于Tm的消息)