Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-06-27 23:16:48 +0400
committerChristopher Faylor <me@cgf.cx>2004-06-27 23:16:48 +0400
commit76a3f968a57035c29d74aeb79017d7ca9dd931d7 (patch)
tree7c11969a1b92a1a4717a0c9ad1e08d5cdae9dbc8 /winsup/cygwin/thread.cc
parentdce592cd8c5237dafba82dfcb1e97192250322b9 (diff)
* thread.cc (__cygwin_lock_lock): Don't bother locking when there is only one
known thread. (__cygwin_lock_unlock): Ditto for unlocking.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index a248b2604..7ba7399b6 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -79,7 +79,13 @@ __cygwin_lock_fini (_LOCK_T *lock)
extern "C" void
__cygwin_lock_lock (_LOCK_T *lock)
{
- pthread_mutex_lock ((pthread_mutex_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);
+ }
}
extern "C" int
@@ -92,7 +98,13 @@ __cygwin_lock_trylock (_LOCK_T *lock)
extern "C" void
__cygwin_lock_unlock (_LOCK_T *lock)
{
- pthread_mutex_unlock ((pthread_mutex_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);
+ }
}
inline LPCRITICAL_SECTION