Code Monkey home page Code Monkey logo

distributed-system-lamport's Introduction

Lamport Clock for Distributed Systems

Simulation of distributed system with lamport clock to determine the order of events among multiple processes. Identifies logical order of events with timestamps, deadlocks and stuck processes using wait-for graphs to track dependencies between processes.

Code Run:

(Version: g++.exe (MinGW.org GCC-6.3.0-1) 6.3.0)

  • Compile the code with the command: g++ -o tut6 lamport.cpp
  • Run the compiled program: ./tut6

Sample Input/Output:

Input format: write all the commands on newline, end command accepts any format starting with end (end process, end process p1, end ), an input of newline (enter button twice) will print the output.

begin process p1
print e11
send (p2) e12
print e13
print e14
send (p2) e15
print e16
recv p2 e17
end process
begin process p2
print e21
print e22
recv p1 e12
send (p1) e17
recv p1 e15
print e26
end process

image image

2

begin process p1
recv p2 m2
send (p4) m4
end process
begin process p2
recv p3 m3
send (p1) m2
end
begin process p3
recv p4 m1
send (p2) m3
end process
begin process p4
send (p3) m1
end process

image

3

begin process p1
recv p2 m2
send (p4) m4
end process
begin process p2
recv p3 m3
send (p1) m2
end
begin process p3
recv p4 m1
send (p2) m3
end process
begin process p4
send (p3) m9
end

image

4

begin process p1
recv p2 m2
send (p4) m4
end process
begin process p2
recv p3 m3
send (p1) m2
end
begin process p3
recv p4 m1
send (p2) m3
end process
begin process p4
print def
end process

image

5

begin process p1
recv p2 m2
end process
begin process p2
recv p1 m1
end process

image

6

begin process p1
recv p2 m2
send (p4) m4
end process
begin process p2
recv p3 m3
send (p1) m2
end
begin process p3
recv p4 m1
send (p2) m3
end process
begin process p4
recv p1 m4
end process

image

7

begin process p1
send (p2) m1
print abc
print def
end process
begin process p2
print x1
recv p1 m1
print x2
send (p1) m2
print x3
end process

image

8

begin process p1
send (p2,p3) m1
end process
begin process p2
recv p1 m1
end process
begin process p3
recv p1 m1
end process

image

9

begin process p1
send (p2) m1
send (p2) m1
end process
begin process p2
recv p1 m1
recv p1 m1
end process

image

10

begin process p1
send (p2) m1
end process
begin process p2
recv p1 m1
recv p1 m1
end process

image

Errors Caught

  • Receiver process does not exist.
  • System deadlock
  • System stuck (message needed to proceed not sent and deadlock is not there)
  • Sender process does not exist
  • Incorrect input format
  • Starting new process before ending previous
  • Starting the same process again
  • Empty receivers, message
  • Sending msg to itself
  • Incorrect command etc.

distributed-system-lamport's People

Contributors

richa-iitr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.