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");
}
}