Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.
-
Upload
georgia-floyd -
Category
Documents
-
view
222 -
download
0
Transcript of Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.
![Page 1: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/1.jpg)
Chapter 17
Theoretical Issues in Distributed Systems
Copyright © 2008
![Page 2: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/2.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.2Operating Systems, by Dhananjay Dhamdhere 2
Introduction
• Notions of Time and State• States and Events in a Distributed System• Time, Clocks and Event Precedences• Recording the State of a Distributed System
![Page 3: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/3.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.3Operating Systems, by Dhananjay Dhamdhere 3
Notions of Time and State
• Time indicates when an event occurred• State of an entity is the condition/mode of its being
– Depends on its features
• Global state of a system comprises the states of all entities in the system at a specific instant of time
• OS uses the notions of time and state for performing scheduling of resources and the CPU:– Find chronological order in which requests occurred
– Distributed OS uses them for recovery
• Problem: lack of global clock in distributed systems
![Page 4: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/4.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.4Operating Systems, by Dhananjay Dhamdhere 4
States and Events in a Distributed System
• Local and Global States• Events
![Page 5: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/5.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.5Operating Systems, by Dhananjay Dhamdhere 5
Local and Global States
• Each entity in a system has its own state– State of a memory cell is the value contained in it
– State of CPU is contents of PSW and GPRs
– State of process:• State of memory allocated to it, CPU state (if running), state
of interprocess communication
• The state of an entity is a local state– State of process Pk at time t: Sk
t
• Global state: collection of local states of all entities at the same instant of time– Global state of system at time t: St={S1
t, S2t,…, Sn
t}
![Page 6: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/6.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.6Operating Systems, by Dhananjay Dhamdhere 6
Events
• An event can be: sending/receiving a message (over a channel), or other (no messages involved)– Channel: an interprocess communication path
• Process state changes when an event occurs in it• We represent an event as follows:
(process id, old state, new state, event description, channel, message)
– Channel and message are “–” if event does not involve sending or receiving of a message
![Page 7: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/7.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.7Operating Systems, by Dhananjay Dhamdhere 7
Time, Clocks, and Event Precedences
• Global clock: abstract clock that can be accessed from different sites of a distributed system with identical results– Cannot be implemented in practice due to unbounded
communication delays
• Alternative: use local clocks in processes– Local clocks should be reasonably well synchronized
![Page 8: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/8.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.8Operating Systems, by Dhananjay Dhamdhere 8
Event Precedence
• e1 → e2 indicates event e1 precedes e2 in time
– i.e., e1 occurred before e2
• Event ordering implies arranging a set of events in a sequence such that each event in the sequence precedes the next one
• A total order (with respect to “→”) exists if all events that can occur in a system can be ordered– A partial order implies that some events can be ordered
but not all events can be ordered
• A casual relationship is used to deduce precedences– A “message send” event precedes “message receive”
![Page 9: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/9.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.9Operating Systems, by Dhananjay Dhamdhere 9
Event Precedence (continued)
• ei precedes ej : If ek and el exist such that ek →el , ei → ek or ei ≡ ek, and el →ej or el ≡ ej • ei follows ej : If eg and eh exist such that eg → eh, ej →eg
or ej ≡ eg, and eh →ei or eh ≡ ei
• ei is concurrent with ej : If ei neither precedes nor follows ej
![Page 10: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/10.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.10Operating Systems, by Dhananjay Dhamdhere 10
Example: Event Precedence
• Timing diagram: plot of the activities of different processes against time– Events in Pi are denoted as ei1, ei2, ..
– e23 is a message send event for message m1
– e12 is a message receive event
![Page 11: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/11.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.11Operating Systems, by Dhananjay Dhamdhere 11
Logical Clocks
• Timestamping (according to local clock) of events provides a direct method of event ordering– Clocks are loosely synchronized using causality
![Page 12: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/12.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.12Operating Systems, by Dhananjay Dhamdhere 12
Logical Clocks (continued)
• A logical clock (LCk) is incremented by 1 only when an event occurs in process Pk
– ts(ei) < ts(ej) if ei → ej
– Problem: ts(ei) < ts(ej) does not imply ei → ej
![Page 13: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/13.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.13Operating Systems, by Dhananjay Dhamdhere 13
Obtaining Unique Timestamps
• Logical clock timestamps are not unique, so cannot be used to obtain a total order over events
• Problem can be overcome by using a pair pts(ei) as the timestamp of ei, where
– pts(ei) ≡ (local time, process id)
• Event ordering rules:ei precedes ej iff (i) pts(ei).local time < pts(ej).local
time, or
(ii) pts(ei).local time = pts(ej).local time and
pts(ei).process id < pts(ej).process id
![Page 14: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/14.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.14Operating Systems, by Dhananjay Dhamdhere 14
Vector Clocks
• A vector clock contains n elements, where n is the number of processes in the distributed system
![Page 15: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/15.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.15Operating Systems, by Dhananjay Dhamdhere 15
Vector Clocks (continued)
• Precedence rules:– ei precedes ej:
• For all l: vts(ei )[l] ≤ vts(ej )[l], but
for some k: vts(ei )[k] vts(ej )[k]
– ei follows ej:
• For all l: vts(ei )[l] ≥ vts(ej )[l], but
for some k: vts(ei )[k] vts(ej )[k]
– ei , ej are concurrent:
• For some k, l: vts(ei )[k] < vts(ej )[k], and vts(ei )[l] > vts(ej )[l]
• vts(ei ) < vts(ej )[l] if and only if ei → ej
![Page 16: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/16.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.16Operating Systems, by Dhananjay Dhamdhere 16
Example: Synchronization of Vector Clocks
• Total order can be obtained using a pair
pvts(ei) ≡ (local time, process id) as timestamp of ei
![Page 17: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/17.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.17Operating Systems, by Dhananjay Dhamdhere 17
Recording the State of a Distributed System
• Problem: it is not possible to get all nodes to record their states at the same time instant– Local clocks are not perfectly synchronized
– Any other collection of local states may be inconsistent
• Alternative: algorithm for obtaining a consistent collection of local states– Collected state not a substitute for the global state
• However, has properties that facilitate some of the control functions in a distributed OS
![Page 18: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/18.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.18Operating Systems, by Dhananjay Dhamdhere 18
Recording the State of a Distributed System (continued)
• Example: inconsistent state recording– Banking application: P1 in N1 and P2 in N2
• Actions:1. P1 debits $100 to account A in node N1
2. P1 sends message to P2 to credit $100 to account B
3. P2 credits $100 to account B in node N2
– Inconsistent if A’s balance is recorded before (1) and B’s balance is recorded after (3)
![Page 19: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/19.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.19Operating Systems, by Dhananjay Dhamdhere 19
Consistent State Recording
• State recording: collection of local states of entities in a system obtained through some algorithm
• Consistent state recording: one in which process states of every pair of processes in the system are consistent according to:
![Page 20: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/20.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.20Operating Systems, by Dhananjay Dhamdhere 20
Properties of a Consistent State Recording
A cut
Process states are recorded at tP1.. tP4
![Page 21: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/21.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.21Operating Systems, by Dhananjay Dhamdhere 21
Properties of a Consistent State Recording (continued)
• “A cut is taken” means that a collection of local states is recorded
• A cut represents a consistent state recording of a system if the states of each pair of processes satisfy Definition 17.1
• State of a channel is the set of messages it contains• A cut may intersect with a message:
– Forward or backward intersection
– Backward intersection makes a cut inconsistent
![Page 22: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/22.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.22Operating Systems, by Dhananjay Dhamdhere 22
Properties of a Consistent State Recording (continued)
• Consistency condition for a cut:– CC: Cut C represents a consistent state recording of a
distributed system if future of cut is closed under the precedes relation on events (closed under “→”)
![Page 23: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/23.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.23
Chandy–Lamport Algorithm for state recording
• Assumptions of the algorithm– Channels are FIFO
– Channels are unidirectional
– Channels have unbounded message buffering capacities
• The state of a process indicates the messages sent and received by it
• A special message called a marker is sent to ask a process to record its state– Process receives markers over all channels incident on it
• Records state of channel over which it received a marker• If it is the first marker received, it also records its own state
Operating Systems, by Dhananjay Dhamdhere 23
![Page 24: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/24.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.24Operating Systems, by Dhananjay Dhamdhere 24
An Algorithm for Consistent State Recording
• Notation:Receivedij : Messages received by Pj over channel Chij
Recorded_recdij : Messages recorded as received in the state of Pj
![Page 25: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/25.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.25Operating Systems, by Dhananjay Dhamdhere 25
Example: Operation of the Chandy−Lamport Algorithm
![Page 26: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/26.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.26Operating Systems, by Dhananjay Dhamdhere 26
Example: Recorded State versus Global State
![Page 27: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/27.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.27Operating Systems, by Dhananjay Dhamdhere 27
Summary
• Operating systems use notions of time and state– Local state: State of an entity
– Global state: States of all entities at the same time instant
• Precedence of events may be deduced using the causal relationship, i.e., cause-and-effect relationship, and transitivity property of precedence
• Some events may be concurrent• It is laborious to deduce the precedence of events by
using transitivity, hence timestamps are used instead– Use local clocks in processes
![Page 28: Chapter 17 Theoretical Issues in Distributed Systems Copyright © 2008.](https://reader036.fdocuments.in/reader036/viewer/2022062301/56649da75503460f94a940ff/html5/thumbnails/28.jpg)
Operating Systems, by Dhananjay Dhamdhere Copyright © 2008 17.28Operating Systems, by Dhananjay Dhamdhere 28
Summary
• Using local clocks in processes– Logical clocks
– Vector clocks
• Include process ids in timestamps for total ordering• It is not possible to record the global state of a system• Chandy-Lamport algorithm obtains consistent recording
of process states using special messages called markers