SlideShare a Scribd company logo
DISTRIBUTED OPERATING
SYSTEMS
By:Little Goku
CANONICAL PROBLEMS IN DISTRIBUTED SYSTEMS
 Time ordering and clock synchronization
 Election
 Mutual exclusion
 Distributed transactions
THE IMPORTANCE OF SYNCHRONIZATION
 Because various components of a distributed
system must cooperate and exchange information,
synchronization is a necessity.
 Constraints, both implicit and explicit, are therefore
enforced to ensure synchronization of components.
CLOCK SYNCHRONIZATION
 As in non-distributed systems, the knowledge
of “when events occur” is necessary.
 However, clock synchronization is often more
difficult in distributed systems because there
is no ideal time source.
 Distributed algorithms must overcome:
 Scattering of information
 Local, rather than global, decision-making.
Conti....
 Time is unambiguous in centralized systems
 Distributed systems: each node has own
system clock.
 Crystal-based clocks are less accurate (1 part in
million)
 Problem: An event that occurred after another
may be assigned an earlier time
LACK OF GLOBAL TIME IN DS (Clock syn.)
 It is impossible to guarantee that
physical clocks run at the same
frequency
 Lack of global time, can cause problem.
 Example: UNIX make
 Edit output.c at a client
 output.o is at a server (compile at server)
 Client machine clock can be lagging behind
the server machine clock
LACK OF GLOBAL TIME – EXAMPLE
When each machine has its own clock, an
event that occurred after another event may
nevertheless be assigned an earlier time.
LOGICAL CLOCKS
 Often, it is not necessary for a computer to know the exact
time, only relative time. This is known as “logical time”.
 Logical time is not based on timing but on the ordering of
events.
 Logical clocks can only advance forward, not in reverse.
 Non-interacting processes cannot share a logical clock.
 Computers generally obtain logical time using interrupts to
update a software clock. The more interrupts (the more
frequently time is updated), the higher the overhead.
LAMPORT’S LOGICAL CLOCK
SYNCHRONIZATION ALGORITHM
 The most common logical clock synchronization algorithm
for distributed systems is Lamport‟s Algorithm. It is used in
situations where ordering is important but global time is not
required.
 Based on the “happens-before” relation:
 Event A “happens-before” Event B (A→B) when all
processes involved in a distributed system agree that
event A occurred first, and B subsequently occurred.
 This DOES NOT mean that Event A actually occurred
before Event B in absolute clock time.
LAMPORT’S LOGICAL CLOCK SYNCHRONIZATION
ALGORITHM
 A distributed system can use the “happens-before”
relation when:
 Events A and B are observed by the same
process, or by multiple processes with the same
global clock
 Event A acknowledges sending a message and
Event B acknowledges receiving it, since a
message cannot be received before it is sent
 If two events do not communicate via messages,
they are considered concurrent – because order
cannot be determined and it does not matter.
Concurrent events can be ignored.
LAMPORT’S LOGICAL CLOCK SYNCHRONIZATION
ALGORITHM (CONT.)
 In the previous examples, Clock C(a) < C(b)
 If they are concurrent, C(a) = C(b)
 Concurrent events can only occur on the same system,
because every message transfer between two systems
takes at least one clock tick.
 In Lamport‟s Algorithm, logical clock values for events may
be changed, but always by moving the clock forward. Time
values can never be decreased.
LAMPORT’S LOGICAL CLOCK
SYNCHRONIZATION ALGORITHM (CONT.)
 Lamport‟s Algorithm can thus be used in distributed
systems to ensure synchronization:
 A logical clock is implemented in each node in
the system.
 Each node can determine the order in which
events have occurred in that system’s own point
of view.
 The logical clock of one node does not need to
have any relation to real time or to any other
node in the system.
PROCESS EACH WITH ITS OWN CLOCK
•At time 6 , Process 0 sends message A to Process 1
•It arrives to Process 1 at 16( It took 10 ticks to make journey
•Message B from 1 to 2 takes 16 ticks
•Message C from 2 to 1 leaves at
60 and arrives at 56 -Not Possible
•Message D from 1 to 0 leaves at
64 and arrives at 54 -Not Possible
LAMPORT’S ALGORITHM CORRECTS THE CLOCKS
 Use „happened-before‟
relation
 Each message carries the
sending time (as per sender‟s
clock)
 When arrives, receiver fast
forwards its clock to be one
more than the sending time.
(between every two events,
the clock must tick at least
once)
PHYSICAL CLOCKS
 The time difference between two computers is known as
drift. Clock drift over time is known as skew. Computer
clock manufacturers specify a maximum skew rate in their
products.
 Computer clocks are among the least accurate modern
timepieces.
 Inside every computer is a chip surrounding a quartz
crystal oscillator to record time. These crystals cost 25
seconds to produce.
 Average loss of accuracy: 0.86 seconds per day
 This skew is unacceptable for distributed systems. Several
methods are now in use to attempt the synchronization of
physical clocks in distributed systems:
PHYSICAL CLOCKS
 17th Century: time has been measured
astronomically
 Solar Day: interval between two consecutive
transit of sun
 Solar Second: 1/86400th of solar day
PHYSICAL CLOCKS
 1948: Atomic Clocks are invented
 Accurate clocks are atomic oscillators (one part in 1013)
 BIH decide TAI(International Atomic Time)
 TAI seconds is now about 3 msec less than solar day
 BIH solves the problem by introducing leap seconds
Whenever discrepancy between TAI and solar time grow to
800 msec
 This time is called Universal Coordinated Time(UTC)
 When BIH announces leap second, the power companies
raise their frequency to 61 & 51 Hz for 60 & 50 sec, to
advance all the clocks in their distribution area.
PHYSICAL CLOCKS - UTC
Coordinated Universal Time
(UTC) is the international
time standard.
UTC is the current term for
what was commonly
referred to as Greenwich
Mean Time (GMT).
Zero hours UTC is midnight in
Greenwich, England, which
lies on the zero longitudinal
meridian.
UTC is based on a 24-hour
clock.
CLOCK SYNCHRONIZATION
 Each clock has a maximum drift rate
 1- dC/dt <= 1+
 Two clocks may drift by 2 t in time t
 To limit drift to  resynchronize after every
2 seconds
CHRISTIAN’S ALGORITHM
 Assuming there is one time server with UTC(Coordinated universal
time):
 Each node in the distributed system periodically polls the time server.
 Time( treply) is estimated as t + (Treply + Treq)/2
 This process is repeated several times and an average is provided.
 Machine Treply then attempts to adjust its time.
 Disadvantages:
 Must attempt to take delay between server Treply andtime
server into account
 Single point of failure if time server fails
CRISTIAN’S ALGORITHM
Synchronize machines to a
time server with a UTC
receiver
Machine P requests time from
server every seconds
 Receives time t from
server, P sets clock to
t+treply where treply is the
time to send reply to P
 Use (treq+treply)/2 as an
estimate of treply
 Improve accuracy by
making a series of
measurements
PROBLEM WITH CRISTIAN’S ALGORITHM
 Time must never run
backward
 If sender‟s clock is
fast, CUTC will be
smaller than the
sender‟s current value
of C
Major Problem Minor Problem
 It takes nonzero time
for the time server‟s
reply
 This delay may be large
and vary with network
load
SOLUTION
Major Problem
 Control the clock
 Suppose that the timer set
to generate 100 intrpt/sec
 Normally each interrupt
add 10 msec to the time
 To slow down add only 9
msec
 To advance add 11 msec to
the time
Minor Problem
 Measure it
 Make a series of
measurements for accuracy
 Discard the measurements
that exceeds the threshold
value
 The message that came
back fastest can be taken to
be the most accurate.
BERKELEY ALGORITHM
 Used in systems without UTC receiver
 Keep clocks synchronized with one another
 One computer is master, other are slaves
 Master periodically polls slaves for their times
 Average times and return differences to slaves
 Communication delays compensated as in Cristian‟s
algo
 Failure of master => election of a new master
BERKELEY ALGORITHM
a)
b)
c)
The time daemon asks all the other machines for their clock values
The machines answer
The time daemon tells everyone how to adjust their clock
30
DECENTRALIZED AVERAGING ALGORITHM
 Each machine on the distributed system has a daemon
without UTC.
 Periodically, at an agreed-upon fixed time, each machine
broadcasts its local time.
 Each machine calculates the correct time by averaging
all results.
TERMINATION DETECTION
 Detecting the end of a distributed computation
 Notation: let sender be predecessor, receiver be successor
 Two types of markers: Done and Continue
 After finishing its part of the snapshot, process Q sends a
Done or a Continue to its predecessor
 Send a Done only when
 All of Q‟s successors send a Done
 Q has not received any message since it check-pointed its local state
and received a marker on all incoming channels
 Else send a Continue
 Computation has terminated if the initiator receives Done
messages from everyone
DISTRIBUTED SYNCHRONIZATION
 Distributed system with multiple processes may
need to share data or access shared data
structures
 Use critical sections with mutual exclusion
 Single process with multiple threads
 Semaphores, locks, monitors
 How do you do this for multiple processes in a
distributed system?
 Processes may be running on different machines
 Solution: lock mechanism for a distributed
environment
 Can be centralized or distributed
CENTRALIZED MUTUAL EXCLUSION
 Assume processes are numbered
 One process is elected coordinator (highest ID
process)
 Every process needs to check with coordinator
before entering the critical section
 To obtain exclusive access: send request, await
reply
 To release: send release message
 Coordinator:
 Receive request: if available and queue empty, send
grant; if not, queue request
 Receive release: remove next request from queue and
send grant
MUTUAL EXCLUSION:
A CENTRALIZED ALGORITHM
a) Process 1 asks the coordinator for permission to enter a
critical region. Permission is granted
b) Process 2 then asks permission to enter the same critical
region. The coordinator does not reply.
c) When process 1 exits the critical region, it tells the
coordinator, when then replies to 2
PROPERTIES
 Simulates centralized lock using blocking calls
 Fair: requests are granted the lock in the order they were
received
 Simple: three messages per use of a critical section
(request, grant, release)
 Shortcomings:
 Single point of failure
 How do you detect a dead coordinator?
 A process can not distinguish between “lock in use” from a dead
coordinator
 No response from coordinator in either case
 Performance bottleneck in large distributed systems
DISTRIBUTED ALGORITHM
 [Ricart and Agrawala]: needs 2(n-1) messages
 Based on event ordering and time stamps
 Process k enters critical section as follows
 Generate new time stamp TSk = TSk+1
 Send request(k,TSk) all other n-1 processes
 Wait until reply(j) received from all other processes
 Enter critical section
 Upon receiving a request message, process j
 Sends reply if no contention
 If already in critical section, does not reply, queue request
 If wants to enter, compare TSj with TSk and send reply if TSk<TSj,
else queue
A DISTRIBUTED ALGORITHM
a)
b)
c)
Two processes want to enter the same critical region at the same
moment.
Process 0 has the lowest timestamp, so it wins.
When process 0 is done, it sends an OK also, so 2 can now enter
the critical region.
PROPERTIES
 Fully decentralized
 N points of failure!
 All processes are involved in all decisions
 Any overloaded process can become a
bottleneck
ELECTION ALGORITHMS
 Many distributed algorithms need one process
to act as coordinator
 Doesn‟t matter which process does the job, just
need to pick one
 Election algorithms: technique to pick a unique
coordinator (aka leader election)
 Examples: take over the role of a failed
process, pick a master in Berkeley clock
synchronization algorithm
 Types of election algorithms: Bully and Ring
algorithms
BULLY ALGORITHM
 Each process has a unique numerical ID
 Processes know the Ids and address of every other
process
 Communication is assumed reliable
 Key Idea: select process with highest ID
 Process initiates election if it just recovered from
failure or if coordinator failed
 3 message types: election, OK, I won
 Several processes can initiate an election
simultaneously
 Need consistent result
 O(n2) messages required with n processes
BULLY ALGORITHM DETAILS
 Any process P can initiate an election
 P sends Election messages to all process with
higher Ids and awaits OK messages
 If no OK messages, P becomes coordinator and
sends I won messages to all process with lower Ids
 If it receives an OK, it drops out and waits for an I
won
 If a process receives an Election msg, it returns an
OK and starts an election
 If a process receives a I won, it treats sender an
coordinator
BULLY ALGORITHM EXAMPLE




The bully election algorithm
Process 4 holds an election
Process 5 and 6 respond, telling 4 to stop
Now 5 and 6 each hold an election
BULLY ALGORITHM EXAMPLE
d)
e)
Process 6 tells 5 to stop
Process 6 wins and tells everyone
RING-BASED ELECTION
 Processes have unique Ids and arranged in a logical ring
 Each process knows its neighbors
 Select process with highest ID
 Begin election if just recovered or coordinator has failed
 Send Election to closest downstream node that is alive
 Sequentially poll each successor until a live node is found
 Each process tags its ID on the message
 Initiator picks node with highest ID and sends a coordinator
message
 Multiple elections can be in progress
 Wastes network bandwidth but does no harm
A RING ALGORITHM
 Election algorithm using a ring.
A TOKEN RING ALGORITHM
a)
b)
An unordered group of processes on a network.
A logical ring constructed in software.
• Use a token to arbitrate access to critical section
• Must wait for token before entering CS
• Pass the token to neighbor once done or if not interested
• Detecting token loss in non-trivial
COMPARISON
 A comparison of three mutual exclusion
algorithms.
Algorithm
Messages per
entry/exit
Delay before entry (in
message times) Problems
Centralized 3 2 Coordinator crash
Distributed 2 ( n – 1 ) 2 ( n – 1 )
Crash of any
process
Token ring 1 to 0 to n – 1
Lost token, process
crash
TRANSACTIONS
Transactions provide higher
level mechanism for atomicity
of processing in distributed
systems
 Have their origins in databases
Banking example: Three
accounts A:$100, B:$200,
C:$300
 Client 1: transfer $4 fromA to
B
 Client 2: transfer $3 from C to
B
Result can be inconsistent
unless certain properties are
Client 1 Client 2
Read A:$100
Write A: $96
Read C: $300
Write C:$297
Read B: $200
Read B: $200
Write B:$203
Write B:$204
Trans..ACID PROPERTIES
Atomic: all or nothing
Consistent: transaction takes
system from one consistent
state to another
Isolated: Immediate effects
are not visible to other
(serializable)
Durable: Changes are
permanent once transaction
completes (commits)
Client 1 Client 2
Read A:$100
Write A: $96
Read B: $200
Write B:$204
Read C: $300
Write C:$297
Read B: $204
Write B:$207

More Related Content

What's hot

Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
Sunita Sahu
 
Distributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmDistributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithm
pinki soni
 
Synchronization
SynchronizationSynchronization
Synchronization
Sara shall
 
Chapter 6 synchronization
Chapter 6 synchronizationChapter 6 synchronization
Distributed System
Distributed SystemDistributed System
Distributed System
Praveen Penumathsa
 
Distributed computing time
Distributed computing timeDistributed computing time
Distributed computing time
Deepak John
 
Vector clock algorithm
Vector clock algorithmVector clock algorithm
Vector clock algorithm
S. Anbu
 
Ds practical file
Ds practical fileDs practical file
Ds practical file
Khushboo Pal
 
Synchronization
SynchronizationSynchronization
Synchronization
Ameena Tijjani
 
Clock Synchronization in Distributed Systems
Clock Synchronization in Distributed SystemsClock Synchronization in Distributed Systems
Clock Synchronization in Distributed Systems
Zbigniew Jerzak
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systemsguest61205606
 
Types of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed SystemTypes of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed System
DHIVYADEVAKI
 
Time in distributed systmes
Time in distributed systmesTime in distributed systmes
Time in distributed systmes
mohammad amid abbasi
 
Distributed System Management
Distributed System ManagementDistributed System Management
Distributed System Management
Ibrahim Amer
 
Shoaib
ShoaibShoaib
Shoaib
ShoaibShoaib

What's hot (20)

Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Distributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithmDistributed system lamport's and vector algorithm
Distributed system lamport's and vector algorithm
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Chapter 6 synchronization
Chapter 6 synchronizationChapter 6 synchronization
Chapter 6 synchronization
 
Distributed System
Distributed SystemDistributed System
Distributed System
 
Ds ppt imp.
Ds ppt imp.Ds ppt imp.
Ds ppt imp.
 
Clocks
ClocksClocks
Clocks
 
Distributed computing time
Distributed computing timeDistributed computing time
Distributed computing time
 
Vector clock algorithm
Vector clock algorithmVector clock algorithm
Vector clock algorithm
 
Ds practical file
Ds practical fileDs practical file
Ds practical file
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Clock Synchronization in Distributed Systems
Clock Synchronization in Distributed SystemsClock Synchronization in Distributed Systems
Clock Synchronization in Distributed Systems
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
 
Types of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed SystemTypes of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed System
 
Time in distributed systmes
Time in distributed systmesTime in distributed systmes
Time in distributed systmes
 
Distributed System Management
Distributed System ManagementDistributed System Management
Distributed System Management
 
Shoaib
ShoaibShoaib
Shoaib
 
OSCh17
OSCh17OSCh17
OSCh17
 
Shoaib
ShoaibShoaib
Shoaib
 

Similar to 3. syncro. in distributed system

Clock.pdf
Clock.pdfClock.pdf
Clock.pdf
MohdAbdulHaque
 
Chapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.pptChapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.ppt
sirajmohammed35
 
Lesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptxLesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptx
LagamaPasala
 
Unit iii-Synchronization
Unit iii-SynchronizationUnit iii-Synchronization
Unit iii-Synchronization
Dhivyaa C.R
 
Chapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.pptChapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.ppt
MeymunaMohammed1
 
Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13
AbdullahMunir32
 
Clock synchronization
Clock synchronizationClock synchronization
Clock synchronization
Medicaps University
 
Synchronization in distributed computing
Synchronization in distributed computingSynchronization in distributed computing
Synchronization in distributed computing
SVijaylakshmi
 
Hu3513551364
Hu3513551364Hu3513551364
Hu3513551364
IJERA Editor
 
CS6601-Unit 4 Distributed Systems
CS6601-Unit 4 Distributed SystemsCS6601-Unit 4 Distributed Systems
CS6601-Unit 4 Distributed Systems
Nandakumar P
 
Clock Synchronization in Distributed Systems
Clock Synchronization in Distributed SystemsClock Synchronization in Distributed Systems
Clock Synchronization in Distributed Systems
IRJET Journal
 
L12.FA20.ppt
L12.FA20.pptL12.FA20.ppt
L12.FA20.ppt
MAliHaider4
 
About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...
About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...
About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...
Subhajit Sahu
 
slides.06.pptx
slides.06.pptxslides.06.pptx
slides.06.pptx
balewayalew
 
Time advance mehcanism
Time advance mehcanismTime advance mehcanism
Time advance mehcanism
Nikhil Sharma
 
Synchronisation
SynchronisationSynchronisation
Synchronisation
Puran Pangeni
 
distribute system.
distribute system.distribute system.
distribute system.
keerthikaA8
 
D021201024031
D021201024031D021201024031
D021201024031
inventionjournals
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
guest0f5a7d
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
guest61205606
 

Similar to 3. syncro. in distributed system (20)

Clock.pdf
Clock.pdfClock.pdf
Clock.pdf
 
Chapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.pptChapter 5-Synchronozation.ppt
Chapter 5-Synchronozation.ppt
 
Lesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptxLesson 05 - Time in Distrributed System.pptx
Lesson 05 - Time in Distrributed System.pptx
 
Unit iii-Synchronization
Unit iii-SynchronizationUnit iii-Synchronization
Unit iii-Synchronization
 
Chapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.pptChapter 6-Synchronozation2.ppt
Chapter 6-Synchronozation2.ppt
 
Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13Parallel and Distributed Computing Chapter 13
Parallel and Distributed Computing Chapter 13
 
Clock synchronization
Clock synchronizationClock synchronization
Clock synchronization
 
Synchronization in distributed computing
Synchronization in distributed computingSynchronization in distributed computing
Synchronization in distributed computing
 
Hu3513551364
Hu3513551364Hu3513551364
Hu3513551364
 
CS6601-Unit 4 Distributed Systems
CS6601-Unit 4 Distributed SystemsCS6601-Unit 4 Distributed Systems
CS6601-Unit 4 Distributed Systems
 
Clock Synchronization in Distributed Systems
Clock Synchronization in Distributed SystemsClock Synchronization in Distributed Systems
Clock Synchronization in Distributed Systems
 
L12.FA20.ppt
L12.FA20.pptL12.FA20.ppt
L12.FA20.ppt
 
About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...
About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...
About TrueTime, Spanner, Clock synchronization, CAP theorem, Two-phase lockin...
 
slides.06.pptx
slides.06.pptxslides.06.pptx
slides.06.pptx
 
Time advance mehcanism
Time advance mehcanismTime advance mehcanism
Time advance mehcanism
 
Synchronisation
SynchronisationSynchronisation
Synchronisation
 
distribute system.
distribute system.distribute system.
distribute system.
 
D021201024031
D021201024031D021201024031
D021201024031
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
 

Recently uploaded

English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 

Recently uploaded (20)

English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 

3. syncro. in distributed system

  • 2. CANONICAL PROBLEMS IN DISTRIBUTED SYSTEMS  Time ordering and clock synchronization  Election  Mutual exclusion  Distributed transactions
  • 3. THE IMPORTANCE OF SYNCHRONIZATION  Because various components of a distributed system must cooperate and exchange information, synchronization is a necessity.  Constraints, both implicit and explicit, are therefore enforced to ensure synchronization of components.
  • 4. CLOCK SYNCHRONIZATION  As in non-distributed systems, the knowledge of “when events occur” is necessary.  However, clock synchronization is often more difficult in distributed systems because there is no ideal time source.  Distributed algorithms must overcome:  Scattering of information  Local, rather than global, decision-making.
  • 5. Conti....  Time is unambiguous in centralized systems  Distributed systems: each node has own system clock.  Crystal-based clocks are less accurate (1 part in million)  Problem: An event that occurred after another may be assigned an earlier time
  • 6. LACK OF GLOBAL TIME IN DS (Clock syn.)  It is impossible to guarantee that physical clocks run at the same frequency  Lack of global time, can cause problem.  Example: UNIX make  Edit output.c at a client  output.o is at a server (compile at server)  Client machine clock can be lagging behind the server machine clock
  • 7. LACK OF GLOBAL TIME – EXAMPLE When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
  • 8. LOGICAL CLOCKS  Often, it is not necessary for a computer to know the exact time, only relative time. This is known as “logical time”.  Logical time is not based on timing but on the ordering of events.  Logical clocks can only advance forward, not in reverse.  Non-interacting processes cannot share a logical clock.  Computers generally obtain logical time using interrupts to update a software clock. The more interrupts (the more frequently time is updated), the higher the overhead.
  • 9. LAMPORT’S LOGICAL CLOCK SYNCHRONIZATION ALGORITHM  The most common logical clock synchronization algorithm for distributed systems is Lamport‟s Algorithm. It is used in situations where ordering is important but global time is not required.  Based on the “happens-before” relation:  Event A “happens-before” Event B (A→B) when all processes involved in a distributed system agree that event A occurred first, and B subsequently occurred.  This DOES NOT mean that Event A actually occurred before Event B in absolute clock time.
  • 10. LAMPORT’S LOGICAL CLOCK SYNCHRONIZATION ALGORITHM  A distributed system can use the “happens-before” relation when:  Events A and B are observed by the same process, or by multiple processes with the same global clock  Event A acknowledges sending a message and Event B acknowledges receiving it, since a message cannot be received before it is sent  If two events do not communicate via messages, they are considered concurrent – because order cannot be determined and it does not matter. Concurrent events can be ignored.
  • 11. LAMPORT’S LOGICAL CLOCK SYNCHRONIZATION ALGORITHM (CONT.)  In the previous examples, Clock C(a) < C(b)  If they are concurrent, C(a) = C(b)  Concurrent events can only occur on the same system, because every message transfer between two systems takes at least one clock tick.  In Lamport‟s Algorithm, logical clock values for events may be changed, but always by moving the clock forward. Time values can never be decreased.
  • 12. LAMPORT’S LOGICAL CLOCK SYNCHRONIZATION ALGORITHM (CONT.)  Lamport‟s Algorithm can thus be used in distributed systems to ensure synchronization:  A logical clock is implemented in each node in the system.  Each node can determine the order in which events have occurred in that system’s own point of view.  The logical clock of one node does not need to have any relation to real time or to any other node in the system.
  • 13. PROCESS EACH WITH ITS OWN CLOCK •At time 6 , Process 0 sends message A to Process 1 •It arrives to Process 1 at 16( It took 10 ticks to make journey •Message B from 1 to 2 takes 16 ticks •Message C from 2 to 1 leaves at 60 and arrives at 56 -Not Possible •Message D from 1 to 0 leaves at 64 and arrives at 54 -Not Possible
  • 14. LAMPORT’S ALGORITHM CORRECTS THE CLOCKS  Use „happened-before‟ relation  Each message carries the sending time (as per sender‟s clock)  When arrives, receiver fast forwards its clock to be one more than the sending time. (between every two events, the clock must tick at least once)
  • 15. PHYSICAL CLOCKS  The time difference between two computers is known as drift. Clock drift over time is known as skew. Computer clock manufacturers specify a maximum skew rate in their products.  Computer clocks are among the least accurate modern timepieces.  Inside every computer is a chip surrounding a quartz crystal oscillator to record time. These crystals cost 25 seconds to produce.  Average loss of accuracy: 0.86 seconds per day  This skew is unacceptable for distributed systems. Several methods are now in use to attempt the synchronization of physical clocks in distributed systems:
  • 16. PHYSICAL CLOCKS  17th Century: time has been measured astronomically  Solar Day: interval between two consecutive transit of sun  Solar Second: 1/86400th of solar day
  • 17. PHYSICAL CLOCKS  1948: Atomic Clocks are invented  Accurate clocks are atomic oscillators (one part in 1013)  BIH decide TAI(International Atomic Time)  TAI seconds is now about 3 msec less than solar day  BIH solves the problem by introducing leap seconds Whenever discrepancy between TAI and solar time grow to 800 msec  This time is called Universal Coordinated Time(UTC)  When BIH announces leap second, the power companies raise their frequency to 61 & 51 Hz for 60 & 50 sec, to advance all the clocks in their distribution area.
  • 18. PHYSICAL CLOCKS - UTC Coordinated Universal Time (UTC) is the international time standard. UTC is the current term for what was commonly referred to as Greenwich Mean Time (GMT). Zero hours UTC is midnight in Greenwich, England, which lies on the zero longitudinal meridian. UTC is based on a 24-hour clock.
  • 19. CLOCK SYNCHRONIZATION  Each clock has a maximum drift rate  1- dC/dt <= 1+  Two clocks may drift by 2 t in time t  To limit drift to  resynchronize after every 2 seconds
  • 20. CHRISTIAN’S ALGORITHM  Assuming there is one time server with UTC(Coordinated universal time):  Each node in the distributed system periodically polls the time server.  Time( treply) is estimated as t + (Treply + Treq)/2  This process is repeated several times and an average is provided.  Machine Treply then attempts to adjust its time.  Disadvantages:  Must attempt to take delay between server Treply andtime server into account  Single point of failure if time server fails
  • 21. CRISTIAN’S ALGORITHM Synchronize machines to a time server with a UTC receiver Machine P requests time from server every seconds  Receives time t from server, P sets clock to t+treply where treply is the time to send reply to P  Use (treq+treply)/2 as an estimate of treply  Improve accuracy by making a series of measurements
  • 22. PROBLEM WITH CRISTIAN’S ALGORITHM  Time must never run backward  If sender‟s clock is fast, CUTC will be smaller than the sender‟s current value of C Major Problem Minor Problem  It takes nonzero time for the time server‟s reply  This delay may be large and vary with network load
  • 23. SOLUTION Major Problem  Control the clock  Suppose that the timer set to generate 100 intrpt/sec  Normally each interrupt add 10 msec to the time  To slow down add only 9 msec  To advance add 11 msec to the time Minor Problem  Measure it  Make a series of measurements for accuracy  Discard the measurements that exceeds the threshold value  The message that came back fastest can be taken to be the most accurate.
  • 24. BERKELEY ALGORITHM  Used in systems without UTC receiver  Keep clocks synchronized with one another  One computer is master, other are slaves  Master periodically polls slaves for their times  Average times and return differences to slaves  Communication delays compensated as in Cristian‟s algo  Failure of master => election of a new master
  • 25. BERKELEY ALGORITHM a) b) c) The time daemon asks all the other machines for their clock values The machines answer The time daemon tells everyone how to adjust their clock
  • 26. 30 DECENTRALIZED AVERAGING ALGORITHM  Each machine on the distributed system has a daemon without UTC.  Periodically, at an agreed-upon fixed time, each machine broadcasts its local time.  Each machine calculates the correct time by averaging all results.
  • 27. TERMINATION DETECTION  Detecting the end of a distributed computation  Notation: let sender be predecessor, receiver be successor  Two types of markers: Done and Continue  After finishing its part of the snapshot, process Q sends a Done or a Continue to its predecessor  Send a Done only when  All of Q‟s successors send a Done  Q has not received any message since it check-pointed its local state and received a marker on all incoming channels  Else send a Continue  Computation has terminated if the initiator receives Done messages from everyone
  • 28. DISTRIBUTED SYNCHRONIZATION  Distributed system with multiple processes may need to share data or access shared data structures  Use critical sections with mutual exclusion  Single process with multiple threads  Semaphores, locks, monitors  How do you do this for multiple processes in a distributed system?  Processes may be running on different machines  Solution: lock mechanism for a distributed environment  Can be centralized or distributed
  • 29. CENTRALIZED MUTUAL EXCLUSION  Assume processes are numbered  One process is elected coordinator (highest ID process)  Every process needs to check with coordinator before entering the critical section  To obtain exclusive access: send request, await reply  To release: send release message  Coordinator:  Receive request: if available and queue empty, send grant; if not, queue request  Receive release: remove next request from queue and send grant
  • 30. MUTUAL EXCLUSION: A CENTRALIZED ALGORITHM a) Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b) Process 2 then asks permission to enter the same critical region. The coordinator does not reply. c) When process 1 exits the critical region, it tells the coordinator, when then replies to 2
  • 31. PROPERTIES  Simulates centralized lock using blocking calls  Fair: requests are granted the lock in the order they were received  Simple: three messages per use of a critical section (request, grant, release)  Shortcomings:  Single point of failure  How do you detect a dead coordinator?  A process can not distinguish between “lock in use” from a dead coordinator  No response from coordinator in either case  Performance bottleneck in large distributed systems
  • 32. DISTRIBUTED ALGORITHM  [Ricart and Agrawala]: needs 2(n-1) messages  Based on event ordering and time stamps  Process k enters critical section as follows  Generate new time stamp TSk = TSk+1  Send request(k,TSk) all other n-1 processes  Wait until reply(j) received from all other processes  Enter critical section  Upon receiving a request message, process j  Sends reply if no contention  If already in critical section, does not reply, queue request  If wants to enter, compare TSj with TSk and send reply if TSk<TSj, else queue
  • 33. A DISTRIBUTED ALGORITHM a) b) c) Two processes want to enter the same critical region at the same moment. Process 0 has the lowest timestamp, so it wins. When process 0 is done, it sends an OK also, so 2 can now enter the critical region.
  • 34. PROPERTIES  Fully decentralized  N points of failure!  All processes are involved in all decisions  Any overloaded process can become a bottleneck
  • 35. ELECTION ALGORITHMS  Many distributed algorithms need one process to act as coordinator  Doesn‟t matter which process does the job, just need to pick one  Election algorithms: technique to pick a unique coordinator (aka leader election)  Examples: take over the role of a failed process, pick a master in Berkeley clock synchronization algorithm  Types of election algorithms: Bully and Ring algorithms
  • 36. BULLY ALGORITHM  Each process has a unique numerical ID  Processes know the Ids and address of every other process  Communication is assumed reliable  Key Idea: select process with highest ID  Process initiates election if it just recovered from failure or if coordinator failed  3 message types: election, OK, I won  Several processes can initiate an election simultaneously  Need consistent result  O(n2) messages required with n processes
  • 37. BULLY ALGORITHM DETAILS  Any process P can initiate an election  P sends Election messages to all process with higher Ids and awaits OK messages  If no OK messages, P becomes coordinator and sends I won messages to all process with lower Ids  If it receives an OK, it drops out and waits for an I won  If a process receives an Election msg, it returns an OK and starts an election  If a process receives a I won, it treats sender an coordinator
  • 38. BULLY ALGORITHM EXAMPLE     The bully election algorithm Process 4 holds an election Process 5 and 6 respond, telling 4 to stop Now 5 and 6 each hold an election
  • 39. BULLY ALGORITHM EXAMPLE d) e) Process 6 tells 5 to stop Process 6 wins and tells everyone
  • 40. RING-BASED ELECTION  Processes have unique Ids and arranged in a logical ring  Each process knows its neighbors  Select process with highest ID  Begin election if just recovered or coordinator has failed  Send Election to closest downstream node that is alive  Sequentially poll each successor until a live node is found  Each process tags its ID on the message  Initiator picks node with highest ID and sends a coordinator message  Multiple elections can be in progress  Wastes network bandwidth but does no harm
  • 41. A RING ALGORITHM  Election algorithm using a ring.
  • 42. A TOKEN RING ALGORITHM a) b) An unordered group of processes on a network. A logical ring constructed in software. • Use a token to arbitrate access to critical section • Must wait for token before entering CS • Pass the token to neighbor once done or if not interested • Detecting token loss in non-trivial
  • 43. COMPARISON  A comparison of three mutual exclusion algorithms. Algorithm Messages per entry/exit Delay before entry (in message times) Problems Centralized 3 2 Coordinator crash Distributed 2 ( n – 1 ) 2 ( n – 1 ) Crash of any process Token ring 1 to 0 to n – 1 Lost token, process crash
  • 44. TRANSACTIONS Transactions provide higher level mechanism for atomicity of processing in distributed systems  Have their origins in databases Banking example: Three accounts A:$100, B:$200, C:$300  Client 1: transfer $4 fromA to B  Client 2: transfer $3 from C to B Result can be inconsistent unless certain properties are Client 1 Client 2 Read A:$100 Write A: $96 Read C: $300 Write C:$297 Read B: $200 Read B: $200 Write B:$203 Write B:$204
  • 45. Trans..ACID PROPERTIES Atomic: all or nothing Consistent: transaction takes system from one consistent state to another Isolated: Immediate effects are not visible to other (serializable) Durable: Changes are permanent once transaction completes (commits) Client 1 Client 2 Read A:$100 Write A: $96 Read B: $200 Write B:$204 Read C: $300 Write C:$297 Read B: $204 Write B:$207