Question about libpthreads

Danesh Petigara danesh102 at hotmail.com
Fri Sep 10 05:40:47 UTC 2010


Hi,
I'm using uClibc version 0.9.29 with support for the old/stable linux threads enabled. 
While browsing the libc source code, I noticed that several functions are wrapped with __pthread_mutex_lock/unlock in order to make those implementations thread-safe. All the pthread symbols are defined as weak symbols in libc. The "real" implementations of these functions are in libpthreads, however, in the old pthreads implementation, these symbols are defined as local/hidden symbols. 
When a multithreaded application invokes a libc function which it expects to be thread-safe (e.g. malloc), libc is expected to use the "real" implementation of __pthread_mutex_lock/unlock defined in libpthreads. I'm having trouble understanding how libc binds (if it does) with the correct version of __pthread_XX functions, when they're defined as hidden symbols within libpthreads? Shouldn't the __pthread_XX implementations in libpthreads be global/default symbols? I'm really keen on knowing if the libraries I've built are thread-safe as they'll be used by heavily multithreaded applications.
Your feedback will be greatly appreciated.
Thanks.
 		 	   		  


More information about the uClibc mailing list