Keith Packard wrote:
> The pthreads library introduces significant overhead for single-threaded
> applications,

Just out of curiosity, have you made some measurements?


> so it's nice to be able to use the regular libc versions
> of various routines when possible. Having libGL explicitly link to
> libpthreads makes this impossible.
> 
> Yes, libGL uses several pthreads functions, but it doesn't create
> threads itself, so the pthreads function usages are simply there to
> permit applications to use threads if they want. Glibc contains many
> pthread functions as 'weak' symbols, expressly for this situation.
> Single threaded applications bind to the non-thread-safe 'weak' versions
> of the pthread functions in glibc while pthread-using multi-threaded
> applications bind to the 'strong' versions in the real pthreads library.
> 
> The problem that Mesa's GL library faces is that there are several
> pthread functions that it uses which are not included in glibc. So, it
> currently links to libpthread and makes all GL applications use the
> thread-safe version of many glibc functions (stdio and malloc being two
> horrible consequences).
> 
> I've gone ahead and created a thread stub library that implements the
> missing functions and allows single-threaded GL applications to skip
> -lpthread.
> 
> If this seems useful (I don't know how many "real" GL applications are
> multi-threaded), we could use this on any elf system supporting weak
> symbols, adding more symbols as necessary for non-Glibc systems.

Sounds like a good idea.  Any GL app that's multithreaded should be 
linking with -lpthreads in the first place so I don't see much risk for 
breakage (undefined thread funcs at run/load time).

I guess the new code would go in the glthreads.c file, protected by 
#ifdef __GNU_C__ (or whatever).

I say go ahead, but maybe not on mesa_7_0_branch for now.

-Brian

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to