[PATCH] Separate pthread fixes #1

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Separate pthread fixes #1

Dave Korn-6

  The attached patch separates out the uncontroversial change to the
__cygwin_lock* functions.

winsup/cygwin/ChangeLog

        * thread.cc (__cygwin_lock_lock):  Delete racy optimisation.
        (__cygwin_lock_unlock):  Likewise.

  OK?

    cheers,
      DaveK


Index: winsup/cygwin/thread.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/thread.cc,v
retrieving revision 1.215
diff -p -u -r1.215 thread.cc
--- winsup/cygwin/thread.cc 20 Jan 2009 12:40:31 -0000 1.215
+++ winsup/cygwin/thread.cc 3 Jun 2009 22:53:40 -0000
@@ -76,13 +76,8 @@ __cygwin_lock_fini (_LOCK_T *lock)
 extern "C" void
 __cygwin_lock_lock (_LOCK_T *lock)
 {
-  if (MT_INTERFACE->threadcount <= 1)
-    paranoid_printf ("threadcount %d.  not locking", MT_INTERFACE->threadcount);
-  else
-    {
-      paranoid_printf ("threadcount %d.  locking", MT_INTERFACE->threadcount);
-      pthread_mutex_lock ((pthread_mutex_t*) lock);
-    }
+  paranoid_printf ("threadcount %d.  locking", MT_INTERFACE->threadcount);
+  pthread_mutex_lock ((pthread_mutex_t*) lock);
 }
 
 extern "C" int
@@ -95,13 +90,8 @@ __cygwin_lock_trylock (_LOCK_T *lock)
 extern "C" void
 __cygwin_lock_unlock (_LOCK_T *lock)
 {
-  if (MT_INTERFACE->threadcount <= 1)
-    paranoid_printf ("threadcount %d.  not unlocking", MT_INTERFACE->threadcount);
-  else
-    {
-      pthread_mutex_unlock ((pthread_mutex_t*) lock);
-      paranoid_printf ("threadcount %d.  unlocked", MT_INTERFACE->threadcount);
-    }
+  pthread_mutex_unlock ((pthread_mutex_t*) lock);
+  paranoid_printf ("threadcount %d.  unlocked", MT_INTERFACE->threadcount);
 }
 
 static inline verifyable_object_state
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Separate pthread fixes #1

Christopher Faylor-8
On Thu, Jun 04, 2009 at 12:11:24AM +0100, Dave Korn wrote:

>
>  The attached patch separates out the uncontroversial change to the
>__cygwin_lock* functions.
>
>winsup/cygwin/ChangeLog
>
> * thread.cc (__cygwin_lock_lock):  Delete racy optimisation.
> (__cygwin_lock_unlock):  Likewise.
>
>  OK?

Yes.  Thanks.

FWIW, I have made this same change many times over the years but I was
always afraid of the performance hit so I've ended up reverting it.
Since you've demonstrated a real problem, performance concerns obviously
don't matter.

cgf