1
/*****************************************************************************
3
Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
4
Copyright (C) 2008, Google Inc.
6
Portions of this file contain modifications contributed and copyrighted by
7
Google, Inc. Those modifications are gratefully acknowledged and are described
8
briefly in the InnoDB documentation. The contributions by Google are
9
incorporated with their permission, and subject to the conditions contained in
10
the file COPYING.Google.
12
This program is free software; you can redistribute it and/or modify it under
13
the terms of the GNU General Public License as published by the Free Software
14
Foundation; version 2 of the License.
16
This program is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License along with
21
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
22
St, Fifth Floor, Boston, MA 02110-1301 USA
24
*****************************************************************************/
26
/**************************************************//**
27
@file include/sync0sync.h
1
/******************************************************
28
2
Mutex, the basic synchronization primitive
30
6
Created 9/5/1995 Heikki Tuuri
31
7
*******************************************************/
41
17
#include "os0sync.h"
42
18
#include "sync0arr.h"
44
#if defined(UNIV_DEBUG) && !defined(UNIV_HOTBACKUP)
45
extern my_bool timed_mutexes;
46
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
48
#ifdef HAVE_WINDOWS_ATOMICS
49
typedef LONG lock_word_t; /*!< On Windows, InterlockedExchange operates
52
typedef byte lock_word_t;
55
#if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
56
/* There are mutexes/rwlocks that we want to exclude from
57
instrumentation even if their corresponding performance schema
58
define is set. And this PFS_NOT_INSTRUMENTED is used
59
as the key value to dentify those objects that would
60
be excluded from instrumentation. */
61
# define PFS_NOT_INSTRUMENTED ULINT32_UNDEFINED
63
# define PFS_IS_INSTRUMENTED(key) ((key) != PFS_NOT_INSTRUMENTED)
65
/* By default, buffer mutexes and rwlocks will be excluded from
66
instrumentation due to their large number of instances. */
67
# define PFS_SKIP_BUFFER_MUTEX_RWLOCK
69
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
72
/* Key defines to register InnoDB mutexes with performance schema */
73
extern mysql_pfs_key_t autoinc_mutex_key;
74
extern mysql_pfs_key_t btr_search_enabled_mutex_key;
75
extern mysql_pfs_key_t buffer_block_mutex_key;
76
extern mysql_pfs_key_t buf_pool_mutex_key;
77
extern mysql_pfs_key_t buf_pool_zip_mutex_key;
78
extern mysql_pfs_key_t cache_last_read_mutex_key;
79
extern mysql_pfs_key_t dict_foreign_err_mutex_key;
80
extern mysql_pfs_key_t dict_sys_mutex_key;
81
extern mysql_pfs_key_t file_format_max_mutex_key;
82
extern mysql_pfs_key_t fil_system_mutex_key;
83
extern mysql_pfs_key_t flush_list_mutex_key;
84
extern mysql_pfs_key_t hash_table_mutex_key;
85
extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
86
extern mysql_pfs_key_t ibuf_mutex_key;
87
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
88
extern mysql_pfs_key_t log_sys_mutex_key;
89
extern mysql_pfs_key_t log_flush_order_mutex_key;
90
extern mysql_pfs_key_t kernel_mutex_key;
91
extern mysql_pfs_key_t commit_id_mutex_key;
92
# ifdef UNIV_MEM_DEBUG
93
extern mysql_pfs_key_t mem_hash_mutex_key;
94
# endif /* UNIV_MEM_DEBUG */
95
extern mysql_pfs_key_t mem_pool_mutex_key;
96
extern mysql_pfs_key_t mutex_list_mutex_key;
97
extern mysql_pfs_key_t purge_sys_mutex_key;
98
extern mysql_pfs_key_t recv_sys_mutex_key;
99
extern mysql_pfs_key_t rseg_mutex_key;
100
# ifdef UNIV_SYNC_DEBUG
101
extern mysql_pfs_key_t rw_lock_debug_mutex_key;
102
# endif /* UNIV_SYNC_DEBUG */
103
extern mysql_pfs_key_t rw_lock_list_mutex_key;
104
extern mysql_pfs_key_t rw_lock_mutex_key;
105
extern mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
106
extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
107
extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
108
extern mysql_pfs_key_t srv_monitor_file_mutex_key;
109
extern mysql_pfs_key_t syn_arr_mutex_key;
110
# ifdef UNIV_SYNC_DEBUG
111
extern mysql_pfs_key_t sync_thread_mutex_key;
112
# endif /* UNIV_SYNC_DEBUG */
113
extern mysql_pfs_key_t trx_doublewrite_mutex_key;
114
extern mysql_pfs_key_t thr_local_mutex_key;
115
extern mysql_pfs_key_t trx_undo_mutex_key;
116
#endif /* UNIV_PFS_MUTEX */
118
/******************************************************************//**
21
/**********************************************************************
119
22
Initializes the synchronization data structures. */
124
/******************************************************************//**
27
/**********************************************************************
125
28
Frees the resources in synchronization data structures. */
131
#undef mutex_free /* Fix for MacOS X */
133
#ifdef UNIV_PFS_MUTEX
134
33
/**********************************************************************
135
Following mutex APIs would be performance schema instrumented
136
if "UNIV_PFS_MUTEX" is defined:
144
These mutex APIs will point to corresponding wrapper functions that contain
145
the performance schema instrumentation if "UNIV_PFS_MUTEX" is defined.
146
The instrumented wrapper functions have the prefix of "innodb_".
148
NOTE! The following macro should be used in mutex operation, not the
149
corresponding function. */
151
/******************************************************************//**
152
34
Creates, or rather, initializes a mutex object to a specified memory
153
35
location (which must be appropriately aligned). The mutex is initialized
154
36
in the reset state. Explicit freeing of the mutex with mutex_free is
155
37
necessary only if the memory block containing it is freed. */
157
# ifdef UNIV_SYNC_DEBUG
158
# define mutex_create(K, M, level) \
159
pfs_mutex_create_func((K), (M), #M, (level), __FILE__, __LINE__)
161
# define mutex_create(K, M, level) \
162
pfs_mutex_create_func((K), (M), #M, __FILE__, __LINE__)
163
# endif/* UNIV_SYNC_DEBUG */
40
# ifdef UNIV_SYNC_DEBUG
41
# define mutex_create(M, level) \
42
mutex_create_func((M), #M, (level), __FILE__, __LINE__)
165
# define mutex_create(K, M, level) \
166
pfs_mutex_create_func((K), (M), __FILE__, __LINE__)
167
# endif /* UNIV_DEBUG */
169
# define mutex_enter(M) \
170
pfs_mutex_enter_func((M), __FILE__, __LINE__)
172
# define mutex_enter_nowait(M) \
173
pfs_mutex_enter_nowait_func((M), __FILE__, __LINE__)
175
# define mutex_exit(M) pfs_mutex_exit_func(M)
177
# define mutex_free(M) pfs_mutex_free_func(M)
179
#else /* UNIV_PFS_MUTEX */
181
/* If "UNIV_PFS_MUTEX" is not defined, the mutex APIs point to
182
original non-instrumented functions */
184
# ifdef UNIV_SYNC_DEBUG
185
# define mutex_create(K, M, level) \
186
mutex_create_func((M), #M, (level), __FILE__, __LINE__)
187
# else /* UNIV_SYNC_DEBUG */
188
# define mutex_create(K, M, level) \
44
# define mutex_create(M, level) \
189
45
mutex_create_func((M), #M, __FILE__, __LINE__)
190
# endif /* UNIV_SYNC_DEBUG */
191
# else /* UNIV_DEBUG */
192
# define mutex_create(K, M, level) \
48
# define mutex_create(M, level) \
193
49
mutex_create_func((M), __FILE__, __LINE__)
194
# endif /* UNIV_DEBUG */
196
# define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
198
# define mutex_enter_nowait(M) \
199
mutex_enter_nowait_func((M), __FILE__, __LINE__)
201
# define mutex_exit(M) mutex_exit_func(M)
203
# define mutex_free(M) mutex_free_func(M)
205
#endif /* UNIV_PFS_MUTEX */
207
/******************************************************************//**
52
/**********************************************************************
208
53
Creates, or rather, initializes a mutex object in a specified memory
209
54
location (which must be appropriately aligned). The mutex is initialized
210
55
in the reset state. Explicit freeing of the mutex with mutex_free is
214
59
mutex_create_func(
215
60
/*==============*/
216
mutex_t* mutex, /*!< in: pointer to memory */
61
mutex_t* mutex, /* in: pointer to memory */
218
const char* cmutex_name, /*!< in: mutex name */
63
const char* cmutex_name, /* in: mutex name */
219
64
# ifdef UNIV_SYNC_DEBUG
220
ulint level, /*!< in: level */
65
ulint level, /* in: level */
221
66
# endif /* UNIV_SYNC_DEBUG */
222
67
#endif /* UNIV_DEBUG */
223
const char* cfile_name, /*!< in: file name where created */
224
ulint cline); /*!< in: file line where created */
226
/******************************************************************//**
227
NOTE! Use the corresponding macro mutex_free(), not directly this function!
68
const char* cfile_name, /* in: file name where created */
69
ulint cline); /* in: file line where created */
71
#undef mutex_free /* Fix for MacOS X */
73
/**********************************************************************
228
74
Calling this function is obligatory only if the memory buffer containing
229
75
the mutex is freed. Removes a mutex object from the mutex list. The mutex
230
76
is checked to be in the reset state. */
235
mutex_t* mutex); /*!< in: mutex */
236
/**************************************************************//**
81
mutex_t* mutex); /* in: mutex */
82
/******************************************************************
83
NOTE! The following macro should be used in mutex locking, not the
84
corresponding function. */
86
#define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
87
/******************************************************************
237
88
NOTE! The following macro should be used in mutex locking, not the
238
89
corresponding function. */
240
91
/* NOTE! currently same as mutex_enter! */
242
93
#define mutex_enter_fast(M) mutex_enter_func((M), __FILE__, __LINE__)
243
/******************************************************************//**
94
/**********************************************************************
244
95
NOTE! Use the corresponding macro in the header file, not this function
245
96
directly. Locks a mutex for the current thread. If the mutex is reserved
246
97
the function spins a preset time (controlled by SYNC_SPIN_ROUNDS) waiting
250
101
mutex_enter_func(
251
102
/*=============*/
252
mutex_t* mutex, /*!< in: pointer to mutex */
253
const char* file_name, /*!< in: file name where locked */
254
ulint line); /*!< in: line where locked */
255
/********************************************************************//**
103
mutex_t* mutex, /* in: pointer to mutex */
104
const char* file_name, /* in: file name where locked */
105
ulint line); /* in: line where locked */
106
/******************************************************************
107
NOTE! The following macro should be used in mutex locking, not the
108
corresponding function. */
110
#define mutex_enter_nowait(M) \
111
mutex_enter_nowait_func((M), __FILE__, __LINE__)
112
/************************************************************************
256
113
NOTE! Use the corresponding macro in the header file, not this function
257
114
directly. Tries to lock the mutex for the current thread. If the lock is not
258
acquired immediately, returns with return value 1.
259
@return 0 if succeed, 1 if not */
115
acquired immediately, returns with return value 1. */
262
118
mutex_enter_nowait_func(
263
119
/*====================*/
264
mutex_t* mutex, /*!< in: pointer to mutex */
265
const char* file_name, /*!< in: file name where mutex
267
ulint line); /*!< in: line where requested */
268
/******************************************************************//**
269
NOTE! Use the corresponding macro mutex_exit(), not directly this function!
270
Unlocks a mutex owned by the current thread. */
275
mutex_t* mutex); /*!< in: pointer to mutex */
278
#ifdef UNIV_PFS_MUTEX
279
/******************************************************************//**
280
NOTE! Please use the corresponding macro mutex_create(), not directly
282
A wrapper function for mutex_create_func(), registers the mutex
283
with peformance schema if "UNIV_PFS_MUTEX" is defined when
284
creating the mutex */
287
pfs_mutex_create_func(
288
/*==================*/
289
PSI_mutex_key key, /*!< in: Performance Schema key */
290
mutex_t* mutex, /*!< in: pointer to memory */
292
const char* cmutex_name, /*!< in: mutex name */
293
# ifdef UNIV_SYNC_DEBUG
294
ulint level, /*!< in: level */
295
# endif /* UNIV_SYNC_DEBUG */
296
# endif /* UNIV_DEBUG */
297
const char* cfile_name, /*!< in: file name where created */
298
ulint cline); /*!< in: file line where created */
299
/******************************************************************//**
300
NOTE! Please use the corresponding macro mutex_enter(), not directly
302
This is a performance schema instrumented wrapper function for
303
mutex_enter_func(). */
306
pfs_mutex_enter_func(
307
/*=================*/
308
mutex_t* mutex, /*!< in: pointer to mutex */
309
const char* file_name, /*!< in: file name where locked */
310
ulint line); /*!< in: line where locked */
311
/********************************************************************//**
312
NOTE! Please use the corresponding macro mutex_enter_nowait(), not directly
314
This is a performance schema instrumented wrapper function for
315
mutex_enter_nowait_func.
316
@return 0 if succeed, 1 if not */
319
pfs_mutex_enter_nowait_func(
320
/*========================*/
321
mutex_t* mutex, /*!< in: pointer to mutex */
322
const char* file_name, /*!< in: file name where mutex
324
ulint line); /*!< in: line where requested */
325
/******************************************************************//**
326
NOTE! Please use the corresponding macro mutex_exit(), not directly
328
A wrap function of mutex_exit_func() with peformance schema instrumentation.
329
Unlocks a mutex owned by the current thread. */
334
mutex_t* mutex); /*!< in: pointer to mutex */
336
/******************************************************************//**
337
NOTE! Please use the corresponding macro mutex_free(), not directly
339
Wrapper function for mutex_free_func(). Also destroys the performance
340
schema probes when freeing the mutex */
345
mutex_t* mutex); /*!< in: mutex */
347
#endif /* UNIV_PFS_MUTEX */
349
#ifdef UNIV_SYNC_DEBUG
350
/******************************************************************//**
120
/* out: 0 if succeed, 1 if not */
121
mutex_t* mutex, /* in: pointer to mutex */
122
const char* file_name, /* in: file name where mutex
124
ulint line); /* in: line where requested */
125
/**********************************************************************
126
Unlocks a mutex owned by the current thread. */
131
mutex_t* mutex); /* in: pointer to mutex */
132
/**********************************************************************
351
133
Returns TRUE if no mutex or rw-lock is currently locked.
352
Works only in the debug version.
353
@return TRUE if no mutexes and rw-locks reserved */
134
Works only in the debug version. */
356
137
sync_all_freed(void);
357
138
/*================*/
358
#endif /* UNIV_SYNC_DEBUG */
359
139
/*#####################################################################
360
140
FUNCTION PROTOTYPES FOR DEBUGGING */
361
/*******************************************************************//**
141
/***********************************************************************
362
142
Prints wait info of the sync system. */
365
145
sync_print_wait_info(
366
146
/*=================*/
367
FILE* file); /*!< in: file where to print */
368
/*******************************************************************//**
147
FILE* file); /* in: file where to print */
148
/***********************************************************************
369
149
Prints info of the sync system. */
374
FILE* file); /*!< in: file where to print */
154
FILE* file); /* in: file where to print */
375
155
#ifdef UNIV_DEBUG
376
/******************************************************************//**
377
Checks that the mutex has been initialized.
156
/**********************************************************************
157
Checks that the mutex has been initialized. */
383
const mutex_t* mutex); /*!< in: mutex */
384
/******************************************************************//**
162
const mutex_t* mutex);
163
/**********************************************************************
385
164
Checks that the current thread owns the mutex. Works only
386
in the debug version.
387
@return TRUE if owns */
165
in the debug version. */
392
const mutex_t* mutex) /*!< in: mutex */
393
__attribute__((warn_unused_result));
170
/* out: TRUE if owns */
171
const mutex_t* mutex); /* in: mutex */
394
172
#endif /* UNIV_DEBUG */
395
173
#ifdef UNIV_SYNC_DEBUG
396
/******************************************************************//**
174
/**********************************************************************
397
175
Adds a latch and its level in the thread level array. Allocates the memory
398
176
for the array if called first time for this OS thread. Makes the checks
399
177
against other latch levels stored in the array for this thread. */
402
180
sync_thread_add_level(
403
181
/*==================*/
404
void* latch, /*!< in: pointer to a mutex or an rw-lock */
405
ulint level); /*!< in: level in the latching order; if
182
void* latch, /* in: pointer to a mutex or an rw-lock */
183
ulint level); /* in: level in the latching order; if
406
184
SYNC_LEVEL_VARYING, nothing is done */
407
/******************************************************************//**
408
Removes a latch from the thread level array if it is found there.
409
@return TRUE if found in the array; it is no error if the latch is
410
not found, as we presently are not able to determine the level for
411
every latch reservation the program does */
185
/**********************************************************************
186
Removes a latch from the thread level array if it is found there. */
414
189
sync_thread_reset_level(
415
190
/*====================*/
416
void* latch); /*!< in: pointer to a mutex or an rw-lock */
417
/******************************************************************//**
418
Checks that the level array for the current thread is empty.
419
@return TRUE if empty */
191
/* out: TRUE if found from the array; it is no error
192
if the latch is not found, as we presently are not
193
able to determine the level for every latch
194
reservation the program does */
195
void* latch); /* in: pointer to a mutex or an rw-lock */
196
/**********************************************************************
197
Checks that the level array for the current thread is empty. */
422
200
sync_thread_levels_empty(void);
423
201
/*==========================*/
424
/******************************************************************//**
425
Checks if the level array for the current thread contains a
426
mutex or rw-latch at the specified level.
427
@return a matching latch, or NULL if not found */
430
sync_thread_levels_contains(
431
/*========================*/
432
ulint level); /*!< in: latching order level
434
/******************************************************************//**
435
Checks if the level array for the current thread is empty.
436
@return a latch, or NULL if empty except the exceptions specified below */
439
sync_thread_levels_nonempty_gen(
440
/*============================*/
441
ibool dict_mutex_allowed); /*!< in: TRUE if dictionary mutex is
202
/* out: TRUE if empty */
203
/**********************************************************************
204
Checks that the level array for the current thread is empty. */
207
sync_thread_levels_empty_gen(
208
/*=========================*/
209
/* out: TRUE if empty except the
210
exceptions specified below */
211
ibool dict_mutex_allowed); /* in: TRUE if dictionary mutex is
442
212
allowed to be owned by the thread,
443
213
also purge_is_running mutex is
445
#define sync_thread_levels_empty_gen(d) (!sync_thread_levels_nonempty_gen(d))
446
/******************************************************************//**
215
/**********************************************************************
447
216
Gets the debug information for a reserved mutex. */
450
219
mutex_get_debug_info(
451
220
/*=================*/
452
mutex_t* mutex, /*!< in: mutex */
453
const char** file_name, /*!< out: file where requested */
454
ulint* line, /*!< out: line where requested */
455
os_thread_id_t* thread_id); /*!< out: id of the thread which owns
221
mutex_t* mutex, /* in: mutex */
222
const char** file_name, /* out: file where requested */
223
ulint* line, /* out: line where requested */
224
os_thread_id_t* thread_id); /* out: id of the thread which owns
457
/******************************************************************//**
458
Counts currently reserved mutexes. Works only in the debug version.
459
@return number of reserved mutexes */
226
/**********************************************************************
227
Counts currently reserved mutexes. Works only in the debug version. */
462
230
mutex_n_reserved(void);
463
231
/*==================*/
464
232
#endif /* UNIV_SYNC_DEBUG */
465
/******************************************************************//**
233
/**********************************************************************
466
234
NOT to be used outside this module except in debugging! Gets the value
467
235
of the lock word. */
470
238
mutex_get_lock_word(
471
239
/*================*/
472
const mutex_t* mutex); /*!< in: mutex */
240
const mutex_t* mutex); /* in: mutex */
473
241
#ifdef UNIV_SYNC_DEBUG
474
/******************************************************************//**
242
/**********************************************************************
475
243
NOT to be used outside this module except in debugging! Gets the waiters
477
@return value to set */
480
247
mutex_get_waiters(
481
248
/*==============*/
482
const mutex_t* mutex); /*!< in: mutex */
249
/* out: value to set */
250
const mutex_t* mutex); /* in: mutex */
483
251
#endif /* UNIV_SYNC_DEBUG */
693
457
Do not use its fields directly! The structure used in the spin lock
694
458
implementation of a mutual exclusion semaphore. */
697
460
struct mutex_struct {
698
os_event_t event; /*!< Used by sync0arr.c for the wait queue */
699
volatile lock_word_t lock_word; /*!< lock_word is the target
700
of the atomic test-and-set instruction when
701
atomic operations are enabled. */
703
#if !defined(HAVE_ATOMIC_BUILTINS)
461
os_event_t event; /* Used by sync0arr.c for the wait queue */
462
ulint lock_word; /* This ulint is the target of the atomic
463
test-and-set instruction in Win32 */
464
#if defined WIN32 && defined UNIV_CAN_USE_X86_ASSEMBLER
705
os_fast_mutex; /*!< We use this OS mutex in place of lock_word
706
when atomic operations are not enabled */
467
os_fast_mutex; /* In other systems we use this OS mutex
468
in place of lock_word */
708
ulint waiters; /*!< This ulint is set to 1 if there are (or
470
ulint waiters; /* This ulint is set to 1 if there are (or
709
471
may be) threads waiting in the global wait
710
472
array for this mutex to be released.
711
473
Otherwise, this is 0. */
712
UT_LIST_NODE_T(mutex_t) list; /*!< All allocated mutexes are put into
474
UT_LIST_NODE_T(mutex_t) list; /* All allocated mutexes are put into
713
475
a list. Pointers to the next and prev. */
714
476
#ifdef UNIV_SYNC_DEBUG
715
const char* file_name; /*!< File where the mutex was locked */
716
ulint line; /*!< Line where the mutex was locked */
717
ulint level; /*!< Level in the global latching order */
477
const char* file_name; /* File where the mutex was locked */
478
ulint line; /* Line where the mutex was locked */
479
ulint level; /* Level in the global latching order */
718
480
#endif /* UNIV_SYNC_DEBUG */
719
const char* cfile_name;/*!< File name where mutex created */
720
ulint cline; /*!< Line where created */
481
const char* cfile_name;/* File name where mutex created */
482
ulint cline; /* Line where created */
721
483
#ifdef UNIV_DEBUG
722
os_thread_id_t thread_id; /*!< The thread id of the thread
484
os_thread_id_t thread_id; /* The thread id of the thread
723
485
which locked the mutex. */
724
ulint magic_n; /*!< MUTEX_MAGIC_N */
725
/** Value of mutex_struct::magic_n */
726
487
# define MUTEX_MAGIC_N (ulint)979585
727
488
#endif /* UNIV_DEBUG */
728
ulong count_os_wait; /*!< count of os_wait */
730
ulong count_using; /*!< count of times mutex used */
731
ulong count_spin_loop; /*!< count of spin loops */
732
ulong count_spin_rounds;/*!< count of spin rounds */
733
ulong count_os_yield; /*!< count of os_wait */
734
ulonglong lspent_time; /*!< mutex os_wait timer msec */
735
ulonglong lmax_spent_time;/*!< mutex os_wait timer msec */
736
const char* cmutex_name; /*!< mutex name */
737
ulint mutex_type; /*!< 0=usual mutex, 1=rw_lock mutex */
738
#endif /* UNIV_DEBUG */
739
#ifdef UNIV_PFS_MUTEX
740
struct PSI_mutex* pfs_psi; /*!< The performance schema
741
instrumentation hook */
489
#ifndef UNIV_HOTBACKUP
490
ulong count_os_wait; /* count of os_wait */
492
ulong count_using; /* count of times mutex used */
493
ulong count_spin_loop; /* count of spin loops */
494
ulong count_spin_rounds; /* count of spin rounds */
495
ulong count_os_yield; /* count of os_wait */
496
ulonglong lspent_time; /* mutex os_wait timer msec */
497
ulonglong lmax_spent_time; /* mutex os_wait timer msec */
498
const char* cmutex_name;/* mutex name */
499
ulint mutex_type;/* 0 - usual mutex 1 - rw_lock mutex */
500
# endif /* UNIV_DEBUG */
501
#endif /* !UNIV_HOTBACKUP */
745
/** The global array of wait cells for implementation of the databases own
746
mutexes and read-write locks. */
747
extern sync_array_t* sync_primary_wait_array;/* Appears here for
748
debugging purposes only! */
750
/** Constant determining how long spin wait is continued before suspending
504
/* The global array of wait cells for implementation of the databases own
505
mutexes and read-write locks. Appears here for debugging purposes only! */
507
extern sync_array_t* sync_primary_wait_array;
509
/* Constant determining how long spin wait is continued before suspending
751
510
the thread. A value 600 rounds on a 1995 100 MHz Pentium seems to correspond
752
511
to 20 microseconds. */
754
513
#define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds
756
/** The number of mutex_exit calls. Intended for performance monitoring. */
757
extern ib_int64_t mutex_exit_count;
515
/* The number of system calls made in this module. Intended for performance
518
extern ulint mutex_system_call_count;
519
extern ulint mutex_exit_count;
759
521
#ifdef UNIV_SYNC_DEBUG
760
/** Latching order checks start when this is set TRUE */
522
/* Latching order checks start when this is set TRUE */
761
523
extern ibool sync_order_checks_on;
762
524
#endif /* UNIV_SYNC_DEBUG */
764
/** This variable is set to TRUE when sync_init is called */
526
/* This variable is set to TRUE when sync_init is called */
765
527
extern ibool sync_initialized;
767
/** Global list of database mutexes (not OS mutexes) created. */
529
/* Global list of database mutexes (not OS mutexes) created. */
768
530
typedef UT_LIST_BASE_NODE_T(mutex_t) ut_list_base_node_t;
769
/** Global list of database mutexes (not OS mutexes) created. */
770
531
extern ut_list_base_node_t mutex_list;
772
/** Mutex protecting the mutex_list variable */
533
/* Mutex protecting the mutex_list variable */
773
534
extern mutex_t mutex_list_mutex;