Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Mar 1998 01:20:44 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        dali@proxima.britcoun.cz (Dalibor Sramek)
Cc:        jb@cimlogic.com.au, hackers@FreeBSD.ORG
Subject:   Re: Free-BSD threads & IO
Message-ID:  <199803250120.SAA15818@usr02.primenet.com>
In-Reply-To: <Pine.BSF.3.95q.980324113506.4218A-100000@proxima.britcoun.cz> from "Dalibor Sramek" at Mar 24, 98 11:40:22 am

next in thread | previous in thread | raw e-mail | index | archive | help
> > Did you compile with -D_THREAD_SAFE and link with -lc_r?
> 
> I linked the library but I did not used the -D_THREAD_SAFE option. Is this
> option system specific? (I used makefile provided with the examples).
> Anyway I will try it.

Yes, it's system specific.  I don't like it being that way, but
that's the way it is (for now, FreeBSD requires "-D_THREAD_SAFE").

If you are not using "-stable", but instead are using a FreeBSD
from a CDROM, you will not be able to get your threads code to
work reliably, especially if you are using signals, sockets, the
fcntl() for dup, dup, dup2, or the ioctl() to set the fd into
non-blocking mode (which is incorrectly sent down instead of
being proxied into the flags for the thread fd).  You will also
have problems with the return values of various functions.

For the -stable version of pthreads, there are only a few things
to look out for.  Most of these are the result of the differences
between pthreads draft 4 and the draf 10/final implementations;
FreeBSD -stable and -current are currently draft 4 implementations.

The two major "gotcha's" are:

	o	you can't statically initialize a pthread_mutex_t
		in draft 4 pthreads

	o	If you pass an attribute to pthread_create, you
		need to pass the address of the attribute instead
		of the attribute itself.

You can compile-time test for draft 4 by:

#ifndef PTHREAD_MUTEX_INITIALIZER

	/*
	 * Draft 4 code here
	 */

#else	/* !PTHREAD_MUTEX_INITIALIZER*/

	/*
	 * Draft 10/final code here
	 */

#endif	/* !PTHREAD_MUTEX_INITIALIZER*/


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



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