delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/12/05/02:34:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Subject: Re: pthread_mutex_trylock does not lock
From: Robert Collins <rbcollins AT cygwin DOT com>
To: Christophe Galerne <christophegalerne AT earthlink DOT net>
Cc: cygwin <cygwin AT cygwin DOT com>
In-Reply-To: <3DEE9416.8060605@earthlink.net>
References: <3DEE74C3 DOT 1070208 AT earthlink DOT net>
<1039074697 DOT 8812 DOT 24 DOT camel AT lifelesswks> <3DEE9416 DOT 8060605 AT earthlink DOT net>
Date: 06 Dec 2002 04:34:11 +1100
Message-Id: <1039109651.13185.2.camel@lifelesswks>
Mime-Version: 1.0

--=-J+I8g9dC6fm50VNWTHyj
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Thu, 2002-12-05 at 10:47, Christophe Galerne wrote:


> > Or you could check the return value from pthread_mutexattr_settype and
> > see that it returns EINVAL.
>=20
> The thing is it's not really an invalid value for 'type' in the call.
> Maybe it would be better to break the compilation of programs that
> expect this value rather than have the developpers debug their applicatio=
ns
> before figuring it out.

With all due respect, any program that doesn't log and quit with such an
error - ie one that requires debugging - is already broken. Good
programs *do* check error codes. And they *do* set the mutex type they
need if the behaviour for PTHREAD_MUTEX_DEFAULT does not suite.
=20

> > Look at pthread.h:53 and pthread.h:58. DEFAULT is mapped to RECURSIVE=20
>=20
> That's a good point.
> Onather solution that might be considered more elegant would be to
> rearrange the defines to make the default behavior self-explanatory.
> Ex.
> #define PTHREAD_MUTEX_RECURSIVE 0
> #define PTHREAD_MUTEX_ERRORCHECK 1
> #define PTHREAD_MUTEX_NORMAL 2
> #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_RECURSIVE

Good suggestion, next time I'm tweaking the file I may just do that. OR:
you could submit a patch:}.

Rob

--=20
---
GPG key available at: http://users.bigpond.net.au/robertc/keys.txt.
---

--=-J+I8g9dC6fm50VNWTHyj
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA9744TI5+kQ8LJcoIRAgH6AJ4w1qXtngL2fyZq93qGAmRRgN3XjgCfWRqw
wpqFL0krwlYLbqvUk1VqFGw=
=VQfm
-----END PGP SIGNATURE-----

--=-J+I8g9dC6fm50VNWTHyj--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019