feat(libkernel): implement pthread_attr scope, inheritsched and stackaddr getters #1912
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1912"
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 TheAggie on 2026-10-08T23:23:43Z.
What
Four POSIX attribute functions were not exported:
pthread_attr_getscopeandpthread_attr_setscopekeep the contention scope. It is system scope by default, as in FreeBSD's libthr. Only process (0) and system (2) scope are accepted; anything else isEINVAL.pthread_attr_getinheritschedandpthread_attr_getstackaddrreport the attribute's existing fields.A null attribute or a null output pointer is
EINVAL. The scope is stored on the attribute (Pthread.hpp); it does not change how threads are created.ccleste (PPSA59322) imports these.
Test (
guest_pthread_attr): inheritsched reads its default and a set value; scope defaults to system, reads back process scope after a set, and rejects 1 without changing; stackaddr is null by default; null outputs and a null attribute returnEINVAL.Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.
mainwith this PR and four other small PRs of mine merged together (SCHED_OTHER priority range, MAP_ALIGNED_SUPER, the compatible pad vibration mode, empty-PT_TLS stack-guard reads, pthread_attr scope/getters). It was run from the generatedCTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.tools/check_conventions.py --base origin/mainpasses on this branch alone.Not tested on Linux or macOS.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T23:24:07Z.
Progress report (
f145139→886fd8b)📈 System libraries: 84.78% (+0.02%, +4 implemented functions)
✅ 4 implemented
pthread_attr_getinheritsched_nid_postfixpthread_attr_getscope_nid_postfixpthread_attr_getstackaddr_nid_postfixpthread_attr_setscope_nid_postfixImported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:39:19Z.
Review: APPROVED
Clean, correct addition of the missing
pthread_attraccessors. Each getter validates both the attr handle and the out-pointer (EINVAL otherwise), matching the existingpthread_attr_*style in this file, andpthread_attr_setscopecorrectly accepts only PTHREAD_SCOPE_SELF/PTHREAD_SCOPE_SYSTEM. The new_scopefield defaults to PTHREAD_SCOPE_SYSTEM (2), the POSIX default. ThePosixAttributestest covers the happy path, the EINVAL paths (null out-pointer, null attr), and scope validation (0 and 2 accepted, 1 rejected).Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:30:34Z.
Closing: ccleste (PPSA59322) stops at
shm_openon main, before these attribute calls. Reopen when one is a title's next stop on main, with the log line.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-10T17:51:30Z.
Additional Windows validation of PR head
886fd8b47ce1da343b134b572fb060d697ac153eapplied locally to main57f96fd2b36563e8380c603a92b1ef0d9d3a6aa4.Windows 11 Enterprise 26200, WinLibs r7 MinGW-w64 GCC 15.2.0, Release, BUILD_TESTING=ON. Full system-library build passed; existing
guest_pthread_attrandguest_pthread_stackpassed 5/5 runs each. No full-suite, Linux, or console result is claimed.An additional scope-query probe failed 5/5: create a thread with explicit system scope (2); set the destination attribute to process scope (0); query that thread with
pthread_attr_get_np; readpthread_attr_getscope. It reports the old destination value 0.scePthreadAttrGetalso leaves the destination scope at 0. Both queries and both reads return success. The worker is kept alive until both queries finish, then joined.This is a limitation of combining the proposed new scope field with existing query paths, not a regression claim against main where that scope export is absent. For the POSIX query, FreeBSD 11 thr_attr.c copies the thread's attribute state into the destination. Its setters accept both scope values, and thr_create.c inherits scope when inherited scheduling is selected. These are source references, not measurements on PS5.
Probe source, linked to the locally built unpatched libkernel/libc with the repository's Windows unwind setup (
-fno-asynchronous-unwind-tables, then.eh_framerenamed to.ehfram):In a separate local diagnostic change, I reset queried scope to system scope and explicitly throw on thread creation requesting process scope with explicit scheduling. Only system-scope threads are represented in that local model; inherited scheduling therefore inherits system scope. This does not implement process-scope scheduling or establish PS5 scope semantics.
The expanded behavioral test checks non-null stack-address readback, null arguments, invalid scope values, stale destination scope replacement in both query paths, inherited scope, and the exact unsupported-process-scope exception with no worker creation or errno mutation. Full system libraries built;
guest_pthread_attr,guest_pthread_stack, andguest_thread_selfeach passed 5/5, and the independent query probe changed to 5/5 pass. Six separate mutation controls (each query update removed, constant scope/stack/inheritance getters, and removed process-scope guard) were all caught; restored code passed again. Conventions and test-registration checks passed. This is diagnostic work kept local, not a new PR or a complete scheduling implementation.PPSA99902 reaches the missing scope import only with a stack of other local fixes/placeholders. It is not the title's next stop on unchanged main, so this is not a request to reopen under the first-stop rule. At the time of the original validation, no guest entry or gameplay had been reached.
AI-assisted investigation and local changes: Codex.
Follow-up (2026-10-10): integrating the attribute proposal plus the local scope-query correction into the broader diagnostic stack reached actual guest entry with
unused-filter=2. One run of local commit6469b3cd4cc63c74508e0f1a9320851161d8a10aand four runs of the following link-placeholder stack6947bf8db4bd07ae1f661471ae80ef39e9d9a52dall stopped at the same null read through the libcstrcmpwrapper. The traced immediate call isstrcmp("Project-A.exe", nullptr); the null's origin is unconfirmed. This conditional result includes other local changes and does not show that this proposal alone starts the title. No rendering or gameplay verified. The unchanged-main first-stop condition remains unmet. Details are being added to the existing startup tracking issue #1578.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T09:39:19Z.
@TheAggie
pthread_attr_getscopeis now the next stop for three catalog titles onmainc6ca798f, with_umtx_op(#1482) merged (Linux, catalog builds withsce_module/libc.prxunwrapped as #2605 requires), each withapp.elf: symbol lookup error: app.elf: undefined symbol: e2G+cdEkOmU:All three go on to
pthread_attr_getstackaddr(DxmIMUQ-wXY) oncegetscopeis in, and this PR has both. The head (886fd8b4) now conflicts withmaininGuestPthreadAttr.cpp.@pushkarreddyy opened #3377 an hour ago with
getscope,getinheritschedandsetscope; intake closed it. On 3377's head merged ontoc6ca798f,guest_pthread_attrpasses 5/5 and the three titles reachpthread_attr_getstackaddr, so that one alone doesn't get them past.Pull request closed