Subject: Re: Threading problems
To: Bill Studenmund <firstname.lastname@example.org>
From: Eric Haszlakiewicz <email@example.com>
Date: 11/24/2004 22:27:06
On Wed, Nov 24, 2004 at 02:53:22PM -0800, Bill Studenmund wrote:
> On Wed, Nov 24, 2004 at 04:03:44PM -0600, Eric Haszlakiewicz wrote:
> > So the app needs to be rewritten to use the threadlib functions. ugh.
> > I thought that libc had weak aliases for the pthread functions, but I
> > just realized that it has weak aliases for it's own internal threading
> > functions instead. (why?)
> So that the right thing happens for a pthread and a non-pthread program.
> Other OSs have libc and libc_r. We didn't want to do that, and this
> behavior lets us.
By "right thing" you mean non-pthread program doesn't have the
pthread_* functions defined? Is that really a requirement?
If so, that seems to mean that even if we wanted to accept the performance
hit, it would be incorrect to just dump pthread into libc.
> > Could we have a define that turns the functions in pthread.h into
> > aliases for those in threadlib.h? That could make fixing modules that
> > currently link against pthread easier. e.g.
> I don't think that'd be a good idea. If you're using pthread.h, you're
> using libpthread, not threadlib.
The problem is that re-writing each and every package that uses
pthread to use threadlib is way too much work. We need an _easy_ way
to allow those modules to not require to be linked against libpthread
so they can be loaded by non-threaded apps.
Perhaps instead of fiddling with the compile settings we create
a libnotquite_pthread.so that has weak symbols for the pthread_* functions
which get replaced like the __libc_* ones do if loaded by an actual
- pthread compiled modules used in non-threaded programs use the stubs
- pthread using modules used in non-threaded programs die due to
no pthread_create() function.
- pthread compiled/using modules used in threaded programs work due
to libpthread loaded at exec time.
- no (3rd party) code needs to be changed (other than setting LDADD)
- non-threaded programs keep their symbol namespace clean
(unless they load a pthread compiled module, of course)