Lamport’s algorithm for mutual exclusion

13
LAMPORT’S ALGORITHM BY Neelamani Samal

description

The slide deals with the basic working principle of Lamport's algorithm.It explains the details with example

Transcript of Lamport’s algorithm for mutual exclusion

Page 1: Lamport’s algorithm for mutual exclusion

LAMPORT’S ALGORITHM

BY

Neelamani Samal

Page 2: Lamport’s algorithm for mutual exclusion

What is Lamport’s Algorithm

• It is a computer algorithm

• Intended to improve the safety in the

usage of shared resources

•  Using mutual exclusion.

Page 3: Lamport’s algorithm for mutual exclusion

Related Terms

• Mutual exclusion

• Types of mutual exclusion algorithm

• Critical Section(C.S.)

• Logical Clock

• Causal Ordering Of Messages

Page 4: Lamport’s algorithm for mutual exclusion

Algorithm

• Every site Si keeps a request_queuei,

• contains mutual exclusion requests ordered by their timestamps

• messages to be delivered in the FIFO order between every pair of sites

Page 5: Lamport’s algorithm for mutual exclusion

System Models

• Requesting The C.S.

• Executing The C.S.

• Releasing The C.S.`

Page 6: Lamport’s algorithm for mutual exclusion

Example

• We have S1,S2,S3 as sites

• S1,S2 request for CS

• S2 Being first

Page 7: Lamport’s algorithm for mutual exclusion

S1

S2

S3

(1,2)

(2,1)

S1,S2 making requesr for entering CS

Page 8: Lamport’s algorithm for mutual exclusion

S1

S2

S3

(1,2)

(2,1)

Site S2 enters CS

(1,2) (1,2),(2,1)

(1,2),(2,1)

(1,2),(2,1)

S2 enters CS

Page 9: Lamport’s algorithm for mutual exclusion

S1

S2

S3

(1,2)

(2,1)

Site S2 exitsCS and release message

(1,2) (1,2),(2,1)

(1,2),(2,1)

(1,2),(2,1)

S2 exits CS

Page 10: Lamport’s algorithm for mutual exclusion

S1

S2

S3

(1,2)

(2,1)

Site S1 entersCS

(1,2) (1,2),(2,1)

(1,2),(2,1)

(1,2),(2,1)

S1enters CS

(2,1)

(2,1)

Page 11: Lamport’s algorithm for mutual exclusion

Performance Analysis

• Total No. of REQUEST (N-1)

• Total No. Of REPLY (N-1)

• Total No. Of RELEASE (N-1)

• Total = 3(N-1)

Page 12: Lamport’s algorithm for mutual exclusion

Conclusion

Though it does not explain the Modern scenario of distributed

systems but , it gave the basic of developing the present way

of handling distributed resources.

Page 13: Lamport’s algorithm for mutual exclusion