Commit bb1f4142 authored by Marko Mäkelä's avatar Marko Mäkelä

InnoDB: Remove thread_mutex

Use my_atomic for updating os_thread_count.

os_thread_init(): Remove.
parent 86927cc7
......@@ -151,23 +151,15 @@ 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
......@@ -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,
......
......@@ -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);
}
......@@ -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();
......
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment