Skip to content

Commit 0cfd81e

Browse files
committed
Add clarifications for physical time.
1 parent 870e690 commit 0cfd81e

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

01-actor-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Here is what our system looks like:
2323
![Step 1 actor model diagram](fig/Step1_Actor.svg)
2424

2525

26-
The squiggly arrows (`~>`) are [**physical connections** in LF](https://www.lf-lang.org/docs/writing-reactors/composing-reactors/#physical-connections). They still use TCP for reliable, in-order delivery on each individual link, but the receiver assigns the incoming message a logical timestamp based on its own physical clock (device's clock) rather than preserving the sender's logical timestamp. As a result, LF does not coordinate a single logical ordering across the California and New York links: messages from the two operators may arrive at either grid manager in either order.
26+
The squiggly arrows (`~>`) are [**physical connections** in LF](https://www.lf-lang.org/docs/writing-reactors/composing-reactors/#physical-connections). They still use TCP for reliable, in-order delivery on each individual link, but the receiver assigns the incoming message a logical timestamp based on its own physical clock (device's clock) rather than preserving the sender's logical timestamp. In LF, [**physical time**](https://www.lf-lang.org/docs/next/writing-reactors/time-and-timers/#logical-time) is the time measured by the execution platform, while logical time is the timestamp used to order reactions. As a result, LF does not coordinate a single logical ordering across the California and New York links: messages from the two operators may arrive at either grid manager in either order.
2727

2828
---
2929

03-timestamps.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Fortunately, we don't need ground truth. We need **both control nodes to agree o
1010

1111
## What Is [Logical Time](https://www.lf-lang.org/docs/writing-reactors/superdense-time/)?
1212

13-
Lingua Franca assigns a [**timestamp**](https://www.lf-lang.org/docs/writing-reactors/superdense-time/#tag-vs-time) to every message at the point it is created. In a federated (distributed) program, each node uses its **local physical clock** to assign timestamps. Clock synchronization protocols like NTP, PTP, or GPS keep these clocks close to each other, within a bounded error `ε`.
13+
Lingua Franca assigns a [**timestamp**](https://www.lf-lang.org/docs/writing-reactors/superdense-time/#tag-vs-time) to every message at the point it is created. In a federated (distributed) program, each node uses its **local physical clock** to assign timestamps. [**Physical time**](https://www.lf-lang.org/docs/next/writing-reactors/time-and-timers/#logical-time) is the time measured by the execution platform; LF tries to keep logical time close to physical time, but they are distinct. Clock synchronization protocols like NTP, PTP, or GPS keep these clocks close to each other, within a bounded error `ε`.
1414

1515
A timestamp becomes a **logical time** because:
1616
- When Node A sends a message with timestamp `t`, Node B processes it at logical time `t`, even if Node B's physical clock has already advanced past `t`.
@@ -148,6 +148,7 @@ For example, we can add the following to the `GridManager` reaction:
148148

149149
This handler will be invoked _instead of_ the normal reaction when a tardy message arrives.
150150
This example shows how to extract the [**intended tag**](https://www.lf-lang.org/docs/writing-reactors/distributed-execution/#tardy-message-handling), which is a **(timestamp, microstep)** pair.
151+
It also prints physical elapsed time with [`lf_time_physical_elapsed()`](https://www.lf-lang.org/docs/next/writing-reactors/time-and-timers/#comparing-logical-and-physical-times), so you can compare when the tardy message arrived in physical time with the logical time at which it should have been processed.
151152
For this grid application, merely printing a warning like this is probably not the right thing to do.
152153
What could you do better?
153154

src/Step3_Timestamps.lf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* on these messages, and with a large enough maxwait, both grid managers handle commands in the
66
* same logical time order.
77
*
8-
* The GridManager instances below use @maxwait. This is the amount of physical time a manager waits
9-
* after timestamp t before assuming no earlier remote message will arrive. For this example, it
10-
* must be at least:
8+
* The GridManager instances below use @maxwait. Physical time is the time measured by the local
9+
* platform clock; @maxwait is the amount of physical time a manager waits after timestamp t before
10+
* assuming no earlier remote message will arrive. For this example, it must be at least:
1111
*
1212
* maxwait >= clock_sync_error + network_latency + processing_overhead
1313
*

0 commit comments

Comments
 (0)