ADVANCED OPERATING SYSTEM, Exercises of Advanced Operating Systems

xxxxxxxxxxxxxxxxxxxxxxxDVSSSSSSSSSSSSS DSHDHH

Typology: Exercises

2020/2021

Uploaded on 07/18/2021

hadia-nayyer
hadia-nayyer 🇵🇰

3

(1)

4 documents

1 / 67

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 3: Logical Time
Ajay Kshemkalyani and Mukesh Singhal
Distributed Computing: Principles, Algorithms, and Systems
Cambridge University Press
A. Kshemkalyani and M. Singhal (Distributed Computing) Logical Time CUP 2008 1 / 67
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43

Partial preview of the text

Download ADVANCED OPERATING SYSTEM and more Exercises Advanced Operating Systems in PDF only on Docsity!

Chapter 3: Logical Time

Ajay Kshemkalyani and Mukesh Singhal

Distributed Computing: Principles, Algorithms, and Systems

Cambridge University Press

Introduction

The concept of causality between events is fundamental to the design and analysis of parallel and distributed computing and operating systems. Usually causality is tracked using physical time. In distributed systems, it is not possible to have a global physical time. As asynchronous distributed computations make progress in spurts, the logical time is sufficient to capture the fundamental monotonicity property associated with causality in distributed systems.

A Framework for a System of Logical Clocks

Definition A system of logical clocks consists of a time domain T and a logical clock C. Elements of T form a partially ordered set over a relation <. Relation < is called the happened before or causal precedence. Intuitively, this relation is analogous to the earlier than relation provided by the physical time. The logical clock C is a function that maps an event e in a distributed system to an element in the time domain T , denoted as C(e) and called the timestamp of e, and is defined as follows: C : H 7 → T such that the following property is satisfied: for two events ei and ej , ei → ej =⇒ C(ei ) < C(ej ).

A Framework for a System of Logical Clocks

This monotonicity property is called the clock consistency condition. When T and C satisfy the following condition, for two events ei and ej , ei → ej ⇔ C(ei ) < C(ej ) the system of clocks is said to be strongly consistent. Implementing Logical Clocks Implementation of logical clocks requires addressing two issues: data structures local to every process to represent logical time and a protocol to update the data structures to ensure the consistency condition. Each process pi maintains data structures that allow it the following two capabilities: ◮ (^) A local logical clock, denoted by lci , that helps process pi measure its own progress.

Scalar Time

Proposed by Lamport in 1978 as an attempt to totally order events in a distributed system. Time domain is the set of non-negative integers. The logical local clock of a process pi and its local view of the global time are squashed into one integer variable Ci. Rules R1 and R2 to update the clocks are as follows: R1: Before executing an event (send, receive, or internal), process pi executes the following: Ci := Ci + d (d > 0) In general, every time R1 is executed, d can have a different value; however, typically d is kept at 1.

Scalar Time

R2: Each message piggybacks the clock value of its sender at sending time. When a process pi receives a message with timestamp Cmsg , it executes the following actions: ◮ (^) Ci := max(Ci , Cmsg ) ◮ (^) Execute R1. ◮ (^) Deliver the message. Figure 3.1 shows evolution of scalar time.

Basic Properties

Consistency Property Scalar clocks satisfy the monotonicity and hence the consistency property: for two events ei and ej , ei → ej =⇒ C(ei ) < C(ej ). Total Ordering Scalar clocks can be used to totally order events in a distributed system. The main problem in totally ordering events is that two or more events at different processes may have identical timestamp. For example in Figure 3.1, the third event of process P 1 and the second event of process P 2 have identical scalar timestamp.

Total Ordering

A tie-breaking mechanism is needed to order such events. A tie is broken as follows: Process identifiers are linearly ordered and tie among events with identical scalar timestamp is broken on the basis of their process identifiers. The lower the process identifier in the ranking, the higher the priority. The timestamp of an event is denoted by a tuple (t, i) where t is its time of occurrence and i is the identity of the process where it occurred. The total order relation ≺ on two events x and y with timestamps (h,i) and (k,j), respectively, is defined as follows:

x ≺ y ⇔ (h < k or (h = k and i < j))

Properties...

No Strong Consistency The system of scalar clocks is not strongly consistent; that is, for two events ei and ej , C(ei ) < C(ej ) 6 =⇒ ei → ej. For example, in Figure 3.1, the third event of process P 1 has smaller scalar timestamp than the third event of process P 2 .However, the former did not happen before the latter. The reason that scalar clocks are not strongly consistent is that the logical local clock and logical global clock of a process are squashed into one, resulting in the loss causal dependency information among events at different processes. For example, in Figure 3.1, when process P 2 receives the first message from process P 1 , it updates its clock to 3, forgetting that the timestamp of the latest event at P 1 on which it depends is 2.

Vector Time

The system of vector clocks was developed independently by Fidge, Mattern and Schmuck. In the system of vector clocks, the time domain is represented by a set of n-dimensional non-negative integer vectors. Each process pi maintains a vector vti [1..n], where vti [i] is the local logical clock of pi and describes the logical time progress at process pi. vti [j] represents process pi ’s latest knowledge of process pj local time. If vti [j]=x, then process pi knows that local time at process pj has progressed till x. The entire vector vti constitutes pi ’s view of the global logical time and is used to timestamp events.

Vector Time

The timestamp of an event is the value of the vector clock of its process when the event is executed. Figure 3.2 shows an example of vector clocks progress with the increment value d=1. Initially, a vector clock is [0, 0 , 0 , ...., 0].

Vector Time

An Example of Vector Clocks

p 3

p 1

2 0 0

3 0 0

4 3 4 0 1 0

(^20) 0 2 3 0

2 4 0

2 3 4

5 3 4 5 6 4 0 0 1

2 3 3

2 (^34)

2 p 2 3 0

2 2 0

2 (^32)

1 0 0

5 3 4 5 5 4

Figure 3.2: Evolution of vector time.

Vector Time

Properties of Vectot Time

Isomorphism If events in a distributed system are timestamped using a system of vector clocks, we have the following property. If two events x and y have timestamps vh and vk, respectively, then

x → y ⇔ vh < vk x ‖ y ⇔ vh ‖ vk.

Thus, there is an isomorphism between the set of partially ordered events produced by a distributed computation and their vector timestamps.

Vector Time

Strong Consistency The system of vector clocks is strongly consistent; thus, by examining the vector timestamp of two events, we can determine if the events are causally related. However, Charron-Bost showed that the dimension of vector clocks cannot be less than n, the total number of processes in the distributed computation, for this property to hold. Event Counting If d=1 (in rule R1), then the ith^ component of vector clock at process pi , vti [i], denotes the number of events that have occurred at pi until that instant. So, if an event e has timestamp vh, vh[j] denotes the number of events executed by process pj that causally precede e. Clearly,

vh[j] − 1 represents the total number of events that causally precede e in the distributed computation.