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

Merged
TheAggie merged 1 commit from upstream-pr/1908 into main 2026-10-10 08:05:56 +00:00
TheAggie commented 2026-10-08 23:23:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T23:23:34Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4793972458 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1908). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-08T23:23:34Z. --- ### 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 - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-09 01:35:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T01:35:41Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5464767537 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1908#pullrequestreview-5464767537). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T01:35:41Z. **Review:** COMMENTED --- 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.
github-actions[bot] commented 2026-10-10 06:00:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:00:41Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094447162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1908#issuecomment-6094447162). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T06:00:41Z. --- <!-- pr-overlap --> 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](https://github.com/boykopovar/AnyPS5/blob/4faa14ef6a8fdacde9ce2cc9e528b295958a0493/core/libs/prx/libkernel/CMakeLists.txt#L529) | | |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1908
No description provided.