Skip to content

fix(libkernel): give an inheriting thread its creator's priority - #5230

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
hugodearaujo:fix/inherit-creator-priority
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
hugodearaujo:fix/inherit-creator-priority

Conversation

@hugodearaujo

Copy link
Copy Markdown
Contributor

What

A thread created with inherited scheduling took the priority stored in its attribute. On the console it runs at its creator's priority. I created threads from a homebrew payload on a PS5 (firmware 13.60), with the creator set to 450 and then to 600 through scePthreadSetprio, and read the child's priority with scePthreadGetschedparam:

Attribute of the new thread Console main
PTHREAD_INHERIT_SCHED, priority 300 set creator's (450, 600) 300
PTHREAD_INHERIT_SCHED, no priority set creator's 700
null attribute (scePthreadCreate, pthread_create) creator's 700
default attribute (pthread_create) creator's 700
PTHREAD_EXPLICIT_SCHED, priority 300 set 300 300
PTHREAD_EXPLICIT_SCHED, no priority set 700 700

The policy already followed this rule (#4086); the priority now does too. The TechnicalDebt sentence that recorded the difference is updated.

Titles, from a run on Linux with logging added to scePthreadCreate:

  • Hollow Knight: Silksong (PPSA12544): FMOD creates its threads with inherited scheduling and priority 256–265 in the attribute. "FMOD nonblocking thread (0)" is created from a thread at 700 with 265 in its attribute, so on the console it runs at 700 and here at 265; the "FMOD file thread" it creates then inherits 265 instead of 700. Silksong reads thread priorities with scePthreadGetschedparam.
  • ASTRO BOT (PPSA21567): five threads (sndz_stream_task_service, tbb_thead) are created with inherited scheduling from creators at 699 and 680 and got 700.

Tested

  • PS5 firmware 13.60: the table above.
  • Linux: full CTest 1052/1053. guest_pthread_schedparam now also creates threads from a guest thread at 450 and 600 with each attribute in the table; it aborts on main. agc_driver_tessellation segfaults the same way on current main.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1077 tests with no failures (the GPU tests skip in this VM); guest_pthread_schedparam passes.
  • Silksong and ASTRO BOT run as before.

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

Measured on a PS5 (firmware 13.60): a thread created with
PTHREAD_INHERIT_SCHED, a null attribute or a default attribute runs at
its creator's priority, whatever priority the attribute holds; with
explicit scheduling it takes the attribute's priority.

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

Copy link
Copy Markdown
Collaborator

Checked the new priority rule in PthreadPrivate (inherit → creator's priority, explicit or no creator → attribute's), the removed duplicate store in scePthreadCreate, and the TechnicalDebt update. guest_pthread_schedparam aborts without the change and passes with it; scoped build and ctest are green. Merging once the full build is green.

@adriadam10
adriadam10 merged commit b0a4753 into boykopovar:main Oct 14, 2026
9 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