Subject: Re: Pthreads, libc, and the future
To: Curt Sampson <cjs@cynic.net>
From: Michael Graff <explorer@flame.org>
List: tech-userlevel
Date: 12/13/1999 14:30:43
Curt Sampson <cjs@cynic.net> writes:
> > Not to mention that this would induce unnecessary overhead in threadless
> > programs. Think m68k and VAX.
>
> And much faster machines, too. A 500 MHz Pentium III can't do more
> than about 4-5 MB/sec to disk using getc() and putc() under Linux
> due to this sort of thing.
If you don't define _REENTRANT in our current code, you still get
normal, unlocked getc() and putc(). If you do, you get a function
rather than a macro. That function will always call a locking
function, which may be a do-nothing one or a real, live one.
Under FreeBSD (and I planned on doing it for us, too) a global int
__is_threaded is non-zero if threading is in use. I see no reason we
can't opt not to do these function calls if it is not set. That means
that in the non-threaded (but thread "capable") the overhead to find
out a lock isn't needed is
if (__is_threaded != 0)
LOCK(...);
--Michael