pthread_mutexattr_getprioceiling error?

Daniel Eischen deischen at freebsd.org
Sat Jun 13 16:08:36 UTC 2009


On Sat, 13 Jun 2009, Михаил Кипа wrote:

> Next little program:
> #include <pthread.h>
> #include <iostream>
>
> int main()
> {
>        pthread_mutexattr_t t;
>        if (pthread_mutexattr_init(&t)) return 1;
>        int i;
>        std::cout << pthread_mutexattr_getprioceiling(&t, &i) << std::endl;
> }
>
> always print 22. It means that pthread_mutexattr_getprioceiling always 
> fails with EINVAL. Under Linux this example works fine, but under 
> FreeBSD 7.2 it does`n work. Is it a bug in FreeBSD thread library or 
> it ai my misunderstanding?

Well, you can't get the priority ceiling of a _mutex_ if
it the protocol is PTHREAD_PRIO_NONE.  See the POSIX spec,
excerpt here (pthread_mutex_getprioceiling):

     These functions shall fail if:

     [EINVAL]
         The protocol attribute of mutex is PTHREAD_PRIO_NONE.

POSIX makes no mention of this for operations on a mutex attribute,
but I have no idea why it wouldn't have the same error returned
under similar conditions.

Why would you want to get the priority ceiling of a mutex
attribute that is not PTHREAD_PRIO_PROTECT?  What value
could the implementation return in this case anyway, it
really doesn't make sense?

-- 
DE


More information about the freebsd-hackers mailing list