Repository navigation
feat(libkernel): implement setpriority - #5545
Conversation
CnRJay
left a comment
There was a problem hiding this comment.
The target-id and which checks mirror getpriority, which is good. The value itself, though, is accepted and dropped. setpriority(PRIO_PROCESS, 0, 10) returns 0, and a following getpriority(PRIO_PROCESS, 0) still reports 0. So the pair is observably inconsistent, which the repository's exact-or-throw rule doesn't allow. It is effectively a silent stub, and those are only allowed for UI-only effects.
Not changing the host scheduling is fine. The guest nice value doesn't need to reach the host. What's missing is the guest-visible state. Two options that stay exact:
- Keep one guest nice value (there is only one guest process).
setpriorityclampsnicevalto[PRIO_MIN, PRIO_MAX](-20..20) as FreeBSD'sdonicedoes and stores it, andgetpriorityreturns it. On FreeBSD, lowering the value below the current one needs privilege (EACCESotherwise). Whether a title process on the console holds that privilege is unverified, so the lowering case could throw until it's known. - Or accept only
niceval == 0(the valuegetpriorityalready reports) and throwNotImplementedfor anything else, with the value PPSA50011 actually passes noted in the debt entry.
Which value does PPSA50011 pass? If it's 0, the second option unblocks it with no new state.
|
Same-file overlaps only, no shared logic:
Whoever lands second needs a small rebase; nothing here depends on either, and this does not change their behaviour. AI-assisted: yes |
|
Thanks — fixed following your first option. There is now one guest nice value: I kept the general model rather than accepting only AI-assisted: yes |
eae354a to
34096bd
Compare
PPSA50011 imports setpriority and stops at start-up once getpriority is implemented. Accept PRIO_PROCESS, PRIO_PGRP and PRIO_USER for the guest's own process and fail with ESRCH for any other id and EINVAL for any other which, leaving errno unchanged on success like FreeBSD's libc; the value is not applied, since the guest nice is not the host's scheduling class.
34096bd to
afc04c7
Compare
|
Checked the |
What
Implement
setpriorityin libkernel next to thegetpriorityadded in #4374.PPSA50011 imports it and stops at start-up on
main(its stop moved here oncegetprioritymerged):Behaviour follows FreeBSD's
sys_setpriorityfor the only guest process:PRIO_PROCESS,PRIO_PGRPandPRIO_USERwith 0 or the guest's own pid (its user id 0 forPRIO_USER) return 0, any other id fails withESRCHand any otherwhichwithEINVAL. errno is left unchanged on success, as in FreeBSD's libc. The value is not applied: the guest nice is not the host's scheduling class, sogetprioritykeeps reporting 0. That is recorded indocs/dev/debt/libkernel.md.Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.
guest_sched_priorityis extended:setpriorityaccepts the same target ids asgetpriority, leaves errno unchanged on success and rejects the same ids (ESRCH) andwhich(EINVAL); it passes.eboot.binunwrapped and relinked with the built relinker--windows: onmainit stops atTUC9xC1YQjs(setpriority); with this change it resolves it and runs the title's own boot ([X360] BOOT main entered), then stops later on an unrelated guest-arena mapping error, not a missing import.python tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)