https://github.com/aakashks/distributed-systems
https://github.com/aakashks/distributed-systems
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/aakashks/distributed-systems
- Owner: aakashks
- Created: 2024-10-21T18:46:30.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-22T05:16:53.000Z (8 months ago)
- Last Synced: 2025-04-27T03:36:29.037Z (about 1 month ago)
- Language: C++
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Birman-Schiper-Stephenson Protocol
## Running the code
Must have gcc installed to compile the code. Linux / Macos specific instructions are given below.
Run the following command to compile the code
```bash
g++ -std=c++11 bss.cpp -o bss
```To run the code for an input file (eg. [input](input)) -
```bash
./bss < input
```To save the output in a file, run the following command -
```bash
./bss < input > output
```there are 3 input files in the repository, you can use them to test the code.
## Sample Inputs
Input 1:
```
begin process p1
send m1
recv_B p2 m2
end process p1begin process p2
recv_B p1 m1
send m2
end process p2begin process p3
recv_B p2 m2
recv_B p1 m1
end process p3
```Output 1:
```
begin process p1
send m1 (100)
recv_B p2 m2 (100)
recv_A p2 m2 (110)
end process p1begin process p2
recv_B p1 m1 (000)
recv_A p1 m1 (100)
send m2 (110)
end process p2begin process p3
recv_B p2 m2 (000)
recv_B p1 m1 (000)
recv_A p1 m1 (100)
recv_A p2 m2 (110)
end process p3```
Input 2:
```
begin process p2
send m2
recv_B p4 m4
recv_B p1 m1
end process p2begin process p1
send m1
recv_B p4 m4
recv_B p2 m2
end process p1begin process p4
recv_B p2 m2
recv_B p1 m1
send m4
end process p4begin process p3
recv_B p2 m2
recv_B p1 m1
recv_B p4 m4
end process p3
```Output 2:
```
begin process p2
send m2 (0100)
recv_B p4 m4 (0100)
recv_B p1 m1 (0100)
recv_A p1 m1 (1100)
recv_A p4 m4 (1101)
end process p2begin process p1
send m1 (1000)
recv_B p4 m4 (1000)
recv_B p2 m2 (1000)
recv_A p2 m2 (1100)
recv_A p4 m4 (1101)
end process p1begin process p4
recv_B p2 m2 (0000)
recv_A p2 m2 (0100)
recv_B p1 m1 (0100)
recv_A p1 m1 (1100)
send m4 (1101)
end process p4begin process p3
recv_B p2 m2 (0000)
recv_A p2 m2 (0100)
recv_B p1 m1 (0100)
recv_A p1 m1 (1100)
recv_B p4 m4 (1100)
recv_A p4 m4 (1101)
end process p3```