Skip to content

Commit

Permalink
Merge branch 'main' into dataflow
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Oct 24, 2024
2 parents f8585ce + 525cfde commit 8b16838
Show file tree
Hide file tree
Showing 16 changed files with 1,490 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ C/include
Cpp/**/include
Cpp/**/share
Cpp/**/lib
examples/Python/include
# Created by https://www.toptal.com/developers/gitignore/api/intellij,gradle,eclipse,maven,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,gradle,eclipse,maven,visualstudiocode

Expand Down
37 changes: 37 additions & 0 deletions examples/C/src/leader-election/NRP_FD_NobodyFails.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* This version of NRP_FD simply has the primary (node1) failing after 5 seconds and the backup
* (node2) failing at at 15s. The backup detects simultaneous loss of the heartbeat on both networks
* and hence assumes that the primary has failed rather than there being a network failure. Switch 1
* remains the NRP.
*
* @author Edward A. Lee
* @author Marjan Sirjani
*/
target C {
coordination: decentralized,
timeout: 1000 hours
}

import Switch, Node from "NRP_FD.lf"

federated reactor(heartbeat_period: time = 1 s, delay: time = 10 ms) {
node1 = new Node(heartbeat_period=heartbeat_period, id=1)
node2 = new Node(heartbeat_period=heartbeat_period, id=2)

switch1 = new Switch(id=1)
switch2 = new Switch(id=2)
switch3 = new Switch(id=3)
switch4 = new Switch(id=4)

node1.out -> switch1.in1, switch3.in1 after delay
switch1.out1, switch3.out1 -> node1.in after delay

switch1.out2 -> switch2.in2 after delay
switch2.out2 -> switch1.in2 after delay

switch2.out1, switch4.out1 -> node2.in after delay
node2.out -> switch2.in1, switch4.in1 after delay

switch3.out2 -> switch4.in2 after delay
switch4.out2 -> switch3.in2 after delay
}
Loading

0 comments on commit 8b16838

Please sign in to comment.