www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14665] New: thread priority does nothing on linux

https://issues.dlang.org/show_bug.cgi?id=14665

          Issue ID: 14665
           Summary: thread priority does nothing on linux
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: r9shackleford gmail.com

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.

--
Jun 08 2015