problem handling POSIX thread on FreeBSD
Dan Nelson
dnelson at allantgroup.com
Mon Jun 27 04:19:59 GMT 2005
In the last episode (Jun 26), Pablo Mora said:
> int main() {
> ....
> if(pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) != 0)
> /* handler */
> ....
> }
>
> $ gcc taller.c -pthread
> $ ./a.out
> pthread_attr_setscope: Unknown error: 0
> $
>
> PTHREAD_SCOPE_SYSTEM fail on freebsd ?
The libc_r and libthr threads libraries do not support
PTHREAD_SCOPE_SYSTEM. The standard does not require support for both
PTHREAD_SCOPE_PROCESS and PTHREAD_SCOPE_SYSTEM, so it's better if you
don't treat failure of pthread_attr_setscope() as fatal to the program.
If you're running FreeBSD 4.0, your only choice of threads library is
libc_r.
Also note that the pthread_attr_*() functions are special in that they
do not set the errno variable. They return their error code, so you
need to do something like:
rv = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
if (rv && rv != ENOTSUP)
handle_error();
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-hackers
mailing list