Skip to content

Commit 6181145

Browse files
committed
🐛 with experiment details and simulation
1 parent 0786c6a commit 6181145

File tree

13 files changed

+989
-48
lines changed

13 files changed

+989
-48
lines changed

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
## Introduction
1+
<div align="center">
2+
<img src="experiment/images/iiith-logo.png" width="25%">
3+
</div>
24

35

4-
<b>Discipline | <b>Fill your discipline name here
6+
### About the Experiment
7+
8+
<b>Discipline | <b>Computer Science and Engineering
59
:--|:--|
6-
<b> Lab | <b> Fill your lab name here
7-
<b> Experiment| <b> Fill your experiment name and number here
10+
<b> Lab | <b> Distributed Systems Virtual Lab
11+
<b> Experiment | <b> Lamport’s algorithm (6)
812

9-
### About the Experiment
1013

11-
Fill a brief description of this experiment here
14+
### Subject matter expert
1215

13-
<b>Name of Developer | <b> Fill the name of experiment owner here
16+
<b>Name of Developer | <b> Dr. Kishore Kothapalli
1417
:--|:--|
15-
<b> Institute | <b>
16-
<b> Email id| <b>
17-
<b> Department |
18+
<b> Institute | <b> IIIT Hyderabad
19+
<b> Email id | <b> [email protected]
20+
<b> Department | Computer Science and Engineering (Professor)
21+
<b> Website | [Faculty Page](https://faculty.iiit.ac.in/~kkishore/)
22+
1823

1924
### Contributors List
2025

2126
SrNo | Name | Faculty or Student | Department| Institute | Email id
2227
:--|:--|:--|:--|:--|:--|
23-
1 | . | . | . | . | .
24-
2 | . | . | . | . | .
28+
1 | Kishore Kothapalli | Professor | Computer Science and Engineering | IIIT Hyderabad | [email protected]
29+
2 | Subhajit Sahu | PhD Research Student | Computer Sceince and Enigneering | IIIT Hyderabad | [email protected]

experiment-descriptor.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"unit-type": "lu",
3+
"label": "",
4+
"basedir": ".",
5+
"LaTeXinMD": true,
6+
"code-assessment": {
7+
"include": false,
8+
"languages": ["javascript"],
9+
"position": 5
10+
},
11+
"service-worker": "/path/to/service-worker.js",
12+
"units": [
13+
{
14+
"unit-type": "aim"
15+
},
16+
{
17+
"target": "theory.html",
18+
"source": "theory.md",
19+
"label": "Theory",
20+
"unit-type": "task",
21+
"content-type": "text"
22+
},
23+
{
24+
"target": "pretest.html",
25+
"source": "pretest.json",
26+
"label": "Pretest",
27+
"unit-type": "task",
28+
"content-type": "assesment"
29+
},
30+
{
31+
"target": "procedure.html",
32+
"source": "procedure.md",
33+
"label": "Procedure",
34+
"unit-type": "task",
35+
"content-type": "text"
36+
},
37+
{
38+
"target": "simulation.html",
39+
"source": "simulation/index.html",
40+
"label": "Simulation",
41+
"unit-type": "task",
42+
"content-type": "simulation"
43+
},
44+
{
45+
"target": "posttest.html",
46+
"source": "posttest.json",
47+
"label": "Posttest",
48+
"unit-type": "task",
49+
"content-type": "assesment"
50+
},
51+
{
52+
"target": "references.html",
53+
"source": "references.md",
54+
"label": "References",
55+
"unit-type": "task",
56+
"content-type": "text"
57+
}
58+
]
59+
}

experiment/contributors.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
EMPTY
2-
<!-- Remove all lines above this line before making changes to the file -->
31
### Subject Matter Experts
4-
| SNo. | Name | Email | Institute | ID |
2+
3+
| SNo. | Name | Email | Institute | GitHub ID |
54
| :---: | :---: | :---: | :---: | :---: |
6-
| 1 | name | email | institute | id |
5+
| 1 | Kishore Kothapalli | [email protected] | IIIT Hyderabad | KishoreKothapalliIIITH |
6+
| 2 | Subhajit Sahu | [email protected] | IIIT Hyderabad | wolfram77 |
7+
| 3 | N. Mahen | [email protected] | IIIT Hyderabad | tempmn |
8+
| 4 | Ajitanshu Singh | [email protected] | IIIT Hyderabad | ajitanshu19 |
9+
710

811
### Developers
9-
| SNo. | Name | Email | Institute | ID |
12+
13+
| SNo. | Name | Email | Institute | GitHub ID |
1014
| :---: | :---: | :---: | :---: | :---: |
11-
| 1 | name | email | institute | id |
15+
| 1 | Subhajit Sahu | [email protected] | IIIT Hyderabad | wolfram77 |

experiment/experiment-name.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
## Experiment name
1+
## Lamport’s algorithm

experiment/images/example-01.png

55.4 KB
Loading

experiment/images/example-02.png

109 KB
Loading

experiment/images/iiith-logo.png

18.8 KB
Loading

experiment/pretest.json

Lines changed: 87 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,105 @@
22
"version": 2.0,
33
"questions": [
44
{
5-
"question": "This is a Sample Question 1?",
5+
"question": "What is the main purpose of Lamport's algorithm in distributed systems?",
66
"answers": {
7-
"a": "answer1",
8-
"b": "answer2",
9-
"c": "answer3",
10-
"d": "answer4"
7+
"a": "To provide fault tolerance during process crashes",
8+
"b": "To ensure only one process can access the critical section at a time",
9+
"c": "To synchronize clocks across all processes in the system",
10+
"d": "To maximize throughput in distributed systems"
1111
},
1212
"explanations": {
13-
"a": "Explanation 1 <a href='www.google.com'>here</a>",
14-
"b": "Explanation 2",
15-
"c": "Explanation 2",
16-
"d": "Explanation 2"
13+
"a": "Incorrect. Lamport's algorithm focuses on mutual exclusion, not fault tolerance.",
14+
"b": "Correct. The algorithm ensures that only one process can access the critical section at any given time.",
15+
"c": "Incorrect. While Lamport's algorithm uses logical timestamps, it does not synchronize clocks.",
16+
"d": "Incorrect. Lamport's algorithm prioritizes mutual exclusion, not throughput maximization."
1717
},
18-
"correctAnswer": "a",
18+
"correctAnswer": "b",
19+
"difficulty": "beginner"
20+
},
21+
{
22+
"question": "How does Lamport's algorithm resolve conflicts when two processes request the critical section simultaneously?",
23+
"answers": {
24+
"a": "By using a round-robin approach to give each process equal time",
25+
"b": "By comparing the timestamps of the requests and allowing the process with the smaller timestamp to enter",
26+
"c": "By randomly choosing which process gets to enter",
27+
"d": "By blocking all requests until the first process finishes executing"
28+
},
29+
"explanations": {
30+
"a": "Incorrect. Lamport’s algorithm does not use a round-robin approach.",
31+
"b": "Correct. The algorithm uses the smallest timestamp to decide which process has priority to enter the critical section.",
32+
"c": "Incorrect. The algorithm does not use randomness to resolve conflicts.",
33+
"d": "Incorrect. The algorithm does not block all requests; instead, it resolves the conflict based on timestamp comparison."
34+
},
35+
"correctAnswer": "b",
36+
"difficulty": "intermediate"
37+
},
38+
{
39+
"question": "What type of clock does Lamport's algorithm use to order events in a distributed system?",
40+
"answers": {
41+
"a": "Real-time clock",
42+
"b": "Physical clock",
43+
"c": "Logical clock",
44+
"d": "Global clock"
45+
},
46+
"explanations": {
47+
"a": "Incorrect. Lamport’s algorithm uses logical clocks, not real-time clocks.",
48+
"b": "Incorrect. The algorithm does not use physical clocks, as they may be unsynchronized in distributed systems.",
49+
"c": "Correct. Lamport’s algorithm uses logical clocks to maintain a partial ordering of events.",
50+
"d": "Incorrect. Lamport’s algorithm does not require a global clock."
51+
},
52+
"correctAnswer": "c",
1953
"difficulty": "beginner"
2054
},
2155
{
22-
"question": "This is a Sample Question 2?",
56+
"question": "Which of the following is **not** a feature of Lamport's algorithm for mutual exclusion?",
2357
"answers": {
24-
"a": "answer1",
25-
"b": "answer2",
26-
"c": "answer3",
27-
"d": "answer4"
58+
"a": "It ensures that only one process accesses the critical section at any time",
59+
"b": "It requires all processes to send messages to each other to request entry into the critical section",
60+
"c": "It resolves conflicts based on process priorities set by physical clocks",
61+
"d": "It guarantees that all processes eventually enter the critical section"
2862
},
2963
"explanations": {
30-
"a": "Explanation 1 <a href='www.google.com'>here</a>",
31-
"b": "Explanation 2",
32-
"c": "Explanation 2",
33-
"d": "Explanation 2"
64+
"a": "Incorrect. This is the main goal of Lamport’s algorithm.",
65+
"b": "Incorrect. Lamport’s algorithm relies on message passing to request entry to the critical section.",
66+
"c": "Correct. Lamport's algorithm does not rely on physical clocks; it uses logical timestamps.",
67+
"d": "Incorrect. Lamport’s algorithm ensures fairness by resolving conflicts based on timestamps."
3468
},
3569
"correctAnswer": "c",
70+
"difficulty": "intermediate"
71+
},
72+
{
73+
"question": "In Lamport's algorithm, what must a process do before entering the critical section?",
74+
"answers": {
75+
"a": "Wait for a timeout",
76+
"b": "Send a request to all other processes and wait for a reply",
77+
"c": "Increment its clock and enter immediately",
78+
"d": "Wait for a process to release the critical section"
79+
},
80+
"explanations": {
81+
"a": "Incorrect. Lamport's algorithm does not rely on timeouts to enter the critical section.",
82+
"b": "Correct. A process must send a request to all other processes and wait for replies before entering the critical section.",
83+
"c": "Incorrect. A process must first send requests and receive replies before entering.",
84+
"d": "Incorrect. The process must request entry and wait for replies, not wait for someone to release the critical section."
85+
},
86+
"correctAnswer": "b",
87+
"difficulty": "beginner"
88+
},
89+
{
90+
"question": "What happens when a process releases the critical section in Lamport's algorithm?",
91+
"answers": {
92+
"a": "It sends a message to all other processes indicating that the critical section is now available",
93+
"b": "It sends a message only to the process that requested last",
94+
"c": "It automatically enters the critical section again",
95+
"d": "It waits for the next process to request the critical section"
96+
},
97+
"explanations": {
98+
"a": "Correct. Once a process completes its work in the critical section, it sends a release message to all other processes.",
99+
"b": "Incorrect. The process must notify all other processes, not just the one that requested last.",
100+
"c": "Incorrect. The process does not automatically re-enter the critical section after releasing it.",
101+
"d": "Incorrect. The process notifies all others that it has released the critical section, allowing them to request access."
102+
},
103+
"correctAnswer": "a",
36104
"difficulty": "beginner"
37105
}
38106
]

experiment/references.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
### Link your references in here
1+
### References
2+
3+
- [Leslie Lamport, "Time, Clocks, and the Ordering of Events in a Distributed System," Communications of the ACM, 1978](https://lamport.azurewebsites.net/pubs/time-clocks.pdf)
4+
- [Andrew S. Tanenbaum, "Distributed Systems: Principles and Paradigms," Second Edition](https://vowi.fsinf.at/images/b/bc/TU_Wien-Verteilte_Systeme_VO_%28Göschka%29_-_Tannenbaum-distributed_systems_principles_and_paradigms_2nd_edition.pdf)
5+
- [George Coulouris, Jean Dollimore, Tim Kindberg, "Distributed Systems: Concepts and Design," Fifth Edition](https://ftp.utcluj.ro/pub/users/civan/CPD/3.RESURSE/6.Book_2012_Distributed%20systems%20_Couloris.pdf)

experiment/simulation/css/main.css

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,80 @@
1-
/* You CSS goes in here */
1+
/* Reset & Base */
2+
* { margin: 0; padding: 0; box-sizing: border-box; }
3+
body { font-family: Arial, sans-serif; background: #f5f5f5; }
4+
#app { display: flex; height: 100vh; }
5+
6+
/* Log Panel on Left */
7+
#log-panel {
8+
width: 250px;
9+
background: #fff;
10+
border-right: 1px solid #ddd;
11+
padding: 16px;
12+
overflow-y: auto;
13+
font-size: 13px;
14+
}
15+
.log-entry { margin-bottom: 8px; color: #000; }
16+
17+
/* Canvas Panel in Center */
18+
#canvas-panel {
19+
flex: 1;
20+
position: relative;
21+
background: #272822;
22+
display: flex;
23+
flex-direction: column;
24+
}
25+
#sim-canvas {
26+
flex: 1;
27+
width: 100%;
28+
display: block;
29+
}
30+
31+
/* Context Menu */
32+
.context-menu {
33+
position: absolute;
34+
background: #fff;
35+
border: 1px solid #ccc;
36+
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
37+
list-style: none;
38+
padding: 8px 0;
39+
display: none;
40+
z-index: 1000;
41+
}
42+
.context-menu li {
43+
padding: 8px 16px;
44+
cursor: pointer;
45+
white-space: nowrap;
46+
}
47+
.context-menu li:hover { background: #f0f0f0; }
48+
49+
/* Right Panel: Controls & State */
50+
#right-panel {
51+
width: 300px;
52+
background: #fafafa;
53+
border-left: 1px solid #ddd;
54+
display: flex;
55+
flex-direction: column;
56+
}
57+
#control-panel {
58+
padding: 16px;
59+
border-bottom: 1px solid #ddd;
60+
}
61+
#control-panel button,
62+
#control-panel select,
63+
#control-panel input[type="checkbox"] {
64+
margin: 6px 0;
65+
width: 100%;
66+
padding: 8px;
67+
font-size: 14px;
68+
}
69+
#control-panel label { display: flex; align-items: center; font-size: 14px; }
70+
#control-panel label input { margin-right: 8px; }
71+
#control-panel label input[type="checkbox"] { width: 2rem; }
72+
73+
#state-panel {
74+
flex: 1;
75+
padding: 16px;
76+
overflow-y: auto;
77+
background: #fff;
78+
font-size: 13px;
79+
border-bottom: 1px solid #ddd;
80+
}

0 commit comments

Comments
 (0)