Repository navigation
Fixed Windows simulator stalls and restored host-clock tick rate - #833
Merged
fdesbiens merged 1 commit intoNov 6, 2026
Merged
Conversation
Fixes eclipse-threadx#832 The Windows simulator rework in 6.5.2.202603 changed the default tick rate and the way a simulated interrupt hands over to the thread it wakes. The tick rate went from 1 tick per 10 ms to 5 ticks per 1 ms, so simulated time ran 5 times faster than TX_TIMER_PERIODIC implied, or 50 times at the defaults. The handover had a single waiter. When a second host thread simulates interrupts, as the GUIX Win32 driver does, both threads wait and spin in SwitchToThread at a priority above the ThreadX threads. The woken thread never runs, and the tick count advances while no thread is scheduled. The win32 and win64 ports now default to TX_TIMER_PERIODIC 10 and TX_WIN32_TICKS_PER_INTERRUPT 1. The regression suite sets the previous fast values itself. The scheduler counts dispatches. A waiting interrupt spins briefly and then blocks in WaitOnAddress until that count changes or the thread it woke is no longer next to run. Any number of interrupt threads can therefore wait at once. threadx_windows_isr_handoff_test, which adds a second interrupt thread, passes 0/5 on dev and 20/20 with the fix, on both win32 and win64. With TX_TIMER_PERIODIC 5, simulated time runs at 962 ticks/s on dev and 191 with the fix. The regression suite passes in all ten configurations, apart from threadx_thread_wait_abort_and_isr_test. That test also times out on dev, where it passes 10/40 standalone against 8/40 with the fix. Assisted-by: Claude Code (Opus 5.5) <noreply@anthropic.com>
This was referenced Nov 4, 2026
fdesbiens
added a commit
that referenced
this pull request
Nov 6, 2026
…835) threadx_thread_wait_abort_and_isr_test waits for a timer interrupt to arrive while preemption is disabled. On the Windows simulators each tick wakes thread 0 from the same point and the next tick follows a fixed interval later, so the interrupt rarely finds it in the window and the test outlives ctest's 20-second timeout. Run standalone on dev, it passed 10 of 40 runs. The Linux build breaks this resonance with an interrupt injector; Windows had nothing. On Windows, thread 0 now does a pseudo-random 0 to 4,095 iterations of work before each wait, so each tick finds it at a different point in its cycle. Other ports are unchanged. A Windows injector that re-armed the port's timer early was rejected because it fixed one port and not the other. Standalone, the test passes 12/12 per port on dev's win32 and win64 ports, reaching all ten windows in at most 9 seconds and usually under one, and 12/12 per port with #833 and #834 applied. The win32 and win64 suites pass 104/104 in all five configurations, with this test reaching ten windows in 0 to 10 seconds. Assisted-by: Claude Code (Opus 5.5) <noreply@anthropic.com>
fdesbiens
added a commit
that referenced
this pull request
Nov 6, 2026
The Win32, Win64 and SMP Win64 timer threads re-armed a one-shot host timer relative to the end of each simulated interrupt, so every interrupt's latency was added to the period. Simulated time ran 37% slow at the regression suite's 1 ms period, 4.5% slow with TX_TIMER_PERIODIC 5, and 4.3% slow at the SMP port's default 10 ms. Each re-arm now advances a deadline, measured with QueryPerformanceCounter, by one period and waits for that deadline. A deadline more than a period late, or more than a period ahead after an idle kick, is reset to one period from now, so missed interrupts are dropped rather than replayed in a burst. This builds on #833, which moved TX_WIN32_TICKS_PER_INTERRUPT into tx_port.h where the new test reads it. threadx_windows_tick_rate_test, with a 2% tolerance, measured 3,163 and 3,184 ticks/s against 5,000 on win32 and win64 before the fix, and 95.7 against 100 on SMP Win64. With the fix it measures 4,999.4 to 4,999.9 and 100.0. With TX_TIMER_PERIODIC 5, both single-core ports now run at 200.0 ticks/s. SMP Win64 passes 119/119 in all five configurations. win32 and win64 pass 106/106 in each configuration except where threadx_thread_wait_abort_and_isr_test times out, which it also does on dev. Assisted-by: Claude Code (Opus 5.5) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #832
The Windows simulator rework in 6.5.2.202603 changed the default tick rate and the way a simulated interrupt hands over to the thread it wakes. The tick rate went from 1 tick per 10 ms to 5 ticks per 1 ms, so simulated time ran 5 times faster than TX_TIMER_PERIODIC implied, or 50 times at the defaults. The handover had a single waiter. When a second host thread simulates interrupts, as the GUIX Win32 driver does, both threads wait and spin in SwitchToThread at a priority above the ThreadX threads. The woken thread never runs, and the tick count advances while no thread is scheduled.
The win32 and win64 ports now default to TX_TIMER_PERIODIC 10 and TX_WIN32_TICKS_PER_INTERRUPT 1. The regression suite sets the previous fast values itself. The scheduler counts dispatches. A waiting interrupt spins briefly and then blocks in WaitOnAddress until that count changes or the thread it woke is no longer next to run. Any number of interrupt threads can therefore wait at once.
threadx_windows_isr_handoff_test, which adds a second interrupt thread, passes 0/5 on dev and 20/20 with the fix, on both win32 and win64. With TX_TIMER_PERIODIC 5, simulated time runs at 962 ticks/s on dev and 191 with the fix. The regression suite passes in all ten configurations, apart from threadx_thread_wait_abort_and_isr_test. That test also times out on dev, where it passes 10/40 standalone against 8/40 with the fix.