Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Subject: Re: pthread_mutex_trylock does not lock
From: Robert Collins <rbcollins@cygwin.com>
To: Christophe Galerne <christophegalerne@earthlink.net>
Cc: cygwin <cygwin@cygwin.com>
In-Reply-To: <3DEE9416.8060605@earthlink.net>
References: <3DEE74C3.1070208@earthlink.net>
	<1039074697.8812.24.camel@lifelesswks>  <3DEE9416.8060605@earthlink.net>
Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature";
	boundary="=-J+I8g9dC6fm50VNWTHyj"
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--

