Clocks and ordering Flashcards
Modelling assumptions
Distributed processes communicate via messages
Events of a process form an event sequence where a->b
Sending or receiving messages is an event
Definitions of the happened before relation (->)
1) if a and b are events in the same process and a occurs before b then; a->b
2) if a is the sending of a message and b is the receipt of that message then a->b
3) if a->b, b->c then a->c
4) Two distinct events a and b are said to be concurrent if a->b and b-> a are not true. It would be denoted as (a||b)
Correctness condition for logical clocks and its requirements.
for any events; a,b, if a->b, then C(a)<C(b)
CL1: If a and b are events in Process x and a->b, then Cx(a)<Cx(b)
CL2: If a is the sending of a message and b is the receiving of a message during process x, then Cx(a)<Cx(b)
Implementing logical clocks rules
IR1: Each process x increments Cx immediately after an event
IR2: i) If a is an event representing the sending of a message m by process x to y, then m contains the timestamp: Tm = Cx(a)
ii) Receiving m by event b by process y, peeks at m; then increments Cy if necessary to ensure that the timestamp is greater than that of the message.
Total order definition
This is a solution for concurrence control, so we are able to order events totally. This is done to break ties in concurrent events.
Total order observations
1) if a->b then a=>b. If a=>b then a->b or a||b. This means that b->a is definitely not possible
2) while -> is unique for a given set of results, there could be several => orderings depending on the rule used to break this
3) The total ordering of logical clocks cannot be guaranteed to respect ordering of evens in the passage of real time
Anomalous behaviour
A system S using logical clocks for total ordering can permit anomalous behaviour, where events are observed to happen in the order that is not consistent with the ordering indicated by the clock numbers.
This causes AB to arise in a system due to non traditional communication between 2 entities such as verbal or no communication.
Strong clock condition
for events a,b in S: if a➔ b, then C(a) < C(b)
This is used to prevent anomalous behaviour
Why can’t the strong clock condition be met by logical clocks
As logical clocks only tick for events in S, not the whole supersystem, and the inter-tick duration does not respect the passage of real time
Physical clocks
These are used for timestamping messages so clocks must reference the ticks respecting the real passage of time
Physical clock requirements
determining faster and slower clocks
Ri: the rate at which Ci runs relative to ref time/ real time
* (Ci(t2) - Ci(t1))/(t2 – t1)
Ideally, Ri must be equal to 1; if so,
* (Ci(t2) - Ci(t1)) = (t2 – t1) and Ci is called a perfect clock
Perfect clocks hardly exist due to impurities in crystal
A given physical clock runs either
* faster: (Ci(t2) - Ci(t1)) > (t2 – t1) or Ri > 1, or
* slower: (Ci(t2) - Ci(t1)) < (t2 – t1) or Ri < 1
Physical clock conditions
1) There is a known constant k (k«1) such that for all values of t: 1-k<= (Ci(t2) - Ci(t1))/(t2 – t1) <=1+k
2) for all i and j, and for all t :
Either 0 ≤ Ci(t) - Cj(t) ≤ e (assuming Ci is faster than Cj),
or 0 ≤ Cj(t) - Ci(t) ≤ e (assuming Cj is faster than Ci)
Hardware approach for synching physical clocks
Use special hardware circuits to
(i) timestamp the clock-synch messages just before they get transmitted to a physical medium
(ii) note the arrival time and copy the timestamp of an incoming clock- synch message soon after it is received from the medium
centralised approach for synching physical clocks
a reference clocks periodically transmits its value, and upon A and B receiving the timestamped message, it updates its value.
mmx is the maximum time elapsed between timestamping and receiving so, the initial error can be (mmx - m) which is the maximum variabilities in delays for message processing, queueing and transmission; E > (Umx -U)
Use of total order to construct algorithms
Example of a exclusive use of a single resource:
(i) a process that 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 were made;
(iii) if every process that is granted the resource eventually releases it, then every request is eventually granted