![]() |
MySQL
8.0.23
Source Code Documentation
|
#include "sync0rw.h"
#include <my_sys.h>
#include <sys/types.h>
#include "ha_prototypes.h"
#include "mem0mem.h"
#include "os0event.h"
#include "os0thread.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "sync0debug.h"
Macros | |
#define | rw_lock_x_lock_wait(L, P, T, F, O) rw_lock_x_lock_wait_func(L, P, T, F, O) |
Typedefs | |
typedef std::vector< rw_lock_debug_t * > | Infos |
For collecting the debug information for a thread's rw-lock. More... | |
Functions | |
static rw_lock_debug_t * | rw_lock_debug_create (void) |
Creates a debug info struct. More... | |
static void | rw_lock_debug_free (rw_lock_debug_t *info) |
Frees a debug info struct. More... | |
void | rw_lock_create_func (rw_lock_t *lock, latch_level_t level, const char *cmutex_name, const char *cfile_name, ulint cline) |
Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). More... | |
void | rw_lock_free_func (rw_lock_t *lock) |
Calling this function is obligatory only if the memory buffer containing the rw-lock is freed. More... | |
void | rw_lock_s_lock_spin (rw_lock_t *lock, ulint pass, const char *file_name, ulint line) |
Lock an rw-lock in shared mode for the current thread. More... | |
void | rw_lock_x_lock_move_ownership (rw_lock_t *lock) |
This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to the current thread. More... | |
UNIV_INLINE void | rw_lock_x_lock_wait_func (rw_lock_t *lock, ulint pass, lint threshold, const char *file_name, ulint line) |
Function for the next writer to call. More... | |
UNIV_INLINE bool | rw_lock_x_lock_low (rw_lock_t *lock, ulint pass, const char *file_name, ulint line) |
Low-level function for acquiring an exclusive lock. More... | |
bool | rw_lock_sx_lock_low (rw_lock_t *lock, ulint pass, const char *file_name, ulint line) |
Low-level function for acquiring an sx lock. More... | |
void | rw_lock_x_lock_func (rw_lock_t *lock, ulint pass, const char *file_name, ulint line) |
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread. More... | |
void | rw_lock_sx_lock_func (rw_lock_t *lock, ulint pass, const char *file_name, ulint line) |
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the current thread. More... | |
bool | rw_lock_validate (const rw_lock_t *lock) |
Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive locks. More... | |
bool | rw_lock_is_locked (rw_lock_t *lock, ulint lock_type) |
Checks if somebody has locked the rw-lock in the specified mode. More... | |
void | rw_lock_add_debug_info (rw_lock_t *lock, ulint pass, ulint lock_type, const char *file_name, ulint line) |
Inserts the debug information for an rw-lock. More... | |
void | rw_lock_remove_debug_info (rw_lock_t *lock, ulint pass, ulint lock_type) |
Removes a debug information struct for an rw-lock. More... | |
ibool | rw_lock_own (rw_lock_t *lock, ulint lock_type) |
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. More... | |
static void | rw_lock_get_debug_info (const rw_lock_t *lock, Infos *infos) |
Get the thread debug info. More... | |
bool | rw_lock_own_flagged (const rw_lock_t *lock, rw_lock_flags_t flags) |
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. More... | |
void | rw_lock_list_print_info (FILE *file) |
Prints debug info of currently locked rw-locks. More... | |
void | rw_lock_debug_print (FILE *f, const rw_lock_debug_t *info) |
Prints info of a debug struct. More... | |
Variables | |
rw_lock_stats_t | rw_lock_stats |
Counters for RW locks. More... | |
rw_lock_list_t | rw_lock_list |
ib_mutex_t | rw_lock_list_mutex |
The read-write lock (for thread synchronization)
Created 9/11/1995 Heikki Tuuri
#define rw_lock_x_lock_wait | ( | L, | |
P, | |||
T, | |||
F, | |||
O | |||
) | rw_lock_x_lock_wait_func(L, P, T, F, O) |
typedef std::vector<rw_lock_debug_t *> Infos |
For collecting the debug information for a thread's rw-lock.
void rw_lock_add_debug_info | ( | rw_lock_t * | lock, |
ulint | pass, | ||
ulint | lock_type, | ||
const char * | file_name, | ||
ulint | line | ||
) |
Inserts the debug information for an rw-lock.
lock | in: rw-lock |
pass | in: pass value |
lock_type | in: lock type |
file_name | in: file where requested |
line | in: line where requested |
void rw_lock_create_func | ( | rw_lock_t * | lock, |
latch_level_t | level, | ||
const char * | cmutex_name, | ||
const char * | cfile_name, | ||
ulint | cline | ||
) |
Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned).
The rw-lock is initialized to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free is necessary only if the memory block containing it is freed.
lock | in: pointer to memory |
level | in: level |
cmutex_name | in: rw-lock name |
cfile_name | in: file name where created |
cline | in: file line where created |
|
static |
Creates a debug info struct.
|
static |
Frees a debug info struct.
void rw_lock_debug_print | ( | FILE * | f, |
const rw_lock_debug_t * | info | ||
) |
Prints info of a debug struct.
[in] | f | Output stream |
[in] | info | Debug struct |
void rw_lock_free_func | ( | rw_lock_t * | lock | ) |
Calling this function is obligatory only if the memory buffer containing the rw-lock is freed.
Removes an rw-lock object from the global list. The rw-lock is checked to be in the non-locked state.
lock | in/out: rw-lock |
Get the thread debug info.
[in] | infos | The rw-lock mode owned by the threads |
[in] | lock | rw-lock to check |
Checks if somebody has locked the rw-lock in the specified mode.
lock | in: rw-lock |
lock_type | in: lock type: RW_LOCK_S, RW_LOCK_X or RW_LOCK_SX |
void rw_lock_list_print_info | ( | FILE * | file | ) |
Prints debug info of currently locked rw-locks.
in: file where to print
file | in: file where to print |
ibool rw_lock_own | ( | rw_lock_t * | lock, |
ulint | lock_type | ||
) |
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.
lock | in: rw-lock |
lock_type | in: lock type: RW_LOCK_S, RW_LOCK_X |
bool rw_lock_own_flagged | ( | const rw_lock_t * | lock, |
rw_lock_flags_t | flags | ||
) |
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.
[in] | lock | rw-lock |
[in] | flags | specify lock types with OR of the rw_lock_flag_t values |
void rw_lock_remove_debug_info | ( | rw_lock_t * | lock, |
ulint | pass, | ||
ulint | lock_type | ||
) |
Removes a debug information struct for an rw-lock.
lock | in: rw-lock |
pass | in: pass value |
lock_type | in: lock type |
void rw_lock_s_lock_spin | ( | rw_lock_t * | lock, |
ulint | pass, | ||
const char * | file_name, | ||
ulint | line | ||
) |
Lock an rw-lock in shared mode for the current thread.
If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock, before suspending the thread.
lock | in: pointer to rw-lock |
pass | in: pass value; != 0, if the lock will be passed to another thread to unlock |
file_name | in: file name where lock requested |
line | in: line where requested |
void rw_lock_sx_lock_func | ( | rw_lock_t * | lock, |
ulint | pass, | ||
const char * | file_name, | ||
ulint | line | ||
) |
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the current thread.
If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting for the lock, before suspending the thread. If the same thread has an x-lock on the rw-lock, locking succeed, with the following exception: if pass != 0, only a single sx-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed!
lock | in: pointer to rw-lock |
pass | in: pass value; != 0, if the lock will be passed to another thread to unlock |
file_name | in: file name where lock requested |
line | in: line where requested |
Low-level function for acquiring an sx lock.
lock | in: pointer to rw-lock |
pass | in: pass value; != 0, if the lock will be passed to another thread to unlock |
file_name | in: file name where lock requested |
line | in: line where requested |
Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive locks.
lock | in: rw-lock |
void rw_lock_x_lock_func | ( | rw_lock_t * | lock, |
ulint | pass, | ||
const char * | file_name, | ||
ulint | line | ||
) |
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread.
If the rw-lock is locked in shared or exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock before suspending the thread. If the same thread has an x-lock on the rw-lock, locking succeed, with the following exception: if pass != 0, only a single x-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed!
lock | in: pointer to rw-lock |
pass | in: pass value; != 0, if the lock will be passed to another thread to unlock |
file_name | in: file name where lock requested |
line | in: line where requested |
UNIV_INLINE bool rw_lock_x_lock_low | ( | rw_lock_t * | lock, |
ulint | pass, | ||
const char * | file_name, | ||
ulint | line | ||
) |
Low-level function for acquiring an exclusive lock.
lock | in: pointer to rw-lock |
pass | in: pass value; != 0, if the lock will be passed to another thread to unlock |
file_name | in: file name where lock requested |
line | in: line where requested |
void rw_lock_x_lock_move_ownership | ( | rw_lock_t * | lock | ) |
This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to the current thread.
The x-latch was set by the buffer read operation and it protected the buffer frame while the read was done. The ownership is moved because we want that the current thread is able to acquire a second x-latch which is stored in an mtr. This, in turn, is needed to pass the debug checks of index page operations.
lock | in: lock which was x-locked in the buffer read |
UNIV_INLINE void rw_lock_x_lock_wait_func | ( | rw_lock_t * | lock, |
ulint | pass, | ||
lint | threshold, | ||
const char * | file_name, | ||
ulint | line | ||
) |
Function for the next writer to call.
Waits for readers to exit. The caller must have already decremented lock_word by X_LOCK_DECR.
lock | in: pointer to rw-lock |
pass | in: pass value; != 0, if the lock will be passed to another thread to unlock |
threshold | in: threshold to wait for |
file_name | in: file name where lock requested |
line | in: line where requested |
rw_lock_list_t rw_lock_list |
ib_mutex_t rw_lock_list_mutex |
rw_lock_stats_t rw_lock_stats |
Counters for RW locks.