Go to the source code of this file.
Classes | |
struct | os_event_struct |
Macros | |
#define | os0sync_h |
#define | OS_SYNC_INFINITE_TIME ULINT_UNDEFINED |
#define | OS_SYNC_TIME_EXCEEDED 1 |
#define | os_event_wait(event) os_event_wait_low(event, 0) |
#define | os_event_wait_time(e, t) os_event_wait_time_low(event, t, 0) |
#define | IB_ATOMICS_STARTUP_MSG "Mutexes and rw_locks use InnoDB's own implementation" |
Typedefs | |
typedef pthread_mutex_t | os_fast_mutex_t |
typedef pthread_cond_t | os_cond_t |
typedef struct os_event_struct | os_event_struct_t |
typedef os_event_struct_t * | os_event_t |
typedef struct os_mutex_struct | os_mutex_str_t |
typedef os_mutex_str_t * | os_mutex_t |
Functions | |
UNIV_INTERN void | os_sync_init (void) |
UNIV_INTERN void | os_sync_free (void) |
UNIV_INTERN os_event_t | os_event_create (const char *name) |
UNIV_INTERN void | os_event_set (os_event_t event) |
UNIV_INTERN ib_int64_t | os_event_reset (os_event_t event) |
UNIV_INTERN void | os_event_free (os_event_t event) |
UNIV_INTERN void | os_event_wait_low (os_event_t event, ib_int64_t reset_sig_count) |
UNIV_INTERN ulint | os_event_wait_time_low (os_event_t event, ulint time_in_usec, ib_int64_t reset_sig_count) |
UNIV_INTERN os_mutex_t | os_mutex_create (void) |
UNIV_INTERN void | os_mutex_enter (os_mutex_t mutex) |
UNIV_INTERN void | os_mutex_exit (os_mutex_t mutex) |
UNIV_INTERN void | os_mutex_free (os_mutex_t mutex) |
UNIV_INLINE ulint | os_fast_mutex_trylock (os_fast_mutex_t *fast_mutex) |
UNIV_INTERN void | os_fast_mutex_unlock (os_fast_mutex_t *fast_mutex) |
UNIV_INTERN void | os_fast_mutex_init (os_fast_mutex_t *fast_mutex) |
UNIV_INTERN void | os_fast_mutex_lock (os_fast_mutex_t *fast_mutex) |
UNIV_INTERN void | os_fast_mutex_free (os_fast_mutex_t *fast_mutex) |
Variables | |
os_mutex_t | os_sync_mutex |
ulint | os_thread_count |
ulint | os_event_count |
ulint | os_mutex_count |
ulint | os_fast_mutex_count |
The interface to the operating system synchronization primitives.
Created 9/6/1995 Heikki Tuuri
Definition in file os0sync.h.
#define IB_ATOMICS_STARTUP_MSG "Mutexes and rw_locks use InnoDB's own implementation" |
Atomic compare-and-swap and increment for InnoDB.
Definition at line 419 of file os0sync.h.
Referenced by innobase_start_or_create_for_mysql().
#define OS_SYNC_INFINITE_TIME ULINT_UNDEFINED |
Denotes an infinite delay for os_event_wait_time()
Definition at line 81 of file os0sync.h.
Referenced by os_event_wait_time_low().
#define OS_SYNC_TIME_EXCEEDED 1 |
Return value of os_event_wait_time() when the time is exceeded
Definition at line 84 of file os0sync.h.
Referenced by os_event_wait_time_low().
typedef struct os_event_struct os_event_struct_t |
typedef os_event_struct_t* os_event_t |
typedef pthread_mutex_t os_fast_mutex_t |
typedef struct os_mutex_struct os_mutex_str_t |
typedef os_mutex_str_t* os_mutex_t |
UNIV_INTERN os_event_t os_event_create | ( | const char * | name | ) |
Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled. The created event is manual reset: it must be reset explicitly by calling sync_os_reset_event.
Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled. The created event is manual reset: it must be reset explicitly by calling sync_os_reset_event.
name | in: the name of the event, if NULL the event is created without a name |
Definition at line 365 of file os0sync.cc.
References os_event_struct::cond_var, os_mutex_struct::event, os_event_create(), os_fast_mutex_init(), os_event_struct::os_mutex, os_mutex_enter(), os_mutex_exit(), UT_LIST_ADD_FIRST, ut_malloc(), and UT_NOT_USED.
Referenced by ib_wqueue_create(), log_init(), mutex_create_func(), os_event_create(), os_mutex_create(), rw_lock_create_func(), srv_init(), and sync_init().
UNIV_INTERN void os_event_free | ( | os_event_t | event | ) |
Frees an event object. in: event to free
Frees an event object.
event | in: event to free |
Definition at line 535 of file os0sync.cc.
References os_event_struct::cond_var, os_event_free(), os_fast_mutex_free(), os_event_struct::os_mutex, os_mutex_enter(), os_mutex_exit(), ut_a, ut_free(), and UT_LIST_REMOVE.
Referenced by ib_wqueue_free(), mutex_free_func(), os_event_free(), os_sync_free(), and rw_lock_free_func().
UNIV_INTERN ib_int64_t os_event_reset | ( | os_event_t | event | ) |
Resets an event semaphore to the nonsignaled state. Waiting threads will stop to wait for the event. The return value should be passed to os_even_wait_low() if it is desired that this thread should not wait in case of an intervening call to os_event_set() between this os_event_reset() and the os_event_wait_low() call. See comments for os_event_wait_low(). in: event to reset
Resets an event semaphore to the nonsignaled state. Waiting threads will stop to wait for the event. The return value should be passed to os_even_wait_low() if it is desired that this thread should not wait in case of an intervening call to os_event_set() between this os_event_reset() and the os_event_wait_low() call. See comments for os_event_wait_low().
event | in: event to reset |
Definition at line 472 of file os0sync.cc.
References os_event_struct::is_set, os_event_reset(), os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, and ut_a.
Referenced by ib_wqueue_wait(), log_write_up_to(), os_aio_simulated_handle(), os_aio_simulated_put_read_threads_to_sleep(), os_event_reset(), srv_conc_enter_innodb(), srv_error_monitor_thread(), srv_lock_timeout_thread(), srv_monitor_thread(), srv_suspend_mysql_thread(), and sync_array_reserve_cell().
UNIV_INTERN void os_event_set | ( | os_event_t | event | ) |
Sets an event semaphore to the signaled state: lets waiting threads proceed. in: event to set
Sets an event semaphore to the signaled state: lets waiting threads proceed.
event | in: event to set |
Definition at line 434 of file os0sync.cc.
References os_event_struct::cond_var, os_event_struct::is_set, os_event_set(), os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, and ut_a.
Referenced by buf_flush_write_complete(), buf_LRU_get_free_block(), ib_wqueue_add(), innobase_shutdown_for_mysql(), log_init(), logs_empty_and_mark_files_at_shutdown(), os_aio_wake_all_threads_at_shutdown(), os_event_set(), row_create_table_for_mysql(), srv_conc_force_exit_innodb(), srv_release_mysql_thread_if_suspended(), srv_release_threads(), srv_suspend_mysql_thread(), sync_arr_wake_threads_if_sema_free(), and sync_array_print_long_waits().
UNIV_INTERN void os_event_wait_low | ( | os_event_t | event, |
ib_int64_t | reset_sig_count | ||
) |
Waits for an event object until it is in the signaled state. If srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the waiting thread when the event becomes signaled (or immediately if the event is already in the signaled state).
Typically, if the event has been signalled after the os_event_reset() we'll return immediately because event->is_set == TRUE. There are, however, situations (e.g.: sync_array code) where we may lose this information. For example:
thread A calls os_event_reset() thread B calls os_event_set() [event->is_set == TRUE] thread C calls os_event_reset() [event->is_set == FALSE] thread A calls os_event_wait() [infinite wait!] thread C calls os_event_wait() [infinite wait!]
Where such a scenario is possible, to avoid infinite wait, the value returned by os_event_reset() should be passed in as reset_sig_count. in: zero or the value returned by previous call of os_event_reset().
Waits for an event object until it is in the signaled state. If srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the waiting thread when the event becomes signaled (or immediately if the event is already in the signaled state).
Typically, if the event has been signalled after the os_event_reset() we'll return immediately because event->is_set == TRUE. There are, however, situations (e.g.: sync_array code) where we may lose this information. For example:
thread A calls os_event_reset() thread B calls os_event_set() [event->is_set == TRUE] thread C calls os_event_reset() [event->is_set == FALSE] thread A calls os_event_wait() [infinite wait!] thread C calls os_event_wait() [infinite wait!]
Where such a scenario is possible, to avoid infinite wait, the value returned by os_event_reset() should be passed in as reset_sig_count.
event | in: event to wait |
reset_sig_count | in: zero or the value returned by previous call of os_event_reset(). |
Definition at line 586 of file os0sync.cc.
References os_event_struct::cond_var, os_event_struct::is_set, os_event_wait_low(), os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, os_thread_exit(), os_event_struct::signal_count, SRV_SHUTDOWN_EXIT_THREADS, ut_a, and UT_NOT_USED.
Referenced by os_event_wait_low(), and sync_array_wait_event().
UNIV_INTERN ulint os_event_wait_time_low | ( | os_event_t | event, |
ulint | time_in_usec, | ||
ib_int64_t | reset_sig_count | ||
) |
Waits for an event object until it is in the signaled state or a timeout is exceeded. In Unix the timeout is always infinite.
Waits for an event object until it is in the signaled state or a timeout is exceeded.
event | in: event to wait |
time_in_usec | in: timeout in microseconds, or OS_SYNC_INFINITE_TIME |
reset_sig_count | in: zero or the value returned by previous call of os_event_reset(). |
Definition at line 652 of file os0sync.cc.
References os_event_struct::cond_var, os_event_struct::is_set, os_event_wait_time_low(), os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, OS_SYNC_INFINITE_TIME, OS_SYNC_TIME_EXCEEDED, os_thread_exit(), os_event_struct::signal_count, SRV_SHUTDOWN_EXIT_THREADS, ut_a, ut_error, and ut_usectime().
Referenced by os_event_wait_time_low(), srv_error_monitor_thread(), srv_lock_timeout_thread(), and srv_monitor_thread().
UNIV_INTERN void os_fast_mutex_free | ( | os_fast_mutex_t * | fast_mutex | ) |
Frees an mutex object. in: mutex to free
Frees a mutex object.
fast_mutex | in: mutex to free |
Definition at line 930 of file os0sync.cc.
References os_fast_mutex_free(), os_mutex_enter(), os_mutex_exit(), ut_a, ut_ad, ut_print_buf(), and ut_print_timestamp().
Referenced by innobase_start_or_create_for_mysql(), mutex_free_func(), os_event_free(), os_fast_mutex_free(), os_mutex_free(), srv_free(), and ut_free_all_mem().
UNIV_INTERN void os_fast_mutex_init | ( | os_fast_mutex_t * | fast_mutex | ) |
Initializes an operating system fast mutex semaphore. in: fast mutex
Initializes an operating system fast mutex semaphore.
fast_mutex | in: fast mutex |
Definition at line 871 of file os0sync.cc.
References os_fast_mutex_init(), os_mutex_enter(), os_mutex_exit(), and ut_a.
Referenced by innobase_start_or_create_for_mysql(), mutex_create_func(), os_event_create(), os_fast_mutex_init(), os_mutex_create(), srv_init(), and ut_mem_init().
UNIV_INTERN void os_fast_mutex_lock | ( | os_fast_mutex_t * | fast_mutex | ) |
Acquires ownership of a fast mutex. in: mutex to acquire
Acquires ownership of a fast mutex.
fast_mutex | in: mutex to acquire |
Definition at line 900 of file os0sync.cc.
References os_fast_mutex_lock().
Referenced by innobase_start_or_create_for_mysql(), os_event_reset(), os_event_set(), os_event_wait_low(), os_event_wait_time_low(), os_fast_mutex_lock(), os_mem_alloc_large(), os_mem_free_large(), os_mutex_enter(), srv_conc_enter_innodb(), srv_conc_force_enter_innodb(), srv_conc_force_exit_innodb(), ut_free(), and ut_malloc_low().
UNIV_INLINE ulint os_fast_mutex_trylock | ( | os_fast_mutex_t * | fast_mutex | ) |
Acquires ownership of a fast mutex. Currently in Windows this is the same as os_fast_mutex_lock!
Referenced by innobase_start_or_create_for_mysql().
UNIV_INTERN void os_fast_mutex_unlock | ( | os_fast_mutex_t * | fast_mutex | ) |
Releases ownership of a fast mutex. in: mutex to release
Releases ownership of a fast mutex.
fast_mutex | in: mutex to release |
Definition at line 915 of file os0sync.cc.
References os_fast_mutex_unlock().
Referenced by innobase_start_or_create_for_mysql(), os_event_reset(), os_event_set(), os_event_wait_low(), os_event_wait_time_low(), os_fast_mutex_unlock(), os_mem_alloc_large(), os_mem_free_large(), os_mutex_exit(), srv_conc_enter_innodb(), srv_conc_force_enter_innodb(), srv_conc_force_exit_innodb(), ut_free(), and ut_malloc_low().
UNIV_INTERN os_mutex_t os_mutex_create | ( | void | ) |
Creates an operating system mutex semaphore. Because these are slow, the mutex semaphore of InnoDB itself (mutex_t) should be used where possible.
Definition at line 774 of file os0sync.cc.
References os_mutex_struct::count, os_mutex_struct::event, os_mutex_struct::handle, os_event_create(), os_fast_mutex_init(), os_mutex_create(), os_mutex_enter(), os_mutex_exit(), UT_LIST_ADD_FIRST, and ut_malloc().
Referenced by os_io_init_simple(), os_mutex_create(), os_sync_init(), and sync_array_create().
UNIV_INTERN void os_mutex_enter | ( | os_mutex_t | mutex | ) |
Acquires ownership of a mutex semaphore. in: mutex to acquire
Acquires ownership of a mutex semaphore.
mutex | in: mutex to acquire |
Definition at line 809 of file os0sync.cc.
References os_mutex_struct::count, os_mutex_struct::handle, os_fast_mutex_lock(), os_mutex_enter(), and ut_a.
Referenced by innobase_shutdown_for_mysql(), os_aio_print(), os_aio_simulated_handle(), os_event_create(), os_event_free(), os_fast_mutex_free(), os_fast_mutex_init(), os_file_read_func(), os_file_read_no_error_handling_func(), os_file_write_func(), os_mutex_create(), os_mutex_enter(), os_mutex_free(), os_thread_create(), and os_thread_exit().
UNIV_INTERN void os_mutex_exit | ( | os_mutex_t | mutex | ) |
Releases ownership of a mutex. in: mutex to release
Releases ownership of a mutex.
mutex | in: mutex to release |
Definition at line 824 of file os0sync.cc.
References os_mutex_struct::count, os_mutex_struct::handle, os_fast_mutex_unlock(), os_mutex_exit(), and ut_a.
Referenced by innobase_shutdown_for_mysql(), os_aio_print(), os_aio_simulated_handle(), os_event_create(), os_event_free(), os_fast_mutex_free(), os_fast_mutex_init(), os_file_read_func(), os_file_read_no_error_handling_func(), os_file_write_func(), os_mutex_create(), os_mutex_exit(), os_mutex_free(), os_thread_create(), and os_thread_exit().
UNIV_INTERN void os_mutex_free | ( | os_mutex_t | mutex | ) |
Frees an mutex object. in: mutex to free
Frees a mutex object.
mutex | in: mutex to free |
Definition at line 840 of file os0sync.cc.
References os_mutex_struct::event, os_mutex_struct::handle, os_fast_mutex_free(), os_mutex_enter(), os_mutex_exit(), os_mutex_free(), ut_a, ut_free(), and UT_LIST_REMOVE.
Referenced by os_mutex_free(), os_sync_free(), and sync_array_free().
UNIV_INTERN void os_sync_free | ( | void | ) |
Frees created events and OS 'slow' mutexes.
Definition at line 325 of file os0sync.cc.
References os_mutex_struct::event, os_event_free(), os_mutex_free(), os_sync_free(), and UT_LIST_GET_FIRST.
Referenced by innobase_shutdown_for_mysql(), and os_sync_free().
UNIV_INTERN void os_sync_init | ( | void | ) |
Initializes global event and OS 'slow' mutex lists.
Definition at line 304 of file os0sync.cc.
References os_mutex_create(), os_sync_init(), and UT_LIST_INIT.
Referenced by os_sync_init(), and srv_general_init().
os_mutex_t os_sync_mutex |
Mutex protecting counts and the event and OS 'slow' mutex lists
Mutex protecting counts and the lists of OS mutexes and events
Definition at line 59 of file os0sync.cc.
Referenced by innobase_shutdown_for_mysql(), os_thread_create(), and os_thread_exit().
ulint os_thread_count |
This is incremented by 1 in os_thread_create and decremented by 1 in
os_thread_exit
Definition at line 67 of file os0sync.cc.
Referenced by innobase_shutdown_for_mysql(), os_thread_create(), and os_thread_exit().