mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
rtlplayground: keep the STP and TCP timers on the system tick
stp_timers() ran every fourth pass of the main loop and stp_clock counted passes, which only measures time while a pass is one tick long. It never quite was: a pass is as long as the packets it handles, and #482 now takes up to four of them, so under an IPv4 stream a pass is about 16 ms and STP time runs at a third of its rate, with hellos 6 s apart and a root aged out after a minute. Since #483 the loop also stops sleeping while packets wait, so under a flood of cheap frames passes come faster than ticks and STP time runs fast instead, shortening the forward delay in exactly the situation a loop produces. uip_periodic() had the same problem from the other side: it ran once per pass, so the retransmit timer sped up with the loop. Both now go by the tick counter the timer interrupt keeps. The STP block catches up on ticks a long pass missed, at most eight steps at a time, and handle_tx() runs its periodics once per tick at most. One byte of xdata more, 48 bytes of code. A host test drives the gate with one pass every 5 ms, every 16 ms and every 0.6 ms for ten seconds each; the STP clock lands on 500 steps in all three, where counting passes gave 156 and 4166. A pass of 1.3 s loses time rather than firing 65 steps at once, and the arithmetic survives the tick counter wrapping.
This commit is contained in:
1 parent
40177f6318
commit
214cc6b737
4 files changed
+108
-9
No files matched your search
+5
-1
@@ -27,7 +27,8 @@ BUILDDIR = build
|
||||
TESTS = $(BUILDDIR)/test_cmd_editor \
|
||||
$(BUILDDIR)/test_port_tables \
|
||||
$(BUILDDIR)/test_page_json \
|
||||
$(BUILDDIR)/test_httpd_tx
|
||||
$(BUILDDIR)/test_httpd_tx \
|
||||
$(BUILDDIR)/test_tick_gate
|
||||
|
||||
# The table tests link the register mock and one environment file; stub/
|
||||
# stands in for the two headers a firmware build generates.
|
||||
@@ -47,6 +48,9 @@ $(BUILDDIR)/test_cmd_editor: test_cmd_editor.c support.c $(SRCROOT)/cmd_editor.c
|
||||
$(BUILDDIR)/test_port_tables: test_port_tables.c $(TABLE_ENV) hw_mock.h | $(BUILDDIR)
|
||||
$(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS)
|
||||
|
||||
$(BUILDDIR)/test_tick_gate: test_tick_gate.c support.c $(SRCROOT)/cmd_editor.c | $(BUILDDIR)
|
||||
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
|
||||
|
||||
$(BUILDDIR)/test_page_json: test_page_json.c $(TABLE_ENV) hw_mock.h | $(BUILDDIR)
|
||||
$(CC) $(CFLAGS) $(filter %.c,$^) -o $@ $(LDFLAGS)
|
||||
|
||||
|
||||
Reference in new issue
Block a user