Subject: Re: pthreads plan
To: Michael Graff <explorer@flame.org>
From: Charles M. Hannum <root@ihack.net>
List: tech-userlevel
Date: 11/06/1999 11:36:36
Michael Graff <explorer@flame.org> writes:

> Greg Hudson <ghudson@MIT.EDU> writes:
> 
> > I think the major sticking point is getc() and putc(), which need to
> > be (a) fast in normal programs, and (b) MT-safe in pthreads programs.
> > 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.
> 
> What about something like this?
> 
> _getc():  no multithreaded support
> _getc_MT():  locking
> 
> and in the header file:
> #if defined(_REENTRANT)
> 	rename(getc, _getc_MT);
> #else
> 	rename(getc, _getc);
> #endif

That doesn't really help, since getc() is a macro.