Clock-Synchronization and Logical Time

We consider the problem of agreeing on time in a distributed system. Since a distributed systems is defined as one where processes communicate by message passing, we cannot have a single global clock every process refer to in order to tell what time it is. It turns out, that is impossible to have a global notion of time in a distributed systems, so the only thing we can hope for, is to get the processes to agree on the time within a specific bound. However, if we are interested in knowing if some event a happens before some other event b, an approximate agreement on what the time is, is not good enough, and we have to resort to another notion of time, called logical time, which allows us to order causally related events

Literature

[DS] Chapter 11.1-11.4

Exercises
  1. [DS] 11.3, 11.4
  2. Assign Lamport timestamps to the events in the diagram below. For the given pair of events below, describe wheter the events are related by the
    following relations; →,←, "concurrent" . Do the same using vector clocks.
    (i) f and j
    (ii) a and m
    (iii) c and j
    (iv) k and e
    (v) j and k

  3. Consider a collection of processes that contend for a shared resource (such as a file, printer, etc.). It is important that only one process access the resource at a time, or bad things may happen (inconsistent data in the file, garbled printer output, etc.). Therefore, the processes cooperate by running a mutual exclusion protocol to ensure that at most one process has access to the resource at a given time. There are many different approaches to this problem, but the following one exploits the logical clocks you have just considered.

     

     

    Convince yourself that the algorithm satisfies the following properties:

     

    Mutual Exclusion (safety):
    No two processes access the resource simultaneoulsy.
    No Starvation (liveness):
    Provided that any process holding the resource will eventually release it, a process that requests the resource will eventually get it. (Furthermore, it can be bypassed at most once by each other process.)
  4. 11.7