pthread_mutex_trylock does not lock

Robert Collins rbcollins@cygwin.com
Wed Dec 4 13:52:00 GMT 2002


On Thu, 2002-12-05 at 08:33, Christophe Galerne wrote:


> This
> www.opengroup.org/onlinepubs/7908799/xsh/pthread_mutexattr_settype.html
> seems to explain that a PT_MUTEX_NORMAL mutex should behave the way Chris
> expect.

NB: PT_MUTEX_NORMAL is not a posix mutex type - it's
PTHREAD_MUTEX_NORMAL.... And yes, 'NORMAL' mutexs deadlock on relocking
attempts.

Thomas Pfaff is currently updating the cygwin mutex support - it would
be great to get some user feedback on his patches, and they support
PTHREAD_MUTEX_NORMAL mutex's.

>  > We don't support NONRECURSIVE mutex's. I don't know what you mean by
>  > NORECURSIVE threads.
> 
> Then maybe one should add a comment above
> pthread.h(55): #define PTHREAD_MUTEX_NORMAL 2
> that this option is not supported.

Or you could check the return value from pthread_mutexattr_settype and
see that it returns EINVAL.

> Also above
> pthread.h(57): #define PTHREAD_MUTEX_INITIALIZER (void *)20
> a comment that says that a default MUTEX will be recursive
> might avoid some surprise. =:-D

Look at pthread.h:53 and pthread.h:58. DEFAULT is mapped to RECURSIVE as
per the 1003.1 options 'an implementation may map this mutex to one of
the other mutex types'. Thus my initial comment: ASSUMING that
PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL is broken code. 

Rob


-- 
---
GPG key available at: http://users.bigpond.net.au/robertc/keys.txt.
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://cygwin.com/pipermail/cygwin/attachments/20021204/a3395a40/attachment.sig>


More information about the Cygwin mailing list