Disallow setting of priority for SCHED_OTHER threads on NetBSD
There are 7 PAL tests that are falling down due to calling
pthread_setschedparam(3) on NetBSD.
Diving into the kernel code I have found that SCHED_OTHER does not support
setting priorities other than PRI_NONE.
/* Disallow setting of priority for SCHED_OTHER threads */
if (lpolicy == SCHED_OTHER && pri != PRI_NONE) {
lwp_unlock(t);
error = EINVAL;
break;
}
-- NetBSD sources sys/kern/sys_sched.c Line 167
/usr/include/sys/param.h:#define PRI_NONE (-1)
It looks like the same rule applies for Linux:
SCHED_OTHER is the default universal time-sharing scheduler policy used
by most processes, SCHED_FIFO and SCHED_RR are intended for special
time-critical applications that need precise control over the way in
which runnable processes are selected for execution. Processes sched-
uled with SCHED_OTHER must be assigned the static priority 0, processes
scheduled under SCHED_FIFO or SCHED_RR can have a static priority in
the range 1 to 99. Only processes with superuser privileges can get a
ordering within the list of runnable processes with equal static prior-
ity.
-- http://ccrma.stanford.edu/planetccrma/man/man2/sched_setscheduler.2.html
Standard says:
The pthread_getschedparam() and pthread_setschedparam() functions shall,
respectively, get and set the scheduling policy and parameters of individual
threads within a multi-threaded process to be retrieved and set. For
SCHED_FIFO and SCHED_RR, the only required member of the sched_param
structure is the priority sched_priority. For SCHED_OTHER, the affected
scheduling parameters are implementation-defined.
The policy parameter may have the value SCHED_OTHER, SCHED_FIFO, or
SCHED_RR. The scheduling parameters for the SCHED_OTHER policy are
implementation-defined. The SCHED_FIFO and SCHED_RR policies shall have a
single scheduling parameter, priority.
http://pubs.opengroup.org/onlinepubs/
9699919799/functions/pthread_getschedparam.html
The culprit code is here: src/pal/src/thread/thread.cpp Line 1276
Fix #3272