tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Moving pthread_(cond|mutex) to libc



On Tue, Jan 22, 2013 at 06:19:06AM +0100, Emmanuel Dreyfus wrote:
> Starting with NetBSD 6.0, libpthread is cursed with the NOLOAD flag,
> which means it cannot be loaded by dlopen(). The problem is that we can
> easily get to dlopen'able modules that do not use pthreads, but are
> linked to libraries that are linked with -lpthread. Such module cannot
> be loaded anymore in NetBSD 6.0.
> 
> It seems there is a conensus that pthread_(cond|mutex) should move to
> libc so that libpthread could be freed from NOLOAD [1]. I started
> looking at it and of course it raises a few problems.

I'm not sure you doing what expected.

The problem with dlopen of pthread is that a few libc functions
need to hold mutex when running from threaded programs, but we
don't want the cost of the mutex operation on non-threded ones.

At the moment the stubs in libc are complete nops - so you can't
load libpthread later and replace the stubs with their non-stub
versions (never mind the effects of dlclose!).

The idea is to make the libc stubs modify the data areas of the
mutex (and maybe allow condvar be created) so that libpthread
can be loaded later.

I've not looked at exactly what this would entail.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index