Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 210 additions & 0 deletions blog/2025-10-14-decentralized-consistency.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/assets/code/c/src/DecentralizedTimerAfter.lf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target C {
import Count, Print from "Federated.lf"

reactor PrintTimer extends Print {
timer t(0, 1 sec)
timer t(10 ms, 1 sec)

reaction(t) {=
lf_print("Timer ticked at (%lld, %d).",
Expand All @@ -18,5 +18,5 @@ reactor PrintTimer extends Print {
federated reactor {
c = new Count()
p = new PrintTimer()
c.out -> p.in after 10 msec
c.out -> p.in after 10 ms
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ reactor PrintTimer {
lf_print("Received: %d at (%lld, %d)", in->value,
lf_time_logical_elapsed(), lf_tag().microstep
);
=} STAA(0) {=
=} tardy {=
lf_print("****** Violation handler invoked at (%lld, %d). "
"Intended tag was (%lld, %d).",
lf_time_logical_elapsed(), lf_tag().microstep,
Expand All @@ -30,6 +30,7 @@ reactor PrintTimer {

federated reactor {
c = new Count()
@maxwait(10 ms)
p = new PrintTimer()
c.out -> p.in after 10 msec
c.out -> p.in
}
3 changes: 2 additions & 1 deletion docs/assets/code/c/src/DecentralizedTimerSTA.lf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target C {

import Count, Print from "Federated.lf"

reactor PrintTimer(STA: time = 10 ms) extends Print {
reactor PrintTimer extends Print {
timer t(0, 1 sec)

reaction(t) {=
Expand All @@ -17,6 +17,7 @@ reactor PrintTimer(STA: time = 10 ms) extends Print {

federated reactor {
c = new Count()
@maxwait(10 ms)
p = new PrintTimer()
c.out -> p.in
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target C {
timeout: 3 s,
coordination: decentralized
}

Expand All @@ -16,14 +17,14 @@ reactor CountPrint {
lf_print("***** CountPrint Received: %d at tag (%lld, %u)",
in->value, lf_time_logical_elapsed(), lf_tag().microstep
);
=} STAA(forever) {=
// This should never happen, but it is here to demonstrate the STAA violation handler.
lf_print_warning("CountPrint: Safe to process violation!");
=} tardy {=
// This should never happen, but it is here to demonstrate the tardy violation handler.
lf_print_warning("CountPrint: Message is tardy!");
lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start());
=}
}

reactor Double(STA: time = forever) {
reactor Double {
input in: int
output out: int

Expand All @@ -36,5 +37,6 @@ federated reactor {
c = new CountPrint()
p = new Double()
c.out -> p.in
@absent_after(forever)
p.out -> c.in
}
28 changes: 28 additions & 0 deletions docs/assets/code/c/src/DecentralizedZeroDelayLoopWithChecker.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
target C {
timeout: 3 s,
coordination: decentralized
}

import CountPrint, Double from "DecentralizedZeroDelayLoop.lf"
reactor CountPrintWithChecker extends CountPrint {

reaction(t, in) {=
if (!in->is_present) {
lf_print("***** CountPrint Failed to Receive response at tag (%lld, %u)",
lf_time_logical_elapsed(), lf_tag().microstep
);
}
=} tardy {=
lf_print("***** CountPrint Received tardy input: %d at tag (%lld, %u)",
in->value, lf_time_logical_elapsed(), lf_tag().microstep
);
=}
}

federated reactor {
c = new CountPrintWithChecker()
p = new Double()
c.out -> p.in
@absent_after(20 ms)
p.out -> c.in
}
4 changes: 2 additions & 2 deletions docs/assets/code/py/src/DecentralizedTimerAfter.lf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target Python {
import Count, Print from "Federated.lf"

reactor PrintTimer extends Print {
timer t(0, 1 sec)
timer t(10 ms, 1 sec)

reaction(t) {=
print(
Expand All @@ -19,5 +19,5 @@ reactor PrintTimer extends Print {
federated reactor {
c = new Count()
p = new PrintTimer()
c.out -> p.inp after 10 msec
c.out -> p.inp after 10 ms
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ reactor PrintTimer {
f"Received: {inp.value} "
f"at ({lf.time.logical_elapsed()}, {lf.tag().microstep})"
)
=} STAA(0) {=
=} tardy {=
print(
"****** Violation handler invoked at "
f"({lf.time.logical_elapsed()}, {lf.tag().microstep}). "
Expand All @@ -33,6 +33,7 @@ reactor PrintTimer {

federated reactor {
c = new Count()
@maxwait(10 ms)
p = new PrintTimer()
c.out -> p.inp after 10 msec
c.out -> p.inp
}
3 changes: 2 additions & 1 deletion docs/assets/code/py/src/DecentralizedTimerSTA.lf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target Python {

import Count, Print from "Federated.lf"

reactor PrintTimer(STA = 10 ms) extends Print {
reactor PrintTimer extends Print {
timer t(0, 1 sec)

reaction(t) {=
Expand All @@ -18,6 +18,7 @@ reactor PrintTimer(STA = 10 ms) extends Print {

federated reactor {
c = new Count()
@maxwait(10 ms)
p = new PrintTimer()
c.out -> p.inp
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target Python {
timeout: 3 s,
coordination: decentralized
}

Expand All @@ -15,14 +16,14 @@ reactor CountPrint {

reaction(inp) {=
print(f"***** CountPrint Received: {inp.value} at tag ({lf.time.logical_elapsed()}, {lf.tag().microstep})")
=} STAA(forever) {=
=} tardy {=
# This should never happen, but it is here to demonstrate the STAA violation handler.
print("CountPrint: Safe to process violation!")
print(f"Intended time: {inp.intended_tag.time - lf.time.start()}")
=}
}

reactor Double(STA = forever) {
reactor Double {
input inp
output out

Expand All @@ -35,5 +36,6 @@ federated reactor {
c = new CountPrint()
p = new Double()
c.out -> p.inp
@absent_after(forever)
p.out -> c.inp
}
23 changes: 23 additions & 0 deletions docs/assets/code/py/src/DecentralizedZeroDelayLoopWithChecker.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
target Python {
timeout: 3 s,
coordination: decentralized
}

import CountPrint, Double from "DecentralizedZeroDelayLoop.lf"
reactor CountPrintWithChecker extends CountPrint {

reaction(t, inp) {=
if (not inp.is_present) :
print(f"***** CountPrint Failed to Receive response at tag ({lf.time.logical_elapsed()}, {lf.tag().microstep})")
=} tardy {=
print(f"***** CountPrint Received tardy input: {inp.value} at tag ({lf.time.logical_elapsed()}, {lf.tag().microstep})")
=}
}

federated reactor {
c = new CountPrintWithChecker()
p = new Double()
c.out -> p.inp
@absent_after(20 ms)
p.out -> c.inp
}
1 change: 1 addition & 0 deletions docs/assets/images/diagrams/DecentralizedZeroDelayLoop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading