Presentation is loading. Please wait.

Presentation is loading. Please wait.

Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.

Similar presentations


Presentation on theme: "Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion."— Presentation transcript:

1 Synchronization in Distributed Systems

2 Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion In single processor systems, critical regions are protected using semaphores, monitors, etc.

3 Criteria for a correct solution No two or more process inside their critical sections simultaneously No process running outside of its critical section can block other processes No process should have to wait forever to enter its critical region (starvation) No assumption about speeds or the number of CPUs should be made

4 A Centralized Algorithm One process is elected as the coordinator To enter a critical region a process needs two messages On exiting the critical region one message is sent Disadvantages: –Single point of failure –A single coordinator can become a performance bottleneck

5 A distributed Algorithm A process builds a message containing critical region ID, process ID and Time Message is broadcast On receiving a message a process: –Sends OK if it does not want to enter the critical region –If already in critical region, does not send a reply –If wants to enter compares the time stamp of the message with its own message

6 A Distributed Algorithm (cont.) The algorithm guarantees a correct solution A global time definition is necessary Disadvantages –N points of failure –2(n-1) messages are necessary per entry –Maintaining a group list is needed –N Performance bottlenecks –Slower and more complicated

7 Token Ring Algorithm A token circulates around the ring A process can enter a critical region only when it holds the token

8 Token Ring Algorithm (Cont.) Disadvantages –Loss of token –Process crash –Ring configuration maintenance

9 Clock Synchronization In centralized systems time is unambiguous but in distributed systems it should be defined Since each processor has its local clock, achieving agreement on time is not trivial

10 Logical Clocks A clock in a processor is generated by a timer interrupting at equal intervals (clock tick) Time difference in a multiprocessor system (time skew) may cause failure of time dependant programs

11 Logical Clock Lamports ALgorithm A Happens-Before relation is defined for all events (a->b) If a and b are events in the same process and a happens before b then a->b If a is the event of a message being sent and b is the event of the message being received then a->b

12 Lamports ALgorithm Happens-Before is transitive a->b and b->c then a->c If x and y happen in two processes that do not exchange messages (even indirectly) then x->y does not hold (concurrent events) If a->b then C(a) < C(b)

13 Lamports ALgorithm If a happens before b then C(a) < C(b) If a and b are the sending and receiving of a message C(a) < C(b) For all events a and b, C(a) <> C(b)

14 Questions?


Download ppt "Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion."

Similar presentations


Ads by Google