Hi Thomas,
Problem solved: it was not the mutex but the but the pthread_mutexattr_t
that caused the error. cygwin's pthread_mutexattr_init () function checks
if its argument points to a valid object. If the pthread_mutexattr_t's value still points to a valid object (from a previous call)
pthread_mutexattr_init () fails, and so do later pthread_mutex_init()s with
this attribute. I think this behaviour is not correct since an uninitialized
pthread_mutexattr_t can point to anything (as a previously created attribute),
so this is probably a bug in cygwin (or what does the International Pthread
Attributes Committee say?). A quick look in winsup/cygwin/thread.cc shows
that this kind of check is done for more of the ..._init() functions, so there
may be similar effects (but i did not test that yet). Demo-Program below does
not work with (my) cygwin but does in my linux box:
#include <pthread.h> int main () { pthread_mutexattr_t attr; pthread_mutexattr_init (&attr); if (pthread_mutexattr_init (&attr)) { printf ("error should not happen\n"); } }
Have a look at
http://www.opengroup.org/onlinepubs/007904975/functions/pthread_mutexattr_init.html
"Results are undefined if pthread_mutexattr_init() is called specifying an already initialized attr attributes object."
Unfortunately the spec does not specify EBUSY (which as returned at the moment) as a valid return code for pthread_mutexattr_init, therefore i will change all attr_init functions to simply return 0 if they are called with an already initialized attribute.
Thomas
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/