Bug 14665 – thread priority does nothing on linux

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-06-08T12:28:40Z
Last change time
2024-12-01T16:24:35Z
Assigned to
No Owner
Creator
weaselcat
Moved to GitHub: phobos#10131 →

Comments

Comment #0 by r9shackleford — 2015-06-08T12:28:40Z
pthread_setschedprio does nothing for non-realtime threads on linux, and setting it to non-zero with a non-realtime scheduling policy is undefined behavior[1]. I believe the correct thing to do is use nice levels(as it is per-thread, not per-process in linux[2]) for thread priority[3] [1] - sched(7) - For threads scheduled under one of the normal scheduling policies (SCHED_OTHER, SCHED_IDLE, SCHED_BATCH), sched_priority is not used in scheduling decisions (it must be specified as 0). [2] - "The scheduling policy and parameters are in fact per-thread attributes on Linux." "The LinuxThreads implementation deviates from the POSIX.1 specification in a number of ways, including the following ... Threads do not share a common nice value." - pthreads(7) [3] - The dynamic priority is based on the nice value (set by nice(2), setpriority(2), or sched_setattr(2)) and increased for each time quantum the thread is ready to run, but denied to run by the scheduler. This ensures fair progress among all SCHED_OTHER threads.
Comment #1 by robert.schadek — 2024-12-01T16:24:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10131 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB