Subject: Re: pthreads plan
To: Giles Lean <>
From: Todd Vierling <>
List: tech-userlevel
Date: 11/06/1999 15:25:53
On Sun, 7 Nov 1999, Giles Lean wrote:

: > If possible, it would be really neat to avoid the situation where
: > there are threaded objects and non-threaded objects, and never the
: > twain shall meet.
: I concur.  Avoiding support questions about having to recompile code
: with _REENTRANT is a worthy goal.

This adds Yet More Hacks when, indeed, POSIX explicitly states that you
*must* set _REENTRANT for such code.  Support questions or not, just tell
people "set _REENTRANT... the pthread man pages tell you to do so."

If you want to do the equivalent to setting _REENTRANT unconditionally, that
adds a performance hit to explicitly single-threaded code (as opposed to
just the guts of libraries, such as libc, which are compiled that way to be
shareable between single-threaded and MT code).  See <errno.h>, for example.

(Not to mention the Linuxlike programming attitude we'd give people who
think that code written on NetBSD will compile properly on other systems
without _REENTRANT.)

: > You can get the overhead for normal programs down to a single
: > condition check by introducing a global flag which gets set when the
: > first thread is created.
: I would prefer this, if the performance impact is acceptable.

Ask the vax folk.  (Hi ragge!  :)

: Library implementors still have to be very careful not to make
: assumptions that a program is not threaded just because Right Now it
: is only single threaded.

This issue is, of course, well known.

-- Todd Vierling (