Skip to content

Commit d6d2ee6

Browse files
authored
Merge pull request #313 from lf-lang/deadlines
Blog on deadlines
2 parents 7ada7e8 + 7995877 commit d6d2ee6

22 files changed

+628
-0
lines changed

blog/2025-08-23-deadlines.md

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.

blog/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
clean:
2+
rm -rf *.lft *.csv *.log src-gen fed-gen include bin
3+

blog/authors.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@ eal:
2020
title: Professor at UC Berkeley
2121
url: http://people.eecs.berkeley.edu/~eal/
2222
image_url: https://avatars.githubusercontent.com/u/8513334?v=4
23+
24+
rcakella:
25+
name: Ravi Akella
26+
title: Sr. Research Engineer, DENSO International America Inc.
27+
url: https://www.linkedin.com/in/ravicakella/
28+
image_url: https://avatars.githubusercontent.com/u/913550?v=4
29+
30+
fra-p:
31+
name: Francesco Paladino
32+
title: Postdoc, UC Berkeley
33+
url: https://dblp.org/pid/347/8232.html
34+
image_url: https://avatars.githubusercontent.com/u/47446988?v=4
35+
36+
keiichibando:
37+
name: Keiichi Bando
38+
title: Chief Engineer, DENSO Create Inc.
39+
url: https://github.com/keiichibando
40+
image_url: https://avatars.githubusercontent.com/u/149469685?v=4

blog/src/CheckDeadline.lf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* This example uses a second reaction to check the completion time of the first reaction.
3+
* LF deadlines are violated when the _start_ of a reaction execution is late.
4+
* This simple pattern shows how to check that the _completion_ time of the reaction is on time.
5+
*/
6+
target C {
7+
timeout: 1 s
8+
}
9+
10+
import Sensor from "SensorProcessorActuator.lf"
11+
12+
13+
reactor Check(exec = 10 ms, limit: time = 50 ms) {
14+
input inp:int
15+
16+
reaction(inp) {=
17+
lf_sleep(self->exec);
18+
lf_print("%s: Received %d.", lf_reactor_name(self), inp->value);
19+
=}
20+
reaction(inp) {=
21+
lf_print("%s: Met deadline.", lf_reactor_name(self));
22+
=} deadline (limit) {=
23+
lf_print("%s: ******* Missed deadline!", lf_reactor_name(self));
24+
=}
25+
}
26+
27+
main reactor {
28+
s = new Sensor()
29+
c = new Check(exec = 60 ms)
30+
s.out -> c.inp
31+
}

blog/src/EnclavedProcessorActuator.lf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
target C {
2+
timeout: 1 s
3+
}
4+
5+
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"
6+
7+
reactor ProcessorActuator(exec = 10 ms, limit = 50 ms) {
8+
input sensor: int
9+
p = new Processor(exec = exec)
10+
a = new Actuator(limit = limit)
11+
sensor -> p.inp
12+
p.out -> a.inp
13+
}
14+
main reactor {
15+
s = new Sensor()
16+
@label("exec = 10 ms")
17+
p1 = new Processor()
18+
a1 = new Actuator()
19+
s.out -> p1.inp
20+
p1.out -> a1.inp
21+
22+
@enclave
23+
@label("exec = 60 ms")
24+
pa = new ProcessorActuator(exec = 60 ms)
25+
s.out -> pa.sensor
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
target C {
2+
timeout: 1 s
3+
}
4+
5+
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"
6+
7+
reactor ProcessorActuator(exec = 10 ms, limit = 50 ms) {
8+
input sensor: int
9+
p = new Processor(exec = exec)
10+
a = new Actuator(limit = limit)
11+
sensor -> p.inp
12+
p.out -> a.inp
13+
}
14+
15+
federated reactor {
16+
s = new Sensor()
17+
pa1 = new ProcessorActuator(exec = 60 ms)
18+
pa2 = new ProcessorActuator()
19+
s.out -> pa1.sensor
20+
s.out -> pa2.sensor
21+
}

blog/src/FederatedSmaller.lf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
target C {
2+
timeout: 1 s
3+
}
4+
5+
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"
6+
7+
reactor SensorProcessorActuator(exec = 10 ms, limit = 50 ms) {
8+
output sensor: int
9+
s = new Sensor()
10+
p = new Processor(exec = exec)
11+
a = new Actuator(limit = limit)
12+
s.out -> p.inp
13+
p.out -> a.inp
14+
s.out -> sensor
15+
}
16+
17+
reactor ProcessorActuator(exec = 10 ms, limit = 50 ms) {
18+
input sensor: int
19+
p = new Processor(exec = exec)
20+
a = new Actuator(limit = limit)
21+
sensor -> p.inp
22+
p.out -> a.inp
23+
}
24+
25+
federated reactor {
26+
spa = new SensorProcessorActuator()
27+
pa = new ProcessorActuator(exec = 60 ms)
28+
spa.sensor -> pa.sensor
29+
}

blog/src/FederatedWatchdog.lf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Use of the decentralized coordinator to implement a watchdog-like monitor.
3+
*/
4+
target C {
5+
timeout: 1 s,
6+
coordination: decentralized
7+
}
8+
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"
9+
10+
reactor Monitored(exec = 10 ms) {
11+
output complete:int
12+
s = new Sensor()
13+
p = new Processor(exec = exec)
14+
a = new Actuator()
15+
s.out -> p.inp
16+
p.out -> a.inp
17+
p.out -> complete
18+
}
19+
20+
reactor Monitor(STA: time = 50 ms) {
21+
input inp:int
22+
timer t(0, 200 ms)
23+
24+
reaction(t, inp) {=
25+
if (!inp->is_present) {
26+
lf_print("%s: ******* Failed to receive input on time at logical time " PRINTF_TIME ".",
27+
lf_reactor_name(self), lf_time_logical_elapsed());
28+
} else {
29+
lf_print("%s: Monitor OK at logical time " PRINTF_TIME ".",
30+
lf_reactor_name(self), lf_time_logical_elapsed());
31+
}
32+
=} STAA(0) {=
33+
lf_print("%s: ******* Monitor received late input.", lf_reactor_name(self));
34+
=}
35+
}
36+
37+
federated reactor {
38+
@label("exec = 60 ms")
39+
m = new Monitored(exec = 60 ms)
40+
@label("STA = 50 ms")
41+
w = new Monitor()
42+
m.complete -> w.inp
43+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
target C {
2+
timeout: 1 s,
3+
scheduler: GEDF_NP
4+
}
5+
6+
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"
7+
8+
main reactor {
9+
s1 = new Sensor()
10+
s2 = new Sensor()
11+
@label("exec = 60 ms")
12+
p1 = new Processor(exec = 60 ms)
13+
a1 = new Actuator()
14+
s1.out -> p1.inp
15+
p1.out -> a1.inp
16+
17+
@label("exec = 10 ms")
18+
p2 = new Processor(exec = 10 ms)
19+
a2 = new Actuator(limit = 40 ms)
20+
s2.out -> p2.inp
21+
p2.out -> a2.inp
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
target C {
2+
timeout: 1 s,
3+
scheduler: GEDF_NP
4+
}
5+
6+
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"
7+
8+
main reactor {
9+
s = new Sensor()
10+
@label("exec = 60 ms")
11+
p1 = new Processor(exec = 60 ms)
12+
a1 = new Actuator()
13+
s.out -> p1.inp
14+
p1.out -> a1.inp
15+
16+
@label("exec = 10 ms")
17+
p2 = new Processor(exec = 10 ms)
18+
a2 = new Actuator(limit = 50 ms)
19+
s.out -> p2.inp
20+
p2.out -> a2.inp
21+
}

0 commit comments

Comments
 (0)