Lamport Algorithm
Lamport Algorithm
Lamport Algorithm
2 LAMPORT’S ALGORITHM
• Request for CS are executed in the increasing order of timestamps and time is
determined by logical clocks.
• Every site Si keeps a queue, request_queuei which contains mutual exclusion requests
ordered by their timestamps
• This algorithm requires communication channels to deliver messages the FIFO
order.Three types of messages are used Request, Reply and Release. These messages
with timestamps also updates logical clock
Correctness
Theorem: Lamport’s algorithm achieves mutual exclusion.
Proof: Proof is by contradiction.
Suppose two sites Si and Sj are executing the CS concurrently. For this to happen
conditions L1 and L2 must hold at both the sites concurrently.
This implies that at some instant in time, say t, both Si and Sj have their own requests
at the top of their request queues and condition L1 holds at them. Without loss of
generality, assume that Si ’s request has smaller timestamp than the request of Sj .
From condition L1 and FIFO property of the communication channels, it is clear that
at instant t the request of Si must be present in request queuej when Sj was executing
its CS. This implies that Sj ’s own request is at the top of its own request queue
when a smaller timestamp request, Si ’s request, is present in the request queuej – a
contradiction!
Message Complexity:
Lamport’s Algorithm requires invocation of 3(N – 1) messages per critical section execution.
These 3(N – 1) messages involves
• (N – 1) request messages
• (N – 1) reply messages
• (N – 1) release messages
Drawbacks of Lamport’s Algorithm:
• Unreliable approach: failure of any one of the processes will halt the progress
ofentire system.
• High message complexity: Algorithm requires 3(N-1) messages per critical
sectioninvocation.
• In case Site Sj is requesting, the timestamp of Site Si‘s request is smaller than its
ownrequest.
• Otherwise the request is deferred by site Sj.
Upon exiting site Si sends REPLY message to all the deferred requests.
Performance:
Synchronization delay is equal to maximum message transmission time. It requires 3(N –
1) messages per CS execution. Algorithm can be optimized to 2(N – 1) messages by
omitting the REPLY message in some situations.
• A site send a REQUEST message to all other site to get their permission to
entercritical section.
• A site send a REPLY message to other site to give its permission to enter the