Skip to content

fix(libkernel): accept SCHED_OTHER in sched_get_priority_max/min - #1908

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
TheAggie:fix/libkernel-sched-other-priority
Oct 10, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
TheAggie:fix/libkernel-sched-other-priority

Conversation

@TheAggie

@TheAggie TheAggie commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What

sched_get_priority_max and sched_get_priority_min accepted only SCHED_FIFO (1) and SCHED_RR (3) and threw for SCHED_OTHER (2). SDL queries the SCHED_OTHER range before it sets a thread priority, so SDL titles stopped there. Quake II (PPSA99007, the homebrew port) hits it at startup.

SCHED_OTHER now reports the same 256 to 767 range as the other two policies. pthread_setschedparam applies a priority regardless of policy, so a priority taken from this range works. Policies outside 1-3 still throw.

What the console reports for SCHED_OTHER is unverified. FreeBSD accepts it with its own range, and shadPS4 rejects it with EINVAL. TechnicalDebt records this.

  • core/libs/prx/libkernel/System/src/Process.cpp: accept policies 1-3.
  • New test guest_sched_priority: policies 1, 2 and 3 report max 256 and min 767, and 0 and 4 throw.
  • docs/dev/TechnicalDebt.md: the entry above.

Tested

Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

  • The full suite (489 tests) passes on current main with 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 generated CTestTestfile.cmake commands because antivirus blocks ctest.exe on this machine.
  • tools/check_conventions.py --base origin/main passes on this branch alone.

Not tested on Linux or macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the full diff. The validation change accepts only SCHED_OTHER in addition to the existing policies, keeps other values rejected, and the focused test covers both limits and invalid policies. The console range uncertainty is recorded in TechnicalDebt. The current-head Build, Windows and Linux suites, and Conventions checks are green. I found no blocking issue.

SDL queries the SCHED_OTHER range before it sets a thread priority. It gets
the same 256 to 767 range as SCHED_FIFO and SCHED_RR, which
pthread_setschedparam applies regardless of policy. The console's answer is
unverified and recorded in TechnicalDebt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TheAggie
TheAggie force-pushed the fix/libkernel-sched-other-priority branch from 71cc955 to 570aac4 Compare October 10, 2026 05:57
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2123 core/libs/prx/libkernel/CMakeLists.txt L529

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026
@oneandonlydean
oneandonlydean merged commit ac75a96 into boykopovar:main Oct 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants