MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sync0rw.cc File Reference
#include "sync0rw.h"
#include "os0thread.h"
#include "mem0mem.h"
#include "srv0srv.h"
#include "os0sync.h"
#include "ha_prototypes.h"
Include dependency graph for sync0rw.cc:

Go to the source code of this file.

Functions

UNIV_INTERN void rw_lock_create_func (rw_lock_t *lock, const char *cfile_name, ulint cline)
UNIV_INTERN void rw_lock_free_func (rw_lock_t *lock)
UNIV_INTERN void rw_lock_s_lock_spin (rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
UNIV_INTERN void rw_lock_x_lock_move_ownership (rw_lock_t *lock)
UNIV_INLINE void rw_lock_x_lock_wait (rw_lock_t *lock, const char *file_name, ulint line)
UNIV_INLINE ibool rw_lock_x_lock_low (rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
UNIV_INTERN void rw_lock_x_lock_func (rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
UNIV_INTERN ibool rw_lock_is_locked (rw_lock_t *lock, ulint lock_type)

Variables

UNIV_INTERN rw_lock_stats_t rw_lock_stats
UNIV_INTERN rw_lock_list_t rw_lock_list
UNIV_INTERN ib_mutex_t rw_lock_list_mutex

Detailed Description

The read-write lock (for thread synchronization)

Created 9/11/1995 Heikki Tuuri

Definition in file sync0rw.cc.

Function Documentation

UNIV_INTERN void rw_lock_create_func ( rw_lock_t lock,
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.

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

Definition at line 209 of file sync0rw.cc.

Here is the call graph for this function:

UNIV_INTERN 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.

Parameters
lockin: rw-lock

Definition at line 285 of file sync0rw.cc.

Here is the call graph for this function:

UNIV_INTERN ibool rw_lock_is_locked ( rw_lock_t lock,
ulint  lock_type 
)

Checks if somebody has locked the rw-lock in the specified mode.

Returns
TRUE if locked
Parameters
lockin: rw-lock
lock_typein: lock type: RW_LOCK_SHARED, RW_LOCK_EX

Definition at line 859 of file sync0rw.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN 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 SYNC_SPIN_ROUNDS), waiting for the lock, before suspending the thread.

Parameters
lockin: pointer to rw-lock
passin: pass value; != 0, if the lock will be passed to another thread to unlock
file_namein: file name where lock requested
linein: line where requested

Definition at line 359 of file sync0rw.cc.

Here is the call graph for this function:

UNIV_INTERN 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 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 x-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed!

< spin round count

< index of the reserved wait cell

Parameters
lockin: pointer to rw-lock
passin: pass value; != 0, if the lock will be passed to another thread to unlock
file_namein: file name where lock requested
linein: line where requested

Definition at line 599 of file sync0rw.cc.

Here is the call graph for this function:

UNIV_INLINE ibool 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.

Returns
FALSE if did not succeed, TRUE if success.
Parameters
lockin: pointer to rw-lock
passin: pass value; != 0, if the lock will be passed to another thread to unlock
file_namein: file name where lock requested
linein: line where requested

Definition at line 535 of file sync0rw.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN 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.

Parameters
lockin: lock which was x-locked in the buffer read

Definition at line 444 of file sync0rw.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE void rw_lock_x_lock_wait ( rw_lock_t lock,
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.

Parameters
lockin: pointer to rw-lock
file_namein: file name where lock requested
linein: line where requested

Definition at line 459 of file sync0rw.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

UNIV_INTERN rw_lock_stats_t rw_lock_stats

Counters for RW locks.

Definition at line 137 of file sync0rw.cc.