Download presentation
Presentation is loading. Please wait.
1
Synchronization
2
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
3
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
4
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
5
The bully algorithm
6
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.
7
Ring Algorithm
8
Atomic Transactions A transaction is either committed completely or nothing is done (all-or- nothing) Sample tape based application
9
Atomic Transaction System consists of some number of independent processes Each process can fail at random Assume communication errors are handled by underlying software
10
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
11
Stable storage
12
Transaction primitives BEGIN TRASACTION END TRANSACTION ABORT READ WRITE
13
Example Transaction
14
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
15
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
16
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
17
Private Workspace
18
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
19
Writeahead LOG
20
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
21
Two Phase Commit
22
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
23
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
24
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
25
Time stamp
26
Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.