#include "univ.i"
#include "sync0types.h"
#include "ut0lst.h"
#include "ut0mem.h"
#include "os0thread.h"
#include "os0sync.h"
#include "sync0arr.h"
Go to the source code of this file.
Classes | |
struct | mutex_struct |
Macros | |
#define | sync0sync_h |
#define | mutex_create(K, M, level) mutex_create_func((M), __FILE__, __LINE__) |
#define | mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__) |
#define | mutex_enter_nowait(M) mutex_enter_nowait_func((M), __FILE__, __LINE__) |
#define | mutex_exit(M) mutex_exit_func(M) |
#define | mutex_free(M) mutex_free_func(M) |
#define | mutex_enter_fast(M) mutex_enter_func((M), __FILE__, __LINE__) |
#define | SYNC_USER_TRX_LOCK 9999 |
#define | SYNC_NO_ORDER_CHECK |
#define | SYNC_LEVEL_VARYING |
#define | SYNC_TRX_I_S_RWLOCK |
#define | SYNC_TRX_I_S_LAST_READ |
#define | SYNC_FILE_FORMAT_TAG |
#define | SYNC_DICT_OPERATION |
#define | SYNC_DICT 1000 |
#define | SYNC_DICT_AUTOINC_MUTEX 999 |
#define | SYNC_DICT_HEADER 995 |
#define | SYNC_IBUF_HEADER 914 |
#define | SYNC_IBUF_PESS_INSERT_MUTEX 912 |
#define | SYNC_IBUF_MUTEX |
#define | SYNC_INDEX_TREE 900 |
#define | SYNC_TREE_NODE_NEW 892 |
#define | SYNC_TREE_NODE_FROM_HASH 891 |
#define | SYNC_TREE_NODE 890 |
#define | SYNC_PURGE_SYS 810 |
#define | SYNC_PURGE_LATCH 800 |
#define | SYNC_TRX_UNDO 700 |
#define | SYNC_RSEG 600 |
#define | SYNC_RSEG_HEADER_NEW 591 |
#define | SYNC_RSEG_HEADER 590 |
#define | SYNC_TRX_UNDO_PAGE 570 |
#define | SYNC_EXTERN_STORAGE 500 |
#define | SYNC_FSP 400 |
#define | SYNC_FSP_PAGE 395 |
#define | SYNC_IBUF_BITMAP_MUTEX 351 |
#define | SYNC_IBUF_BITMAP 350 |
#define | SYNC_KERNEL 300 |
#define | SYNC_REC_LOCK 299 |
#define | SYNC_TRX_LOCK_HEAP 298 |
#define | SYNC_TRX_SYS_HEADER 290 |
#define | SYNC_LOG 170 |
#define | SYNC_LOG_FLUSH_ORDER 147 |
#define | SYNC_RECV 168 |
#define | SYNC_WORK_QUEUE 162 |
#define | SYNC_SEARCH_SYS_CONF 161 /* for assigning btr_search_enabled */ |
#define | SYNC_SEARCH_SYS |
#define | SYNC_COMMIT_ID_LOCK 159 |
#define | SYNC_BUF_POOL 150 /* Buffer pool mutex */ |
#define | SYNC_BUF_BLOCK 146 /* Block mutex */ |
#define | SYNC_BUF_FLUSH_LIST 145 /* Buffer flush list mutex */ |
#define | SYNC_DOUBLEWRITE 140 |
#define | SYNC_ANY_LATCH 135 |
#define | SYNC_THR_LOCAL 133 |
#define | SYNC_MEM_HASH 131 |
#define | SYNC_MEM_POOL 130 |
#define | RW_LOCK_NOT_LOCKED 350 |
#define | RW_LOCK_EX 351 |
#define | RW_LOCK_EXCLUSIVE 351 |
#define | RW_LOCK_SHARED 352 |
#define | RW_LOCK_WAIT_EX 353 |
#define | SYNC_MUTEX 354 |
#define | SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds |
Typedefs | |
typedef byte | lock_word_t |
Functions | |
UNIV_INTERN void | sync_init (void) |
UNIV_INTERN void | sync_close (void) |
UNIV_INTERN void | mutex_create_func (mutex_t *mutex, const char *cfile_name, ulint cline) |
UNIV_INTERN void | mutex_free_func (mutex_t *mutex) |
UNIV_INLINE void | mutex_enter_func (mutex_t *mutex, const char *file_name, ulint line) |
UNIV_INTERN ulint | mutex_enter_nowait_func (mutex_t *mutex, const char *file_name, ulint line) |
UNIV_INLINE void | mutex_exit_func (mutex_t *mutex) |
UNIV_INTERN void | sync_print_wait_info (FILE *file) |
UNIV_INTERN void | sync_print (FILE *file) |
UNIV_INLINE lock_word_t | mutex_get_lock_word (const mutex_t *mutex) |
typedef | UT_LIST_BASE_NODE_T (mutex_t) ut_list_base_node_t |
Variables | |
sync_array_t * | sync_primary_wait_array |
ib_int64_t | mutex_exit_count |
ibool | sync_initialized |
ut_list_base_node_t | mutex_list |
mutex_t | mutex_list_mutex |
Mutex, the basic synchronization primitive
Created 9/5/1995 Heikki Tuuri
Definition in file sync0sync.h.
#define mutex_enter_fast | ( | M | ) | mutex_enter_func((M), __FILE__, __LINE__) |
NOTE! The following macro should be used in mutex locking, not the corresponding function.
Definition at line 243 of file sync0sync.h.
#define SYNC_DICT_OPERATION |
Definition at line 615 of file sync0sync.h.
#define SYNC_FILE_FORMAT_TAG |
Definition at line 614 of file sync0sync.h.
#define SYNC_IBUF_MUTEX |
Definition at line 621 of file sync0sync.h.
#define SYNC_LEVEL_VARYING |
Definition at line 611 of file sync0sync.h.
#define SYNC_NO_ORDER_CHECK |
Definition at line 610 of file sync0sync.h.
#define SYNC_SEARCH_SYS |
Definition at line 654 of file sync0sync.h.
#define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds |
Constant determining how long spin wait is continued before suspending the thread. A value 600 rounds on a 1995 100 MHz Pentium seems to correspond to 20 microseconds.
Definition at line 735 of file sync0sync.h.
Referenced by rw_lock_x_lock_func().
#define SYNC_TRX_I_S_LAST_READ |
Definition at line 613 of file sync0sync.h.
#define SYNC_TRX_I_S_RWLOCK |
Definition at line 612 of file sync0sync.h.
UNIV_INTERN void mutex_create_func | ( | mutex_t * | mutex, |
const char * | cfile_name, | ||
ulint | cline | ||
) |
Creates, or rather, initializes a mutex object in a specified memory location (which must be appropriately aligned). The mutex is initialized in the reset state. Explicit freeing of the mutex with mutex_free is necessary only if the memory block containing it is freed. in: file line where created
Creates, or rather, initializes a mutex object in a specified memory location (which must be appropriately aligned). The mutex is initialized in the reset state. Explicit freeing of the mutex with mutex_free is necessary only if the memory block containing it is freed.
mutex | in: pointer to memory |
cfile_name | in: file name where created |
cline | in: file line where created |
Definition at line 249 of file sync0sync.cc.
References mutex_struct::cfile_name, mutex_struct::cline, mutex_struct::count_os_wait, mutex_struct::event, mutex_struct::lock_word, mutex_create_func(), mutex_list, mutex_list_mutex, os_event_create(), mutex_struct::os_fast_mutex, os_fast_mutex_init(), ut_ad, UT_LIST_ADD_FIRST, UT_LIST_GET_FIRST, and UT_LIST_GET_LEN.
Referenced by mutex_create_func().
UNIV_INLINE void mutex_enter_func | ( | mutex_t * | mutex, |
const char * | file_name, | ||
ulint | line | ||
) |
NOTE! Use the corresponding macro in the header file, not this function directly. Locks a mutex for the current thread. If the mutex is reserved the function spins a preset time (controlled by SYNC_SPIN_ROUNDS) waiting for the mutex before suspending the thread. in: line where locked
mutex | in: pointer to mutex |
file_name | in: file name where locked |
UNIV_INTERN ulint mutex_enter_nowait_func | ( | mutex_t * | mutex, |
const char * | , | ||
ulint | |||
) |
NOTE! Use the corresponding macro in the header file, not this function directly. Tries to lock the mutex for the current thread. If the lock is not acquired immediately, returns with return value 1.
NOTE! Use the corresponding macro in the header file, not this function directly. Tries to lock the mutex for the current thread. If the lock is not acquired immediately, returns with return value 1.
mutex | in: pointer to mutex |
Definition at line 381 of file sync0sync.cc.
References mutex_enter_nowait_func(), os_thread_get_curr_id(), ut_ad, and ut_d.
Referenced by mutex_enter_nowait_func().
UNIV_INLINE void mutex_exit_func | ( | mutex_t * | mutex | ) |
NOTE! Use the corresponding macro mutex_exit(), not directly this function! Unlocks a mutex owned by the current thread. in: pointer to mutex
UNIV_INTERN void mutex_free_func | ( | mutex_t * | mutex | ) |
NOTE! Use the corresponding macro mutex_free(), not directly this function! Calling this function is obligatory only if the memory buffer containing the mutex is freed. Removes a mutex object from the mutex list. The mutex is checked to be in the reset state. in: mutex
NOTE! Use the corresponding macro mutex_free(), not directly this function! Calling this function is obligatory only if the memory buffer containing the mutex is freed. Removes a mutex object from the mutex list. The mutex is checked to be in the reset state.
mutex | in: mutex |
Definition at line 322 of file sync0sync.cc.
References mutex_struct::event, mutex_free_func(), mutex_get_lock_word(), mutex_list, mutex_list_mutex, os_event_free(), mutex_struct::os_fast_mutex, os_fast_mutex_free(), ut_a, ut_ad, UT_LIST_GET_FIRST, UT_LIST_GET_LEN, UT_LIST_GET_NEXT, UT_LIST_GET_PREV, and UT_LIST_REMOVE.
Referenced by mutex_free_func().
UNIV_INLINE lock_word_t mutex_get_lock_word | ( | const mutex_t * | mutex | ) |
NOT to be used outside this module except in debugging! Gets the value of the lock word. in: mutex
Referenced by mutex_free_func().
UNIV_INTERN void sync_close | ( | void | ) |
Frees the resources in synchronization data structures.
Frees the resources in InnoDB's own synchronization data structures. Use os_sync_free() after calling this.
Definition at line 1462 of file sync0sync.cc.
References mutex_list, mutex_list_mutex, sync_array_free(), sync_close(), sync_initialized, sync_primary_wait_array, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.
Referenced by innobase_shutdown_for_mysql(), and sync_close().
UNIV_INTERN void sync_init | ( | void | ) |
Initializes the synchronization data structures.
Definition at line 1403 of file sync0sync.cc.
References sync_thread_struct::levels, mutex_list, mutex_list_mutex, os_event_create(), sync_array_create(), SYNC_ARRAY_OS_MUTEX, sync_init(), sync_initialized, sync_primary_wait_array, ut_a, UT_LIST_INIT, and ut_malloc().
Referenced by srv_general_init(), and sync_init().
UNIV_INTERN void sync_print | ( | FILE * | file | ) |
Prints info of the sync system. in: file where to print
Prints info of the sync system.
file | in: file where to print |
Definition at line 1536 of file sync0sync.cc.
References sync_array_print_info(), sync_primary_wait_array, sync_print(), and sync_print_wait_info().
Referenced by srv_printf_innodb_monitor(), and sync_print().
UNIV_INTERN void sync_print_wait_info | ( | FILE * | file | ) |
Prints wait info of the sync system. in: file where to print
Prints wait info of the sync system.
file | in: file where to print |
Definition at line 1497 of file sync0sync.cc.
References mutex_exit_count, rw_s_exit_count, rw_s_os_wait_count, rw_s_spin_round_count, rw_s_spin_wait_count, rw_x_exit_count, rw_x_os_wait_count, rw_x_spin_round_count, rw_x_spin_wait_count, and sync_print_wait_info().
Referenced by sync_print(), and sync_print_wait_info().
typedef UT_LIST_BASE_NODE_T | ( | mutex_t | ) |
Global list of database mutexes (not OS mutexes) created.
Referenced by lock_move_reorganize_page().
ib_int64_t mutex_exit_count |
The number of mutex_exit calls. Intended for performance monitoring.
The number of mutex_exit() calls. Intended for performance monitoring.
Definition at line 182 of file sync0sync.cc.
Referenced by sync_print_wait_info().
ut_list_base_node_t mutex_list |
Global list of database mutexes (not OS mutexes) created.
Definition at line 211 of file sync0sync.cc.
Referenced by innodb_mutex_show_status(), mutex_create_func(), mutex_free_func(), sync_close(), and sync_init().
mutex_t mutex_list_mutex |
Mutex protecting the mutex_list variable
Definition at line 214 of file sync0sync.cc.
Referenced by innodb_mutex_show_status(), mutex_create_func(), mutex_free_func(), sync_close(), and sync_init().
ibool sync_initialized |
This variable is set to TRUE when sync_init is called
Definition at line 189 of file sync0sync.cc.
Referenced by sync_close(), and sync_init().
sync_array_t* sync_primary_wait_array |
The global array of wait cells for implementation of the databases own mutexes and read-write locks.
The global array of wait cells for implementation of the database's own mutexes and read-write locks
Definition at line 186 of file sync0sync.cc.
Referenced by rw_lock_x_lock_func(), sync_arr_wake_threads_if_sema_free(), sync_array_print_long_waits(), sync_close(), sync_init(), and sync_print().