drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
sync0sync.h File Reference
#include "univ.i"
#include "sync0types.h"
#include "ut0lst.h"
#include "ut0mem.h"
#include "os0thread.h"
#include "os0sync.h"
#include "sync0arr.h"
Include dependency graph for sync0sync.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mutex_struct

Macros

#define sync0sync_h
#define mutex_create(K, M, level)
#define mutex_enter(M)
#define mutex_enter_nowait(M)
#define mutex_exit(M)
#define mutex_free(M)
#define mutex_enter_fast(M)
#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_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_PURGE_QUEUE   200
#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

Detailed Description

Mutex, the basic synchronization primitive

Created 9/5/1995 Heikki Tuuri

Definition in file sync0sync.h.

Macro Definition Documentation

◆ mutex_create

#define mutex_create ( K,
M,
level )
Value:
mutex_create_func((M), __FILE__, __LINE__)
UNIV_INTERN void mutex_create_func(mutex_t *mutex, const char *cfile_name, ulint cline)
Definition sync0sync.cc:272

Definition at line 192 of file sync0sync.h.

◆ mutex_enter

#define mutex_enter ( M)
Value:
mutex_enter_func((M), __FILE__, __LINE__)
UNIV_INLINE void mutex_enter_func(mutex_t *mutex, const char *file_name, ulint line)

Definition at line 196 of file sync0sync.h.

◆ mutex_enter_fast

#define mutex_enter_fast ( M)
Value:
mutex_enter_func((M), __FILE__, __LINE__)

NOTE! The following macro should be used in mutex locking, not the corresponding function.

Definition at line 242 of file sync0sync.h.

◆ mutex_enter_nowait

#define mutex_enter_nowait ( M)
Value:
mutex_enter_nowait_func((M), __FILE__, __LINE__)
UNIV_INTERN ulint mutex_enter_nowait_func(mutex_t *mutex, const char *file_name, ulint line)
Definition sync0sync.cc:404

Definition at line 198 of file sync0sync.h.

◆ mutex_exit

#define mutex_exit ( M)
Value:
UNIV_INLINE void mutex_exit_func(mutex_t *mutex)

Definition at line 201 of file sync0sync.h.

◆ mutex_free

#define mutex_free ( M)
Value:
UNIV_INTERN void mutex_free_func(mutex_t *mutex)
Definition sync0sync.cc:345

Definition at line 203 of file sync0sync.h.

◆ RW_LOCK_EX

#define RW_LOCK_EX   351

Definition at line 666 of file sync0sync.h.

◆ RW_LOCK_EXCLUSIVE

#define RW_LOCK_EXCLUSIVE   351

Definition at line 667 of file sync0sync.h.

◆ RW_LOCK_NOT_LOCKED

#define RW_LOCK_NOT_LOCKED   350

Definition at line 665 of file sync0sync.h.

◆ RW_LOCK_SHARED

#define RW_LOCK_SHARED   352

Definition at line 668 of file sync0sync.h.

◆ RW_LOCK_WAIT_EX

#define RW_LOCK_WAIT_EX   353

Definition at line 669 of file sync0sync.h.

◆ sync0sync_h

#define sync0sync_h

Definition at line 35 of file sync0sync.h.

◆ SYNC_ANY_LATCH

#define SYNC_ANY_LATCH   135

Definition at line 659 of file sync0sync.h.

◆ SYNC_BUF_BLOCK

#define SYNC_BUF_BLOCK   146 /* Block mutex */

Definition at line 656 of file sync0sync.h.

◆ SYNC_BUF_FLUSH_LIST

#define SYNC_BUF_FLUSH_LIST   145 /* Buffer flush list mutex */

Definition at line 657 of file sync0sync.h.

◆ SYNC_BUF_POOL

#define SYNC_BUF_POOL   150 /* Buffer pool mutex */

Definition at line 655 of file sync0sync.h.

◆ SYNC_COMMIT_ID_LOCK

#define SYNC_COMMIT_ID_LOCK   159

Definition at line 654 of file sync0sync.h.

◆ SYNC_DICT

#define SYNC_DICT   1000

Definition at line 615 of file sync0sync.h.

◆ SYNC_DICT_AUTOINC_MUTEX

#define SYNC_DICT_AUTOINC_MUTEX   999

Definition at line 616 of file sync0sync.h.

◆ SYNC_DICT_HEADER

#define SYNC_DICT_HEADER   995

Definition at line 617 of file sync0sync.h.

◆ SYNC_DICT_OPERATION

#define SYNC_DICT_OPERATION
Value:
1001 /* table create, drop, etc. reserve
this in X-mode; implicit or backround
operations purge, rollback, foreign
key checks reserve this in S-mode */

Definition at line 614 of file sync0sync.h.

◆ SYNC_DOUBLEWRITE

#define SYNC_DOUBLEWRITE   140

Definition at line 658 of file sync0sync.h.

◆ SYNC_EXTERN_STORAGE

#define SYNC_EXTERN_STORAGE   500

Definition at line 632 of file sync0sync.h.

◆ SYNC_FILE_FORMAT_TAG

#define SYNC_FILE_FORMAT_TAG
Value:
1200 /* Used to serialize access to the
file format tag */

Definition at line 613 of file sync0sync.h.

◆ SYNC_FSP

#define SYNC_FSP   400

Definition at line 633 of file sync0sync.h.

◆ SYNC_FSP_PAGE

#define SYNC_FSP_PAGE   395

Definition at line 634 of file sync0sync.h.

◆ SYNC_IBUF_BITMAP

#define SYNC_IBUF_BITMAP   350

Definition at line 639 of file sync0sync.h.

◆ SYNC_IBUF_BITMAP_MUTEX

#define SYNC_IBUF_BITMAP_MUTEX   351

Definition at line 638 of file sync0sync.h.

◆ SYNC_IBUF_HEADER

#define SYNC_IBUF_HEADER   914

Definition at line 618 of file sync0sync.h.

◆ SYNC_IBUF_MUTEX

#define SYNC_IBUF_MUTEX
Value:
910 /* ibuf mutex is really below
SYNC_FSP_PAGE: we assign a value this
high only to make the program to pass
the debug checks */

Definition at line 620 of file sync0sync.h.

◆ SYNC_IBUF_PESS_INSERT_MUTEX

#define SYNC_IBUF_PESS_INSERT_MUTEX   912

Definition at line 619 of file sync0sync.h.

◆ SYNC_INDEX_TREE

#define SYNC_INDEX_TREE   900

Definition at line 622 of file sync0sync.h.

◆ SYNC_KERNEL

#define SYNC_KERNEL   300

Definition at line 643 of file sync0sync.h.

◆ SYNC_LEVEL_VARYING

#define SYNC_LEVEL_VARYING
Value:
2000 /* Level is varying. Only used with
buffer pool page locks, which do not
have a fixed level, but instead have
their level set after the page is
locked; see e.g.
ibuf_bitmap_get_map_page(). */

Definition at line 610 of file sync0sync.h.

◆ SYNC_LOG

#define SYNC_LOG   170

Definition at line 648 of file sync0sync.h.

◆ SYNC_LOG_FLUSH_ORDER

#define SYNC_LOG_FLUSH_ORDER   147

Definition at line 649 of file sync0sync.h.

◆ SYNC_MEM_HASH

#define SYNC_MEM_HASH   131

Definition at line 661 of file sync0sync.h.

◆ SYNC_MEM_POOL

#define SYNC_MEM_POOL   130

Definition at line 662 of file sync0sync.h.

◆ SYNC_MUTEX

#define SYNC_MUTEX   354

Definition at line 670 of file sync0sync.h.

◆ SYNC_NO_ORDER_CHECK

#define SYNC_NO_ORDER_CHECK
Value:
3000 /* this can be used to suppress
latching order checking */

Definition at line 609 of file sync0sync.h.

◆ SYNC_PURGE_LATCH

#define SYNC_PURGE_LATCH   800

Definition at line 626 of file sync0sync.h.

◆ SYNC_PURGE_QUEUE

#define SYNC_PURGE_QUEUE   200

Definition at line 647 of file sync0sync.h.

◆ SYNC_REC_LOCK

#define SYNC_REC_LOCK   299

Definition at line 644 of file sync0sync.h.

◆ SYNC_RECV

#define SYNC_RECV   168

Definition at line 650 of file sync0sync.h.

◆ SYNC_RSEG

#define SYNC_RSEG   600

Definition at line 628 of file sync0sync.h.

◆ SYNC_RSEG_HEADER

#define SYNC_RSEG_HEADER   590

Definition at line 630 of file sync0sync.h.

◆ SYNC_RSEG_HEADER_NEW

#define SYNC_RSEG_HEADER_NEW   591

Definition at line 629 of file sync0sync.h.

◆ SYNC_SEARCH_SYS

#define SYNC_SEARCH_SYS
Value:
160 /* NOTE that if we have a memory
heap that can be extended to the
buffer pool, its logical level is
SYNC_SEARCH_SYS, as memory allocation
can call routines there! Otherwise
the level is SYNC_MEM_HASH. */

Definition at line 653 of file sync0sync.h.

◆ SYNC_SEARCH_SYS_CONF

#define SYNC_SEARCH_SYS_CONF   161 /* for assigning btr_search_enabled */

Definition at line 652 of file sync0sync.h.

◆ SYNC_SPIN_ROUNDS

#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 734 of file sync0sync.h.

◆ SYNC_THR_LOCAL

#define SYNC_THR_LOCAL   133

Definition at line 660 of file sync0sync.h.

◆ SYNC_TREE_NODE

#define SYNC_TREE_NODE   890

Definition at line 625 of file sync0sync.h.

◆ SYNC_TREE_NODE_FROM_HASH

#define SYNC_TREE_NODE_FROM_HASH   891

Definition at line 624 of file sync0sync.h.

◆ SYNC_TREE_NODE_NEW

#define SYNC_TREE_NODE_NEW   892

Definition at line 623 of file sync0sync.h.

◆ SYNC_TRX_I_S_LAST_READ

#define SYNC_TRX_I_S_LAST_READ
Value:
1900 /* Used for
trx_i_s_cache_t::last_read_mutex */

Definition at line 612 of file sync0sync.h.

◆ SYNC_TRX_I_S_RWLOCK

#define SYNC_TRX_I_S_RWLOCK
Value:
1910 /* Used for
trx_i_s_cache_t::rw_lock */

Definition at line 611 of file sync0sync.h.

◆ SYNC_TRX_LOCK_HEAP

#define SYNC_TRX_LOCK_HEAP   298

Definition at line 645 of file sync0sync.h.

◆ SYNC_TRX_SYS_HEADER

#define SYNC_TRX_SYS_HEADER   290

Definition at line 646 of file sync0sync.h.

◆ SYNC_TRX_UNDO

#define SYNC_TRX_UNDO   700

Definition at line 627 of file sync0sync.h.

◆ SYNC_TRX_UNDO_PAGE

#define SYNC_TRX_UNDO_PAGE   570

Definition at line 631 of file sync0sync.h.

◆ SYNC_USER_TRX_LOCK

#define SYNC_USER_TRX_LOCK   9999

Definition at line 608 of file sync0sync.h.

◆ SYNC_WORK_QUEUE

#define SYNC_WORK_QUEUE   162

Definition at line 651 of file sync0sync.h.

Typedef Documentation

◆ lock_word_t

typedef byte lock_word_t

Definition at line 53 of file sync0sync.h.

Function Documentation

◆ mutex_create_func()

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.

Parameters
mutexin: pointer to memory
cfile_namein: file name where created
clinein: file line where created

Definition at line 272 of file sync0sync.cc.

◆ mutex_enter_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

Parameters
mutexin: pointer to mutex
file_namein: file name where locked

◆ mutex_enter_nowait_func()

UNIV_INTERN ulint mutex_enter_nowait_func ( mutex_t * mutex,
const char * file_name,
ulint line )

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.

Returns
0 if succeed, 1 if not in: line where requested

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.

Returns
0 if succeed, 1 if not
Parameters
mutexin: pointer to mutex
file_namein: file name where mutex requested
linein: line where requested

Definition at line 404 of file sync0sync.cc.

◆ mutex_exit_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

◆ mutex_free_func()

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.

Parameters
mutexin: mutex

Definition at line 345 of file sync0sync.cc.

◆ mutex_get_lock_word()

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

◆ sync_close()

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 1512 of file sync0sync.cc.

◆ sync_init()

UNIV_INTERN void sync_init ( void )

Initializes the synchronization data structures.

Definition at line 1433 of file sync0sync.cc.

◆ sync_print()

UNIV_INTERN void sync_print ( FILE * file)

Prints info of the sync system. in: file where to print

Prints info of the sync system.

Parameters
filein: file where to print

Definition at line 1591 of file sync0sync.cc.

◆ sync_print_wait_info()

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.

Parameters
filein: file where to print

Definition at line 1552 of file sync0sync.cc.

◆ UT_LIST_BASE_NODE_T()

typedef UT_LIST_BASE_NODE_T ( mutex_t )

Global list of database mutexes (not OS mutexes) created.

Variable Documentation

◆ mutex_exit_count

ib_int64_t mutex_exit_count
extern

The number of mutex_exit calls. Intended for performance monitoring.

The number of mutex_exit() calls. Intended for performance monitoring.

Definition at line 185 of file sync0sync.cc.

◆ mutex_list

ut_list_base_node_t mutex_list
extern

Global list of database mutexes (not OS mutexes) created.

Definition at line 215 of file sync0sync.cc.

◆ mutex_list_mutex

mutex_t mutex_list_mutex
extern

Mutex protecting the mutex_list variable

Definition at line 218 of file sync0sync.cc.

◆ sync_initialized

ibool sync_initialized
extern

This variable is set to TRUE when sync_init is called

Definition at line 192 of file sync0sync.cc.

◆ sync_primary_wait_array

sync_array_t* sync_primary_wait_array
extern

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 189 of file sync0sync.cc.