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.」app
【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的消息)