Repository navigation
fix(libkernel): report the console's scheduling priority range - #4077
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
On a PS5 (firmware 13.60) sched_get_priority_max returns 767 and sched_get_priority_min 256 for SCHED_FIFO and SCHED_RR; the two were swapped. Every other policy, SCHED_OTHER included, returns -1 with EINVAL instead of a range or a host exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 tasks done
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.
What
sched_get_priority_maxreturned 256 andsched_get_priority_min767 for policies 1 to 3, and other policies threw. TechnicalDebt said the console's answer was unverified. I called the console's exports from a homebrew payload on a PS5 (firmware 13.60):mainmax / minSCHED_FIFO)SCHED_RR)SCHED_OTHER)So the range was swapped, and every policy without a range fails with
EINVALinstead of a host exception. A second check agrees: on the console a mutex attribute set toPTHREAD_PRIO_PROTECTreports a default ceiling of 767, the highestSCHED_RRpriority in FreeBSD libthr.pthread_mutexattr_setprotocolhere takes that ceiling fromsched_get_priority_max(SCHED_RR), so onmainit is 256; this change fixes it too.Title: Propagation: Paradise Hotel (PPSA15878) sets its thread priorities this way (
eboot.bin0x4b75d60):Threads report
SCHED_FIFOboth on the console and here, so with the swapped range each level got the mirrored priority: level 4 gave 767 instead of 256.The
SCHED_OTHERrange was accepted for SDL titles (#1908). SDL now gets -1 andEINVAL, as on the console, instead of an exception or a range.The TechnicalDebt entry gives the measurements. It also notes what is still different and left for a separate change:
pthread_setschedparamignores the policy and does not check the priority, where the console rejectsSCHED_OTHERand priorities below 256 withEINVAL.Tested
pthread_getschedparamon the main thread and on a created thread (bothSCHED_FIFO).guest_sched_prioritynow checks both ranges and theEINVALcases; it aborts onmain.guest_pthread_mutexattralready compares the ceiling withsched_get_priority_max(SCHED_RR)and passes.maindoes not build on Windows (HostPollinSocket.cpp, fixed by fix(libkernel): restore Windows select build for Demons Souls testing #4021), so I built this branch with fix(libkernel): restore Windows select build for Demons Souls testing #4021 merged: 903/905,guest_sched_priorityandguest_pthread_mutexattrpass.agc_write_trackingandguest_kernel_stack_protectfail the same way onmainwith fix(libkernel): restore Windows select build for Demons Souls testing #4021 in this VM.Overlap: #3654 adds its
getpriorityTechnicalDebt entry right below the entry this PR rewrites, so whichever lands second needs a one-line rebase. #3654 already conflicts withmainelsewhere.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