NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/52826: sched_get_priority functions return wrong value for SCHED_OTHER priority



>Number:         52826
>Category:       lib
>Synopsis:       sched_get_priority functions return wrong value for SCHED_OTHER priority
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 16 17:00:00 +0000 2017
>Originator:     Onno van der Linden
>Release:        NetBSD 8.99.8
>Organization:
>Environment:
System: NetBSD sheep 8.99.8 NetBSD 8.99.8 (SHEEPKMS) #1: Mon Dec 4 16:43:49 CET 2017 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386
Architecture: i386
Machine: i386
>Description:
While trying to build mono 5.4.1.6 I bumped into a problem
with pthread_setschedparam not being able to set a priority.
That's partly caused by the fact that the sched_get_priority functions
will return their respective sysconf values
(_SC_SCHED_PRI_MIN and SC_SCHED_PRI_MAX) without taking the
policy parameter into account. The sched(3) manual page says that 
the sched_priority parameter for SCHED_OTHER must be PRI_NONE.
If (like the mono code) you expect the min and max code to be
correct and base a pthread_setschedparam on them you'll get
an error in return.
>How-To-Repeat:
call sched_get_priority_max(SCHED_OTHER) and it returns 63.
>Fix:
In /usr/src/lib/libc/sys/sched.c change the return statements
to return policy == SCHED_OTHER ? PRI_NONE : (int)sysconf(_SC_SCHED_PRI_MAX)
for sched_get_priority_max
and
return policy == SCHED_OTHER ? PRI_NONE : (int)sysconf(_SC_SCHED_PRI_MAX)
for sched_get_priority_min



Home | Main Index | Thread Index | Old Index