Date: Sun, 26 Jun 2005 23:19:58 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Pablo Mora <fbsd.hackers@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: problem handling POSIX thread on FreeBSD Message-ID: <20050627041958.GB51206@dan.emsphone.com> In-Reply-To: <a9e342b5050626200472f78ea5@mail.gmail.com> References: <a9e342b5050626200472f78ea5@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050627041958.GB51206>
