diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-06-02 16:04:50 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-06-06 12:09:49 +0300 |
commit | bb1f41423a0c26313a7bd4b7704ccc4ad66e348a (patch) | |
tree | 99265299436d3be5e0e9342337d9b6becf9c53ef /storage | |
parent | 86927cc712b6589f15fb1306a5fc42bb705c5302 (diff) | |
download | mariadb-git-bb1f41423a0c26313a7bd4b7704ccc4ad66e348a.tar.gz |
InnoDB: Remove thread_mutex
Use my_atomic for updating os_thread_count.
os_thread_init(): Remove.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/include/os0thread.h | 8 | ||||
-rw-r--r-- | storage/innobase/include/sync0types.h | 1 | ||||
-rw-r--r-- | storage/innobase/os/os0thread.cc | 46 | ||||
-rw-r--r-- | storage/innobase/srv/srv0srv.cc | 1 | ||||
-rw-r--r-- | storage/innobase/sync/sync0debug.cc | 2 |
5 files changed, 6 insertions, 52 deletions
diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index 6f521b5a2ec..5c3a62e59a0 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -152,22 +152,14 @@ os_thread_sleep( ulint tm); /*!< in: time in microseconds */ /** -Initializes OS thread management data structures. */ -void -os_thread_init(); -/*============*/ - -/** Frees OS thread management data structures. */ void os_thread_free(); -/*============*/ /*****************************************************************//** Check if there are threads active. @return true if the thread count > 0. */ bool os_thread_active(); -/*==============*/ #endif diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h index cb1b36d5962..ec4503daa64 100644 --- a/storage/innobase/include/sync0types.h +++ b/storage/innobase/include/sync0types.h @@ -354,7 +354,6 @@ enum latch_id_t { LATCH_ID_EVENT_MANAGER, LATCH_ID_EVENT_MUTEX, LATCH_ID_SYNC_ARRAY_MUTEX, - LATCH_ID_THREAD_MUTEX, LATCH_ID_ZIP_PAD_MUTEX, LATCH_ID_OS_AIO_READ_MUTEX, LATCH_ID_OS_AIO_WRITE_MUTEX, diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index 72199b4cf0b..dc6e54f0162 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -31,14 +31,9 @@ Created 9/8/1995 Heikki Tuuri #include "os0event.h" #include <map> -/** Mutex that tracks the thread count. Used by innorwlocktest.cc -FIXME: the unit tests should use APIs */ -SysMutex thread_mutex; - /** Number of threads active. */ ulint os_thread_count; - /***************************************************************//** Compares two thread ids for equality. @return TRUE if equal */ @@ -127,11 +122,7 @@ os_thread_create_func( CloseHandle(handle); - mutex_enter(&thread_mutex); - - os_thread_count++; - - mutex_exit(&thread_mutex); + my_atomic_addlint(&os_thread_count, 1); return((os_thread_t)new_thread_id); #else /* _WIN32 else */ @@ -140,9 +131,7 @@ os_thread_create_func( pthread_attr_init(&attr); - mutex_enter(&thread_mutex); - ++os_thread_count; - mutex_exit(&thread_mutex); + my_atomic_addlint(&os_thread_count, 1); int ret = pthread_create(&new_thread_id, &attr, func, arg); @@ -197,16 +186,11 @@ os_thread_exit( pfs_delete_thread(); #endif - mutex_enter(&thread_mutex); - - os_thread_count--; + my_atomic_addlint(&os_thread_count, -1); #ifdef _WIN32 - mutex_exit(&thread_mutex); - ExitThread(0); #else - mutex_exit(&thread_mutex); if (detach) { pthread_detach(pthread_self()); } @@ -260,10 +244,6 @@ bool os_thread_active() /*==============*/ { - mutex_enter(&thread_mutex); - - bool active = (os_thread_count > 0); - /* All the threads have exited or are just exiting; NOTE that the threads may not have completed their exit yet. Should we use pthread_join() to make sure @@ -272,30 +252,16 @@ os_thread_active() os_thread_exit(). Now we just sleep 0.1 seconds and hope that is enough! */ - mutex_exit(&thread_mutex); - - return(active); -} - -/** -Initializes OS thread management data structures. */ -void -os_thread_init() -/*============*/ -{ - mutex_create(LATCH_ID_THREAD_MUTEX, &thread_mutex); + return(my_atomic_loadlint(&os_thread_count) > 0); } /** Frees OS thread management data structures. */ void os_thread_free() -/*============*/ { - if (os_thread_count != 0) { - ib::warn() << "Some (" << os_thread_count << ") threads are" + if (ulint count = my_atomic_loadlint(&os_thread_count)) { + ib::warn() << "Some (" << count << ") threads are" " still active"; } - - mutex_destroy(&thread_mutex); } diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 0a84afa5106..06ed058f18e 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1183,7 +1183,6 @@ srv_boot(void) srv_normalize_init_values(); sync_check_init(); - os_thread_init(); /* Reset the system variables in the recovery module. */ recv_sys_var_init(); trx_pool_init(); diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc index 4fff24a77f1..11743e14be2 100644 --- a/storage/innobase/sync/sync0debug.cc +++ b/storage/innobase/sync/sync0debug.cc @@ -1498,8 +1498,6 @@ sync_latch_meta_init() LATCH_ADD_MUTEX(SYNC_ARRAY_MUTEX, SYNC_NO_ORDER_CHECK, sync_array_mutex_key); - LATCH_ADD_MUTEX(THREAD_MUTEX, SYNC_NO_ORDER_CHECK, thread_mutex_key); - LATCH_ADD_MUTEX(ZIP_PAD_MUTEX, SYNC_NO_ORDER_CHECK, zip_pad_mutex_key); LATCH_ADD_MUTEX(OS_AIO_READ_MUTEX, SYNC_NO_ORDER_CHECK, |