This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: POSIX update for glibc 2.1



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]