InnoDB Plugin  1.0
Data Fields
rw_lock_t Struct Reference

#include <sync0rw.h>

Collaboration diagram for rw_lock_t:
Collaboration graph
[legend]

Data Fields

volatile lint lock_word
volatile ulint waiters
volatile ibool recursive
volatile os_thread_id_t writer_thread
os_event_t event
os_event_t wait_ex_event
ib_mutex_t mutex
ut_list_node< rw_lock_tlist
ut_list_base< rw_lock_debug_tdebug_list
ulint level
ulint count_os_wait
const char * cfile_name
const char * last_s_file_name
const char * last_x_file_name
ibool writer_is_wait_ex
unsigned cline:14
unsigned last_s_line:14
unsigned last_x_line:14
ulint magic_n

Detailed Description

The structure used in the spin lock implementation of a read-write

lock. Several threads may have a shared lock simultaneously in this lock, but only one writer may have an exclusive lock, in which case no shared locks are allowed. To prevent starving of a writer blocked by readers, a writer may queue for x-lock by decrementing lock_word: no new readers will be let in while the thread waits for readers to exit.

Field Documentation

const char* rw_lock_t::cfile_name

File name where lock created

unsigned rw_lock_t::cline

Line where created

ulint rw_lock_t::count_os_wait

Count of os_waits. May not be accurate

ut_list_base< rw_lock_debug_t > rw_lock_t::debug_list

In the debug version: pointer to the debug info list of the lock

os_event_t rw_lock_t::event

Used by sync0arr.cc for thread queueing

const char* rw_lock_t::last_s_file_name

File name where last s-locked

unsigned rw_lock_t::last_s_line

Line number where last time s-locked

const char* rw_lock_t::last_x_file_name

File name where last x-locked

unsigned rw_lock_t::last_x_line

Line number where last time x-locked

ulint rw_lock_t::level

Level in the global latching order.

ut_list_node< rw_lock_t > rw_lock_t::list

All allocated rw locks are put into a list

volatile lint rw_lock_t::lock_word

Holds the state of the lock.

ulint rw_lock_t::magic_n

RW_LOCK_MAGIC_N

ib_mutex_t rw_lock_t::mutex

The mutex protecting rw_lock_t

volatile ibool rw_lock_t::recursive

Default value FALSE which means the lock is non-recursive. The value is typically set to TRUE making normal rw_locks recursive. In case of asynchronous IO, when a non-zero value of 'pass' is passed then we keep the lock non-recursive. This flag also tells us about the state of writer_thread field. If this flag is set then writer_thread MUST contain the thread id of the current x-holder or wait-x thread. This flag must be reset in x_unlock functions before incrementing the lock_word

os_event_t rw_lock_t::wait_ex_event

Event for next-writer to wait on. A thread must decrement lock_word before waiting.

volatile ulint rw_lock_t::waiters

1: there are waiters

ibool rw_lock_t::writer_is_wait_ex

This is TRUE if the writer field is RW_LOCK_WAIT_EX; this field is located far from the memory update hotspot fields which are at the start of this struct, thus we can peek this field without causing much memory bus traffic

volatile os_thread_id_t rw_lock_t::writer_thread

Thread id of writer thread. Is only guaranteed to have sane and non-stale value iff recursive flag is set.


The documentation for this struct was generated from the following file: