This is the mail archive of the
pthreads-win32@sources.redhat.com
mailing list for the pthreas-win32 project.
Re: pthread_init_mutex problem
- From: 5qduh001 at sneakemail dot com
- To: ssundaragopalan at hss dot hns dot com, pthreads-win32 at sources dot redhat dot com
- Date: 04 May 2002 13:42:43 -0000
- Subject: Re: pthread_init_mutex problem
I'd be interested in measurements comparing calling pthread_mutex_init() vs. using PTHREAD_MUTEX_INITIALIZER.
I.e the code from the earlier e-mail:
pthread_mutex_t mutex;
assert(pthread_mutex_init(&mutex, NULL) == 0);
vs.
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
I haven't looked at the win32 pthread source to see what happens in either, but I can only imagine that the latter would be more efficient if the implementation in win32 pthreads is anything like what most other implementations do (a linux implementation in this case), basically:
pthread_mutex_t mutex = {0, 0, 0, PTHREAD_MUTEX_FAST_NP, {0, 0}};
As I understand it, using PTHREAD_MUTEX_INITIALIZER should also allow you to avoid the call to pthread_mutex_destroy() thus another saving.
If the PTHREAD_MUTEX_INITIALIZER is faster as I suspect, please let us know and by roughly how much :).
Good luck,
Dave
-----------------------------------------------------
Protect yourself from spam, use http://sneakemail.com