This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Re: Patch: POSIX update for glibc 2.1
- To: tromey@cygnus.com
- Subject: Re: Patch: POSIX update for glibc 2.1
- From: Matt Welsh <mdw@cs.berkeley.edu>
- Date: Wed, 08 Sep 1999 00:22:16 -0700
- cc: Java Patch List <java-patches@sourceware.cygnus.com>
- Reply-To: Matt Welsh <mdw@cs.berkeley.edu>
Tom Tromey <tromey@cygnus.com> writes:
> #elif defined (PTHREAD_MUTEX_HAVE___M_COUNT)
> - int r = pmu->__m_count == 1;
> + int r = (pthread_t) pmu->__m_owner == pthread_self ();
I'm not sure this is quite right, since __m_owner will still be
pthread_self() if the mutex was unlocked before entering this
routine.
The correct check is
((pmu->__m_owner == pthread_self()) && (pmu->__m_count == 0))
which means that PthreadCheckMonitor was the first to lock the mutex.
Still, this is ugly and possibly slow, depending on how pthread_self()
is implemented. In the long run it's probably best to have our own
"fast check" for a mutex being locked or not.
Matt Welsh