Seminar DC

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Lamport’s Algorithm

Lamport’s Algorithm is a pivotal method used to achieve mutual exclusion in distributed systems. In a distributed
environment, where there is no shared memory or global clock, coordinating access to shared resources among multiple
processes becomes complex. Mutual exclusion ensures that only one process can access a critical section (CS) at any
given time, preventing race conditions and ensuring data consistency. It was developed by Leslie Lamport in 1978,
this algorithm relies on the concept of logical clocks to order events across different processes.

Features that are present in the algorithm are:


•Three type of messages (REQUEST, REPLY and RELEASE) are used and communication
channels are assumed to follow FIFO order.
•A site send a REQUEST message to all other site to get their permission to enter critical section.
•A site send a REPLY message to requesting site to give its permission to enter the critical section.
•A site send a RELEASE message to all other site upon exiting the critical section.
•Every site Si, keeps a queue to store critical section requests ordered by their timestamps.
request_queuei denotes the queue of site Si
•A timestamp is given to each critical section request using Lamport’s logical clock.
•Timestamp is used to determine priority of critical section requests. Smaller timestamp gets
high priority over larger timestamp. The execution of critical section request is always in the
order of their timestamp.
Algorithm
•To enter Critical section:
• When a site Si wants to enter the critical section, it sends a request message Request(tsi,
i) to all other sites and places the request on request_queuei. Here, Tsi denotes the
timestamp of Site Si
• When a site Sj receives the request message REQUEST(tsi, i) from site Si, it returns a
timestamped REPLY message to site Si and places the request of site Si on
request_queuej

•To execute the critical section:


• A site Si can enter the critical section if it has received the message with timestamp larger
than (tsi, i) from all other sites and its own request is at the top of request_queuei

•To release the critical section:


• When a site Si exits the critical section, it removes its own request from the top of its
request queue and sends a timestamped RELEASE message to all other sites
• When a site Sj receives the timestamped RELEASE message from site Si, it removes the
request of Si from its request queue
Message Complexity, Drawbacks and Performance







Advantages and Disadvantages of
Lamport’s Algorithm

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy