Top Banner
Synchronization
26

Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Synchronization

Page 2: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Physical Clocks

• Solar Physical Clocks

• Cesium Clocks

• International Atomic Time

• Universal Coordinate Time (UTC)

• Clock Synchronization Algorithms– One machine is connected to WWV– No machine is receiving WWV time

Page 3: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Election Algorithms

• Many distributed systems require one process to act as coordinator

• Assume:– All processes are the same– Each process has a process number– Each process knows the process number of

every other process

Page 4: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

The Bully Algorithm

• When a process P notices the coordinator is no longer responding it initiates and election– P sends ELECTION to every process with a

higher number– If no one responds P wins and becomes

coordinator– If one of the higher-numbered processes

responds then it takes over and P is done

Page 5: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

The bully algorithm

Page 6: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Ring Algorithm

• The process noticing that the coordinator is not functioning builds an ELECTION message containing its process number and sends it its successor

• When the message gets back to the process that started it, its type is changed to COORDINATOR and sent around the ring

• The process with the largest number is elected.

Page 7: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Ring Algorithm

Page 8: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Atomic Transactions

• A transaction is either committed completely or nothing is done (all-or-nothing)

• Sample tape based application

Page 9: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Atomic Transaction

• System consists of some number of independent processes

• Each process can fail at random

• Assume communication errors are handled by underlying software

Page 10: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Storage types

• Volatile RAM memory

• Disk storage

• Stable storage– Implemented using two or more disks– In case a failure, the second disk is used for

recovery

Page 11: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Stable storage

Page 12: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Transaction primitives

• BEGIN TRASACTION

• END TRANSACTION

• ABORT

• READ

• WRITE

Page 13: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Example Transaction

Page 14: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Properties of Transactions

• Serializability

Concurrent transactions do not interfere with each other

• Atomicity• To the outside world, the transaction happens

indivisibly

• Permanence• Once a transaction commits, the changes are

permanent

Page 15: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Nested Transactions

• The transactions can be contain sub-transactions

• Either all sub-transactions should commit or abort

• Each sub-transaction is given a private copy of data

Page 16: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Implementation

• Private Workspace– The copying is expensive– Optimizations for read and write are available

• No copy if no write is going on• Only copy the block list of files and update

modified blocks

Page 17: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Private Workspace

Page 18: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Writeahead Log

• A list called an intension list or LOG is created with TransID, BlockNo, OldVal, NewVal fields

• After the log has been successfully written, the changes are made to the file

• In case of ABORT, the operation are reversed from last to first

Page 19: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Writeahead LOG

Page 20: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Two Phase Commit

• Send each subordinate a message

• A subordinate responds when it is ready to commit

• If all subordinates are ready then commit else abort

Page 21: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Two Phase Commit

Page 22: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Concurrency Control

• Locking– A process can lock a file before a transaction– Smaller piece of data can be lock for

efficiency (Granularity of locking)– Two phase locking (growing and shrinking)

can be used to avoid deadlocks and cascaded aborts

Page 23: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Optimistic concurrency Control

• Perform any transaction without considering other processes

• When committing the transaction, check if the files have been changed or not

• It is DeadLock Free

• In case of failure the transaction should re-run

Page 24: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Time stamp

• Assign a time stamp to each transaction at the moment it begins

• On committing check the orders– If orders true then commit – Else abort

Page 25: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Time stamp

Page 26: Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.

Questions?