Subject: Re: pthreads plan
To: Greg Hudson <ghudson@MIT.EDU>
From: Todd Vierling <>
List: tech-userlevel
Date: 11/07/1999 22:42:23
On Sat, 6 Nov 1999, Greg Hudson wrote:

: >> And if they want to use a third-party library like Motif, tell them
: >> they're screwed?
: > Thread safety is much more than compiling the libraries you use with
: > _REENTRANT.  MT-safe code requires a knowledge of function
: > reentrancy, and implementation of same, to work correctly.
: Sure, so you assume that the Motif library isn't thread-safe,

That's the point:  you don't.  If you want things to work in a MT world, you
either lock everything POSIX dictates is MT-unsafe, including stdio for the
sake of getc and putc, or get the vendor to have Motif compiled with
_REENTRANT if the code itself is such.  At the very least, compiling a
"MT-unsafe" library with _REENTRANT means that you only have to worry about
that library's non-reentrancy.

getc() and putc() are _defined_ to be speed hacks (read POSIX or even the
ANSI spec).  Putting a check for thread existince in them drops the speed
gained, so you might as well be calling fgetc() and fputc() all the time.

-- Todd Vierling (