Skip to content

fix(libkernel): check and keep the scheduling policy of a thread - #4086

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
hugodearaujo:fix/setschedparam-console
Oct 13, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
hugodearaujo:fix/setschedparam-console

Conversation

@hugodearaujo

Copy link
Copy Markdown
Contributor

What

Follows #4077, which fixed sched_get_priority_max/min and left this in TechnicalDebt: pthread_setschedparam and scePthreadSetschedparam ignored the policy and stored any priority, and pthread_getschedparam always reported SCHED_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) Console main
SCHED_FIFO (1) or SCHED_RR (3), priority 256 to 767 0 0
same policies, priority 896 to 959 0 0
same policies, priority -2 to 255, 768 to 895, 960 to 2100, 4095, 4096, 8191, 65535, 65536, INT_MAX EINVAL, nothing changes 0, priority stored
any priority with policy 0, 2 (SCHED_OTHER), 4 EINVAL, nothing changes 0, priority stored
getschedparam after SCHED_RR was set 3 1

Both APIs answer the same (0x80020016 for the SCE one, 22 for the POSIX one). A thread created with explicit scheduling attributes starts with the attributes' policy (SCHED_RR gives 3); one that inherits starts with its creator's (1 here, even when the attributes say SCHED_RR).

So both set calls now check the policy and the priority and keep the policy, both get calls report it, and scePthreadCreate sets it from the attributes or the creator. A null parameter still returns EINVAL; on the console it crashed the payload.

Title: Propagation: Paradise Hotel (PPSA15878) calls pthread_setschedparam from three places in eboot.bin: with SCHED_FIFO and a priority from the engine (0xffe6b3), and twice with the policy pthread_getschedparam reported (0xffebe2, and 0x4b75df0, 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

Until #4077 is merged this branch also carries its commit; the change of this PR is the second commit.

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: fix(libkernel): report the console's scheduling priority range #4077
  • AI-assisted: yes

🤖 Generated with Claude Code

On a PS5 (firmware 13.60) pthread_setschedparam and
scePthreadSetschedparam accept only SCHED_FIFO and SCHED_RR with a
priority of 256 to 767 or 896 to 959, return EINVAL otherwise, and
keep the policy for pthread_getschedparam. A created thread takes the
policy of explicit scheduling attributes, or its creator's when it
inherits. Here any policy and priority were accepted and SCHED_FIFO
was always reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main (the TechnicalDebt entry moved to docs/dev/debt/libkernel.md; same text). Checked: scoped build and ctest, guest_pthread_schedparam fails without the change and passes with it, both APIs and the policy of created threads covered. Merging once the full build is green.

@adriadam10
adriadam10 force-pushed the fix/setschedparam-console branch from 0b95cb6 to 5c6a9d2 Compare October 13, 2026 10:55
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@adriadam10
adriadam10 merged commit c827e11 into boykopovar:main Oct 13, 2026
8 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.

2 participants