diff options
author | Christopher Faylor <me@cgf.cx> | 2010-02-10 10:25:26 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2010-02-10 10:25:26 +0300 |
commit | 3700578ee8a4d7f56184a8a742067a2bdcb71360 (patch) | |
tree | ab029b2747c9159a4ecfd80131ae5391242d8a09 /winsup/cygwin/thread.h | |
parent | 161387a725ca8b931c1f68dd373f44e0bd0e7922 (diff) |
* dcrt0.cc (_dll_crt0): Set _main_tls as early as possible.
* thread.cc (pthread_mutex::can_be_unlocked): Remove check for
MUTEX_OWNER_ANONYMOUS since it is racy and unsafe.
(pthread::init_mainthread): Initialize thread directly from _my_tls.
(pthread::self): Ditto.
(pthread::get_tls_self_pointer): Delete.
(pthread_mutex::pthread_mutex): Use an event rather than a semaphore.
(pthread_mutex::lock): Rename from _<func>. Derive self directly.
(pthread_mutex::tryunlock): Ditto.
(pthread_mutex::destroy): Ditto.
(pthread_mutex::unlock): Ditto. Accommodate change from semaphore to event.
(pthread_mutex::_fixup_after_fork): Accommodate change from semaphore to event.
(pthread_mutex::init): Don't attempt to initialize a semaphore unless it is in
an initialized state. Do this check under mutex_initialization_lock.lock
* thread.h (fast_mutex::init): Use event rather than semaphore.
(fast_mutex::lock): Ditto.
(pthread_mutex::_lock): Delete.
(pthread_mutex::_unlock): Ditto.
(pthread_mutex::_trylock): Ditto.
(pthread_mutex::_destroy): Ditto.
(pthread_mutex::get_pthread_self): Ditto.
(pthread_mutex::get_tls_self_pointer): Ditto.
(pthread_mutex::lock): Un-inline.
(pthread_mutex::unlock): Ditto.
(pthread_mutex::trylock): Ditto.
(pthread_mutex::destroy): Ditto.
Diffstat (limited to 'winsup/cygwin/thread.h')
-rw-r--r-- | winsup/cygwin/thread.h | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index 04869f763..21d278dae 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -1,7 +1,7 @@ /* thread.h: Locking and threading module definitions Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, - 2008, 2009 Red Hat, Inc. + 2008, 2009, 2010 Red Hat, Inc. This file is part of Cygwin. @@ -57,10 +57,10 @@ public: bool init () { lock_counter = 0; - win32_obj_id = ::CreateSemaphore (&sec_none_nih, 0, LONG_MAX, NULL); + win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL); if (!win32_obj_id) { - debug_printf ("CreateSemaphore failed. %E"); + debug_printf ("CreateEvent failed. %E"); return false; } return true; @@ -75,7 +75,7 @@ public: void unlock () { if (InterlockedDecrement ((long *) &lock_counter)) - ::ReleaseSemaphore (win32_obj_id, 1, NULL); + ::SetEvent (win32_obj_id); } private: @@ -285,29 +285,10 @@ public: int type; int pshared; - pthread_t get_pthread_self () const - { - return PTHREAD_MUTEX_NORMAL == type ? MUTEX_OWNER_ANONYMOUS : - ::pthread_self (); - } - - int lock () - { - return _lock (get_pthread_self ()); - } - int trylock () - { - return _trylock (get_pthread_self ()); - } - int unlock () - { - return _unlock (get_pthread_self ()); - } - int destroy () - { - return _destroy (get_pthread_self ()); - } - + int lock (); + int trylock (); + int unlock (); + int destroy (); void set_owner (pthread_t self) { recursion_counter = 1; @@ -337,11 +318,6 @@ public: } private: - int _lock (pthread_t self); - int _trylock (pthread_t self); - int _unlock (pthread_t self); - int _destroy (pthread_t self); - void _fixup_after_fork (); static List<pthread_mutex> mutexes; @@ -446,7 +422,6 @@ private: void precreate (pthread_attr *); void postcreate (); bool create_cancel_event (); - static pthread *get_tls_self_pointer (); static void set_tls_self_pointer (pthread *); void cancel_self (); DWORD get_thread_id (); |