MySQL 9.1.0
Source Code Documentation
sync0arr.h File Reference

The wait array used in synchronization primitives. More...

#include "univ.i"
#include "sync0arr.ic"

Go to the source code of this file.

Functions

static sync_array_tsync_array_get_and_reserve_cell (void *object, ulint type, ut::Location location, sync_cell_t **cell)
 Get an instance of the sync wait array and reserve a wait array cell in the instance for waiting for an object. More...
 
sync_cell_tsync_array_reserve_cell (sync_array_t *arr, void *object, ulint type, ut::Location location)
 Reserves a wait array cell for waiting for an object. More...
 
void sync_array_wait_event (sync_array_t *arr, sync_cell_t *&cell)
 This function should be called when a thread starts to wait on a wait array cell. More...
 
void sync_array_free_cell (sync_array_t *arr, sync_cell_t *&cell)
 Frees the cell. More...
 
void sync_array_object_signalled ()
 Note that one of the wait objects was signalled. More...
 
void sync_arr_wake_threads_if_sema_free ()
 If the wakeup algorithm does not work perfectly at semaphore releases, this function will do the waking (see the comment in mutex_exit). More...
 
bool sync_array_print_long_waits (std::thread::id *waiter, const void **sema)
 Prints warnings of long semaphore waits to stderr. More...
 
void sync_array_detect_deadlock ()
 
void sync_array_print (FILE *file)
 Prints info of the wait array. More...
 
void sync_array_init (ulint n_threads)
 Create the primary system wait array(s), they are protected by an OS mutex. More...
 
void sync_array_close ()
 Close sync array wait sub-system. More...
 
static sync_array_tsync_array_get ()
 Get an instance of the sync wait array. More...
 

Detailed Description

The wait array used in synchronization primitives.

Created 9/5/1995 Heikki Tuuri

Function Documentation

◆ sync_arr_wake_threads_if_sema_free()

void sync_arr_wake_threads_if_sema_free ( void  )

If the wakeup algorithm does not work perfectly at semaphore releases, this function will do the waking (see the comment in mutex_exit).

This function should be called about every 1 second in the server.

This function should be called about every 1 second in the server.

Note that there's a race condition between this thread and mutex_exit changing the lock_word and calling signal_object, so sometimes this finds threads to wake up even when nothing has gone wrong.

◆ sync_array_close()

void sync_array_close ( )

Close sync array wait sub-system.

◆ sync_array_detect_deadlock()

void sync_array_detect_deadlock ( )

◆ sync_array_free_cell()

void sync_array_free_cell ( sync_array_t arr,
sync_cell_t *&  cell 
)

Frees the cell.

NOTE! sync_array_wait_event frees the cell automatically! in: the reserved cell

NOTE! sync_array_wait_event frees the cell automatically!

Parameters
arrin: wait array
cellin/out: the cell in the array

◆ sync_array_get()

static sync_array_t * sync_array_get ( )
inlinestatic

Get an instance of the sync wait array.

◆ sync_array_get_and_reserve_cell()

static sync_array_t * sync_array_get_and_reserve_cell ( void *  object,
ulint  type,
ut::Location  location,
sync_cell_t **  cell 
)
inlinestatic

Get an instance of the sync wait array and reserve a wait array cell in the instance for waiting for an object.

The event of the cell is reset to nonsignalled state. If reserving cell of the instance fails, try to get another new instance until we can reserve an empty cell of it.

Parameters
[in]objectpointer to the object to wait for
[in]typelock request type
[in]locationlocation where requested
[out]cellthe cell reserved, never NULL
Returns
the sync array found, never NULL.

◆ sync_array_init()

void sync_array_init ( ulint  n_threads)

Create the primary system wait array(s), they are protected by an OS mutex.

in: Number of slots to create

Parameters
n_threadsin: Number of slots to create in all arrays

◆ sync_array_object_signalled()

void sync_array_object_signalled ( )

Note that one of the wait objects was signalled.

Note that one of the wait objects was signalled.

◆ sync_array_print()

void sync_array_print ( FILE *  file)

Prints info of the wait array.

in: file where to print

Prints info of the wait array.

Parameters
filein/out: Print to this stream

◆ sync_array_print_long_waits()

bool sync_array_print_long_waits ( std::thread::id waiter,
const void **  sema 
)

Prints warnings of long semaphore waits to stderr.

Returns
true if fatal semaphore wait threshold was exceeded out: longest-waited-for semaphore
true if fatal semaphore wait threshold was exceeded
Parameters
waiterout: longest waiting thread
semaout: longest-waited-for semaphore

◆ sync_array_reserve_cell()

sync_cell_t * sync_array_reserve_cell ( sync_array_t arr,
void *  object,
ulint  type,
ut::Location  location 
)

Reserves a wait array cell for waiting for an object.

The event of the cell is reset to nonsignalled state.

Parameters
[in]arrwait array
[in]objectpointer to the object to wait for
[in]typelock request type
[in]locationlocation where requested
Returns
sync cell to wait on

◆ sync_array_wait_event()

void sync_array_wait_event ( sync_array_t arr,
sync_cell_t *&  cell 
)

This function should be called when a thread starts to wait on a wait array cell.

In the debug version this function checks if the wait for a semaphore will result in a deadlock, in which case prints info and asserts. in: the reserved cell

In the debug version this function checks if the wait for a semaphore will result in a deadlock, in which case prints info and asserts.

Parameters
arrin: wait array
cellin: index of the reserved cell