pthread_mutex_trylock does not lock

Chris Knight c.knight@teligent.co.uk
Tue Dec 3 01:37:00 GMT 2002


Hello,

I think I have found a problem in the "pthread_mutex_trylock" call.  When I
run the following code both the trylock and lock return immediately.  If I
compile this under RedHat 8 it works as I would expect with the trylock
locking the mutex and the lock stopping execution.

I am running the latest version of cygwin under Windows 2000 Pro with the
latest service packs.

/* -------------------------------------------------------------------------
-------- */

#include <pthread.h>

int main (void)
{
 pthread_mutex_t accessMutex = PTHREAD_MUTEX_INITIALIZER;

 printf ("Init\n");
 pthread_mutex_init(&accessMutex, NULL);

 printf ("Try lock(%d)\n", pthread_mutex_trylock(&accessMutex));

 printf ("Lock(%d)\n", pthread_mutex_lock(&accessMutex));

 printf ("We should never get here!");
}

/* -------------------------------------------------------------------------
-------- */

Chris Knight
Development, Teligent Ltd.
Office: +44 (1442) 283818
Mobile: +44 (7971) 646218
Email: c.knight@teligent.co.uk


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list