Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
356 changes: 356 additions & 0 deletions blog/2025-08-13-deadlines.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions blog/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
clean:
rm -rf *.lft *.csv *.log src-gen fed-gen include bin

12 changes: 12 additions & 0 deletions blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ eal:
title: Professor at UC Berkeley
url: http://people.eecs.berkeley.edu/~eal/
image_url: https://avatars.githubusercontent.com/u/8513334?v=4

rcakella:
name: Ravi Akella
title: Sr. Research Engineer, DENSO International America Inc.
url: https://www.linkedin.com/in/ravicakella/
image_url: https://avatars.githubusercontent.com/u/913550?v=4

fra-p:
name: Francesco Paladino
title: Postdoc, UC Berkeley
url: https://dblp.org/pid/347/8232.html
image_url: https://avatars.githubusercontent.com/u/47446988?v=4
31 changes: 31 additions & 0 deletions blog/src/CheckDeadline.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* This example uses a second reaction to check the completion time of the first reaction.
* LF deadlines are violated when the _start_ of a reaction execution is late.
* This simple pattern shows how to check that the _completion_ time of the reaction is on time.
*/
target C {
timeout: 1 s
}

import Sensor from "SensorProcessorActuator.lf"


reactor Check(exec = 10 ms, limit: time = 50 ms) {
input inp:int

reaction(inp) {=
lf_sleep(self->exec);
lf_print("%s: Received %d.", lf_reactor_name(self), inp->value);
=}
reaction(inp) {=
lf_print("%s: Met deadline.", lf_reactor_name(self));
=} deadline (limit) {=
lf_print("%s: ******* Missed deadline!", lf_reactor_name(self));
=}
}

main reactor {
s = new Sensor()
c = new Check(exec = 60 ms)
s.out -> c.inp
}
26 changes: 26 additions & 0 deletions blog/src/EnclavedProcessorActuator.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
target C {
timeout: 1 s
}

import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"

reactor ProcessorActuator(exec = 10 ms, limit = 50 ms) {
input sensor: int
p = new Processor(exec = exec)
a = new Actuator(limit = limit)
sensor -> p.inp
p.out -> a.inp
}
main reactor {
s = new Sensor()
@label("exec = 10 ms")
p1 = new Processor()
a1 = new Actuator()
s.out -> p1.inp
p1.out -> a1.inp

@enclave
@label("exec = 60 ms")
pa = new ProcessorActuator(exec = 60 ms)
s.out -> pa.sensor
}
21 changes: 21 additions & 0 deletions blog/src/FederatedSensorProcessorActuator.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
target C {
timeout: 1 s
}

import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"

reactor ProcessorActuator(exec = 10 ms, limit = 50 ms) {
input sensor: int
p = new Processor(exec = exec)
a = new Actuator(limit = limit)
sensor -> p.inp
p.out -> a.inp
}

federated reactor {
s = new Sensor()
pa1 = new ProcessorActuator(exec = 60 ms)
pa2 = new ProcessorActuator()
s.out -> pa1.sensor
s.out -> pa2.sensor
}
29 changes: 29 additions & 0 deletions blog/src/FederatedSmaller.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
target C {
timeout: 1 s
}

import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"

reactor SensorProcessorActuator(exec = 10 ms, limit = 50 ms) {
output sensor: int
s = new Sensor()
p = new Processor(exec = exec)
a = new Actuator(limit = limit)
s.out -> p.inp
p.out -> a.inp
s.out -> sensor
}

reactor ProcessorActuator(exec = 10 ms, limit = 50 ms) {
input sensor: int
p = new Processor(exec = exec)
a = new Actuator(limit = limit)
sensor -> p.inp
p.out -> a.inp
}

federated reactor {
spa = new SensorProcessorActuator()
pa = new ProcessorActuator(exec = 60 ms)
spa.sensor -> pa.sensor
}
43 changes: 43 additions & 0 deletions blog/src/FederatedWatchdog.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Use of the decentralized coordinator to implement a watchdog-like monitor.
*/
target C {
timeout: 1 s,
coordination: decentralized
}
import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"

reactor Monitored(exec = 10 ms) {
output complete:int
s = new Sensor()
p = new Processor(exec = exec)
a = new Actuator()
s.out -> p.inp
p.out -> a.inp
p.out -> complete
}

reactor Monitor(STA: time = 50 ms) {
input inp:int
timer t(0, 200 ms)

reaction(t, inp) {=
if (!inp->is_present) {
lf_print("%s: ******* Failed to receive input on time at logical time " PRINTF_TIME ".",
lf_reactor_name(self), lf_time_logical_elapsed());
} else {
lf_print("%s: Monitor OK at logical time " PRINTF_TIME ".",
lf_reactor_name(self), lf_time_logical_elapsed());
}
=} STAA(0) {=
lf_print("%s: ******* Monitor received late input.", lf_reactor_name(self));
=}
}

federated reactor {
@label("exec = 60 ms")
m = new Monitored(exec = 60 ms)
@label("STA = 50 ms")
w = new Monitor()
m.complete -> w.inp
}
22 changes: 22 additions & 0 deletions blog/src/MoreParallelSensorProcessorActuator.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
target C {
timeout: 1 s,
scheduler: GEDF_NP
}

import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"

main reactor {
s1 = new Sensor()
s2 = new Sensor()
@label("exec = 60 ms")
p1 = new Processor(exec = 60 ms)
a1 = new Actuator()
s1.out -> p1.inp
p1.out -> a1.inp

@label("exec = 10 ms")
p2 = new Processor(exec = 10 ms)
a2 = new Actuator(limit = 40 ms)
s2.out -> p2.inp
p2.out -> a2.inp
}
21 changes: 21 additions & 0 deletions blog/src/ParallelSensorProcessorActuator.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
target C {
timeout: 1 s,
scheduler: GEDF_NP
}

import Sensor, Processor, Actuator from "SensorProcessorActuator.lf"

main reactor {
s = new Sensor()
@label("exec = 60 ms")
p1 = new Processor(exec = 60 ms)
a1 = new Actuator()
s.out -> p1.inp
p1.out -> a1.inp

@label("exec = 10 ms")
p2 = new Processor(exec = 10 ms)
a2 = new Actuator(limit = 50 ms)
s.out -> p2.inp
p2.out -> a2.inp
}
45 changes: 45 additions & 0 deletions blog/src/SensorProcessorActuator.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Pattern for a typical use of deadlines in LF.
*/
target C {
timeout: 1 s
}

reactor Sensor {
output out:int
timer t(0, 200 ms)
state count: int = 0
reaction(t) -> out {=
lf_set(out, self->count);
self->count++;
=}
}

reactor Processor(exec = 10 ms) {
input inp:int
output out:int

reaction(inp) -> out{=
lf_print("%s: Received %d.", lf_reactor_name(self), inp->value);
lf_sleep(self->exec);
lf_set(out, inp->value * 2);
=}
}

reactor Actuator(limit: time = 50 ms) {
input inp:int

reaction(inp) {=
lf_print("%s: Met deadline. Received %d.", lf_reactor_name(self), inp->value);
=} deadline (limit) {=
lf_print("%s: ******* Missed deadline! Received %d.", lf_reactor_name(self), inp->value);
=}
}

main reactor {
s = new Sensor()
p = new Processor(exec = 10 ms)
a = new Actuator()
s.out -> p.inp
p.out -> a.inp
}
3 changes: 3 additions & 0 deletions docs/assets/images/vs_code/diagram_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/CheckDeadline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/EnclavedProcessorActuator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/FederatedSensorProcessorActuator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/FederatedSmaller.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/FederatedWatchdog.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/MoreParallelSensorProcessorActuator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/ParallelSensorProcessorActuator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/ParallelSensorProcessorActuator2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/SensorProcessorActuator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/blog/federate__spa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.