MySQL 9.1.0
Source Code Documentation
|
The read-write lock (for thread synchronization) More...
#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"
Typedefs | |
typedef std::vector< const 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_id_t id, ut::Location clocation) |
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, ut::Location location) |
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... | |
static 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... | |
static void | rw_lock_x_lock_wait (rw_lock_t *lock, ulint pass, lint treshold, const char *file_name, ulint line) |
Function for the next writer to call. More... | |
static 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, ut::Location location) |
Low-level function for acquiring an sx lock. More... | |
void | rw_lock_x_lock_func (rw_lock_t *lock, ulint pass, ut::Location location) |
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, ut::Location location) |
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, ut::Location location) |
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... | |
bool | rw_lock_own (const 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_list_t | rw_lock_list {} |
The global list of rw-locks. More... | |
ib_mutex_t | rw_lock_list_mutex |
The read-write lock (for thread synchronization)
Created 9/11/1995 Heikki Tuuri
typedef std::vector<const 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, | ||
ut::Location | location | ||
) |
Inserts the debug information for an rw-lock.
[in] | lock | rw-lock |
[in] | pass | pass value |
[in] | lock_type | lock type |
[in] | location | location where requested |
void rw_lock_create_func | ( | rw_lock_t * | lock, |
latch_id_t | id, | ||
ut::Location | clocation | ||
) |
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.
[in] | lock | pointer to memory |
[in] | id | latch_id |
[in] | clocation | location 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 | file where to print |
file | in: file where to print |
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.
Note that the mode is checked exactly, so if the thread owns RW_LOCK_X only, the rw_lock_own(..,RW_LOCK_S) will return false.
[in] | lock | the rw-lock |
[in] | lock_type | The exact lock type to check: RW_LOCK_S, RW_LOCK_SX or 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 |
Removes a debug information struct for an rw-lock.
in: lock type
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, | ||
ut::Location | location | ||
) |
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.
[in] | lock | pointer to rw-lock |
[in] | pass | pass value; !=0, if the lock will be passed to another thread to unlock |
[in] | location | location where requested |
void rw_lock_sx_lock_func | ( | rw_lock_t * | lock, |
ulint | pass, | ||
ut::Location | location | ||
) |
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!
[in] | lock | pointer to rw-lock |
[in] | pass | pass value; != 0, if the lock will be passed to another thread to unlock |
[in] | location | location where requested |
bool rw_lock_sx_lock_low | ( | rw_lock_t * | lock, |
ulint | pass, | ||
ut::Location | location | ||
) |
Low-level function for acquiring an sx lock.
[in] | lock | pointer to rw-lock |
[in] | pass | pass value; != 0, if the lock will be passed to another thread to unlock |
[in] | location | location where requested |
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.
lock | in: rw-lock |
void rw_lock_x_lock_func | ( | rw_lock_t * | lock, |
ulint | pass, | ||
ut::Location | location | ||
) |
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!
[in] | lock | pointer to rw-lock |
[in] | pass | pass value; != 0, if the lock will be passed to another thread to unlock |
[in] | location | location where requested |
|
inlinestatic |
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 |
|
inlinestatic |
Function for the next writer to call.
Waits for readers to exit. The caller must have already decremented lock_word by X_LOCK_DECR.
[in] | lock | pointer to rw-lock |
[in] | pass | pass value; != 0, if the lock will be passed to another thread to unlock |
[in] | treshold | threshold to wait for |
[in] | file_name | file name where lock requested |
[in] | line | line where requested |
|
inlinestatic |
Function for the next writer to call.
Waits for readers to exit. The caller must have already decremented lock_word by X_LOCK_DECR.
[in] | lock | pointer to rw-lock |
[in] | pass | pass value; != 0, if the lock will be passed to another thread to unlock |
[in] | threshold | threshold to wait for |
[in] | file_name | file name where lock requested |
[in] | line | line where requested |
rw_lock_list_t rw_lock_list {} |
The global list of rw-locks.
ib_mutex_t rw_lock_list_mutex |