feat(libkernel_sys): implement sched_rr_get_interval #9382
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9382"
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 MarcZX10 on 2026-10-21T19:54:56Z.
What
Implement
sched_rr_get_intervalfor the guest's current process. It reports the FreeBSD 11 ULE default time slice for usual AMD64 clock rates (94 ms), accepts pid 0 or the current guest pid, and returnsESRCHfor other pids andEFAULTfor a null output pointer. The emulator does not model per-process scheduling quantum changes; that limitation is recorded in technical debt.Tested
cmake --build build --target guest_sched_priority_tests -j2passed.python3 tools/check_conventions.py --base upstream/mainpassed.python3 tools/pr_overlap.py --base main --branch codex/libkernel-sys-sched-interval --jobs 2reported no overlap with open PRs.ctest --test-dir build -R '^guest_sched_priority$' --output-on-failurecould not enter the test: this host's Intel Xeon E5-1620 v2 lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, and FMA required by AnyPS5's CPU guard.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T22:41:47Z.
Windows run of
76178efc32merged ontomaina6dcea9279(6cd718d449, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release,BUILD_TESTING=ON.Built
libkernel,libkernel_sysandguest_sched_priority_testswith no errors or warnings.ctest --repeat until-fail:2onguest_sched_priority: passes on both repeats. Not run: a title.Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-21T23:39:36Z.
Windows layout problem: the guest's
tv_nsecis not fully written.Head
76178efc32merged onto maina6dcea927(clean). Windows 11 Home 10.0.26300, Ryzen 5 9600X, WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release,BUILD_TESTING=ON; WSL2 Ubuntu 24.04, GCC 13.3.0, Release.sched_rr_get_interval_nid_postfixtakes the hoststruct timespec*. On MinGW the hosttimespecis a 64-bittv_secand a 32-bitlong tv_nsec, so the store writes only the low 4 bytes of the guest's 64-bittv_nsec. The test uses the same host struct, so it cannot see this. Probe: a 16-byte guest timespec filled with0xff, thensched_rr_get_interval(0, &value):ret=0 tv_sec=0 tv_nsec=-4200967296 (0xffffffff059a5380)ret=0 tv_sec=0 tv_nsec=94000000 (0x00000000059a5380)Using
KernelTimespec(or twostd::int64_tfields), as #9388 had to fortimespec_get, and pre-filling the output in the test fixes it and makes it observable.Other results:
guest_sched_priority: 3/3 on Windows, 3/3 on Linux. WithExport.cppandExport.Discovery.cppfrom main:sched_rr_get_interval_nid_postfix not implemented.ksched_attachstores1000000000 / hz * sched_rr_interval()(ksched.c L66) and ULE'ssched_rr_interval()is(sched_slice * hz + realstathz / 2) / realstathz(sched_ule.c L1705), 94 with hz 1000, stathz 127, slice 12. The ESRCH-before-EFAULT order matchessys_sched_rr_get_interval.sched_rr_get_interval(PrsRaaSO-X0) is exported by PS5 3.20 libkernel as well as libkernel_sys (libkernel.c L8845). On Windows a libkernel import does not search libkernel_sys (WindowsEntryStubBuilder.cpp:175-177adds libkernel only for libkernel_sys/libkernel_web imports), so a title that imports it from libkernel will not reach this implementation.AI-assisted: yes (Claude Code); results above were run on this machine.