Seems to be working great

This commit is contained in:
2026-10-07 01:03:18 -06:00
parent c39c226885
commit 739347c4da
26 changed files with 6290 additions and 7007 deletions
+13 -33
View File
@@ -1,37 +1,17 @@
# Worker ABI and lifecycle
# Synchronous ABI and online-change lifecycle
The 16-argument atMbCall_cext ABI and its signature are retained. Calls are serialized
by the lifecycle mutex and priority-inheritance engine mutex. The worker accesses
fixed C contexts only. Calls may wait briefly for the engine mutex; no claim of
hard real-time maximum latency is made for OS/serial-driver operations.
There is no native worker thread in atMb 0.8. The existing 16-argument
`atMbCall_cext` ABI is retained, and every transport tick runs synchronously in
the PLC task that owns the IEC client or slave instance.
New commands:
The C component uses fixed context pools, generation-checked handles and no
retained IEC pointers. Request values and results are copied through the ABI
buffers during the owning PLC call.
| Command | Purpose | Parameters / result |
|---|---|---|
| 12 | Client transaction timing | Normal handle; status[21] duration ms, [22] successful-read age ms (saturated UDINT); other client status fields retained |
| 40 | Configure/start global worker | startAddress=CPU+1 (0 inherited mask), connectTimeoutMs=interval 1..20, responseTimeoutMs=watchdog 100..60000 |
| 41 | Worker capabilities/status | No start side effect; available even before worker starts |
For online change, `FB_reinit` closes the native context first, clears the client
handle and all IEC request pointers, and resets active-request state. The next
PLC scan recreates the context using the current configuration. Slave blocks
close their listener before clearing their native handle.
Worker status words: [0] capability 0x00040000; [1] running; [2] pthread error;
[3] configured CPU+1, 0 inherited mask; [4] interval ms; [5] watchdog ms;
[6:7] cycle counter low/high; [8:9] monotonic heartbeat low/high. Remaining words zero.
Error 260 reports worker initialization or CPU-affinity failure. Invalid settings
return 1. Invalid settings do not change current affinity/timing.
Client command 5 and server command 34 now refresh the context's scan lease and
snapshot state; they do not perform socket reads/writes. All deadline times are
sourced from CLOCK_MONOTONIC; the ABI nowMs argument is retained but ignored.
Command 6 rejects a new transaction until completion is acknowledged with command
10. Completion data cannot be overwritten by another request before acknowledgment.
Worker shutdown sets a stop flag, releases the mutex, joins the thread, then
closes contexts. Generation-tagged handles prevent access to released slots.
Watchdog expiry closes transport while preserving the slot and terminal result;
refresh resumes it. No worker thread is restarted repeatedly on link failure;
existing TCP/RTU state machines retry within it.
Socket progress is nonblocking. Socket close/configuration calls may also occur
synchronously for explicit close/reconfigure commands. These and serial ioctls are
OS calls, so target execution-time measurement remains necessary. The worker uses
normal SCHED_OTHER, not a high-priority busy loop.
The external ABI signature/API version remain unchanged. Component version is
0.5.0.0; IEC library version is 0.8.0.0.