fix(libc): use precise Windows thread sleep #8129
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8129"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Th3EvilGod on 2026-10-19T23:23:41Z.
What
_Thrd_sleepuses winpthreadsnanosleepon Windows, which truncates sub-millisecond requests and can finish millisecond waits on 15.6 ms clock steps. Use the existing high-resolution waitable-timer helper for the bounded relative wait, rounding up to 100 ns, then recheck the absolute realtime deadline.The existing xtime normalization, one-day chunk bound, past-deadline behavior and POSIX
nanosleeppath remain intact. Add guest-API checks for 100 us and 2 ms deadlines and a broad 12 ms median bound over 31 samples. Keep the existing cancellation/console-contract gaps explicit in libc technical debt.Related to #1471; this addresses only
_Thrd_sleep. #7735 changes condition-variable waits in the same source file, independently of this function.Tested
Windows 11 Pro (26300), AMD Ryzen 7 9800X3D, WinLibs MinGW-w64 GCC 15.2.0 r7, Release build. No title or console verification.
7c2334d20835a4126ec8c8ba4af32735c4535eed, the 2 ms guest sleep median was 15,527,800 ns andguest_ampr_threadsfailed the 12 ms bound; the other three guest thread/import tests passed.precise_wait,guest_libc_threads,guest_libc_static_imports,guest_libc_cnd_timed_wait, andguest_ampr_threads. The 2 ms guest sleep median was 2,005,500 ns. Existing past, normalized-positive/negative xtime and null-target checks passed. Every sampled short sleep was checked against its absolute realtime deadline.606ebafd203c016ec18b8501a1f50a76ad52bf02: 5/5 passed.python tools/check_conventions.py --base origin/main: passed.python tools/pr_overlap.py --branch codex/libc-precise-thread-sleep --repo boykopovar/AnyPS5: completed with no confirmed overlaps. Manually inspected the shared files flagged for stale/conflicting PRs #1835, #5021, #5303, #6044, #6226, #6469, #6819, #6879, #7081, #7201, #7332, #7386, #7473 and #7715: the Threads.cpp changes affect_Cnd_timedwait, the debt changes affect other entries, and #6044 moves GuestAmprThreads.cpp unchanged into tests/memory. No other PR implements this sleep fix. #7735 also merges independently.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T23:32:15Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/src/Threads.cppcore/libs/prx/libc/src/Threads.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/tests/GuestAmprThreads.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Threads.cppdocs/dev/debt/libc.mdcore/libs/prx/libc/src/Threads.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.md