fix(libkernel): check and keep the scheduling policy of a thread #4086
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4086"
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 hugodearaujo on 2026-10-11T22:58:48Z.
What
Follows #4077, which fixed
sched_get_priority_max/minand left this in TechnicalDebt:pthread_setschedparamandscePthreadSetschedparamignored the policy and stored any priority, andpthread_getschedparamalways reportedSCHED_FIFO. I called the console's exports from a homebrew payload on a PS5 (firmware 13.60), on a created thread:setschedparam(self, policy, priority)mainSCHED_FIFO(1) orSCHED_RR(3), priority 256 to 767INT_MAXEINVAL, nothing changesSCHED_OTHER), 4EINVAL, nothing changesgetschedparamafterSCHED_RRwas setBoth APIs answer the same (
0x80020016for the SCE one, 22 for the POSIX one). A thread created with explicit scheduling attributes starts with the attributes' policy (SCHED_RRgives 3); one that inherits starts with its creator's (1 here, even when the attributes saySCHED_RR).So both set calls now check the policy and the priority and keep the policy, both get calls report it, and
scePthreadCreatesets it from the attributes or the creator. A null parameter still returnsEINVAL; on the console it crashed the payload.Title: Propagation: Paradise Hotel (PPSA15878) calls
pthread_setschedparamfrom three places ineboot.bin: withSCHED_FIFOand a priority from the engine (0xffe6b3), and twice with the policypthread_getschedparamreported (0xffebe2, and0x4b75df0, the priority mapping described in #4077). It ignores the result.What is still different is in TechnicalDebt: a created thread that inherits scheduling takes the priority of its attributes, where the console gives it its creator's (measured: 700 with the attributes at 300).
Tested
SCHED_FIFO, and four attribute combinations at creation.guest_pthread_schedparamcovers the accepted bands and their edges, the rejected policies, both APIs, the policy kept afterSCHED_RR, and the policy of created threads; it aborts onmain.maindoes not build on Windows (HostPollinSocket.cpp, fixed by #4021), so I built this branch with #4021 merged: 907/909,guest_pthread_schedparam,guest_sched_priorityandguest_pthread_attrpass.agc_write_trackingandguest_kernel_stack_protectfail the same way onmainwith #4021 in this VM.Until #4077 is merged this branch also carries its commit; the change of this PR is the second commit.
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 adriadam10 on 2026-10-13T10:55:50Z.
Rebased onto current
main(the TechnicalDebt entry moved todocs/dev/debt/libkernel.md; same text). Checked: scoped build and ctest,guest_pthread_schedparamfails without the change and passes with it, both APIs and the policy of created threads covered. Merging once the full build is green.