Subject: Re: Problems with pthread mutexes
From: Brian Dessent <[email-masked]>
To: [email-masked]
Date: Sat, 25 Sep 2004 19:10:47 -0700

Arash Partow wrote:

> I've got a problem with pthread mutexes and cygwin. When I try to initialise
> a mutex
> attribute variable, the related pthread call never returns a 0 (zero) value.
> 
> ie:
> 
>    int result = 0;
>    pthread_mutexattr_t mutex_attr;
> 
>    if ((result = pthread_mutexattr_init(&mutex_attr)) != 0)
>    {
>       printf("Error - Description: %s\n",stderror(result));
>       exit(EXIT_FAILURE);
>    }
> 
> I'm using the latest snapshot as of 24th Sept, and also got the latest
> gcc, I'm running on windows 2000 with sp4, I've also tried on win xp
> with sp2 same cygwin install etc, yet the same problem occurs.
> 
> Same code compiles ok on NetBSD 1.62 and Mandrake 10.1 and gives
> a non erroneous return code.

It must be something your code is doing wrong -- something not in the
above snippet.  I think you'll find that if you can narrow it down to a
simple testcase that compiles and exhibits the error it will be much
easier to find out what's wrong.  Your above code works fine for me:

$ cat >pthread_mutexattr.c <<EOF && \
gcc -o pthread_mutexattr.exe pthread_mutexattr.c && \
./pthread_mutexattr
#include <pthread.h>
#include <stdlib.h>

int main() {
   int result;
   pthread_mutexattr_t mutex_attr;

   if ((result = pthread_mutexattr_init(&mutex_attr)) != 0)
      perror("pthread_mutexattr_init");
   else
      printf("success");
}
EOF
success

Brian

--
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/