Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 07 Jul 2003 15:34:02 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        deischen@freebsd.org
Cc:        threads@freebsd.org
Subject:   Re: libc_r silliness
Message-ID:  <XFMail.20030707153402.jhb@FreeBSD.org>
In-Reply-To: <Pine.GSO.4.10.10307071444090.4037-100000@pcnet5.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 07-Jul-2003 Daniel Eischen wrote:
> On Mon, 7 Jul 2003, John Baldwin wrote:
> 
>> Just wondering why the PTHREAD_{MIN,MAX}_PRIORITY macros referenced in
>> the pthread_{get,set}schedparam() man pages are not available to
>> applications but are hidden in pthread_private.h.  It would seem that
>> these values should be exported in pthread.h.
> 
> Because they are not defined by the POSIX spec.  According
> to POSIX you should use:
> 
>   sched_get_priority_max(), sched_get_priority_min()
> 
> but it is confusing because these are specified for the process
> scheduling.  The values returned by these system calls, do not
> necessarily correspond to the values used by our thread libraries
> (in fact, they don't).

They do if you use SCHED_RR (which is the default policy) or SCHED_FIFO.
SCHED_OTHER uses -20 to 20 (nice values).

> I believe somewhere in the old spec, there were supposed to be
> at least 31 or 32 priorities (I can't seem to find that mentioned
> in the new spec).  Our thread libraries, at least libc_r and
> libpthread, use priorities 0 .. 31.
> 
> I don't really know how to handle this.  We can wrap
> sched_get_priority_{min,max}(), but how do we know whether
> the application wants process priorities or thread
> priorities?

Ugh.  Perhaps the manpage should at least be updated to not
reference the macros.  What does POSIX say about the confusion
between sched_get_priority_{min,max}?

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20030707153402.jhb>