InnoDB Plugin  1.0
sync0sync.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2008, Google Inc.
5 Copyright (c) 2012, Facebook Inc.
6 
7 Portions of this file contain modifications contributed and copyrighted by
8 Google, Inc. Those modifications are gratefully acknowledged and are described
9 briefly in the InnoDB documentation. The contributions by Google are
10 incorporated with their permission, and subject to the conditions contained in
11 the file COPYING.Google.
12 
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; version 2 of the License.
16 
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
24 
25 *****************************************************************************/
26 
27 /**************************************************/
34 #ifndef sync0sync_h
35 #define sync0sync_h
36 
37 #include "univ.i"
38 #include "sync0types.h"
39 #include "ut0lst.h"
40 #include "ut0mem.h"
41 #include "os0thread.h"
42 #include "os0sync.h"
43 #include "sync0arr.h"
44 
45 #if defined(UNIV_DEBUG) && !defined(UNIV_HOTBACKUP)
46 extern "C" my_bool timed_mutexes;
47 #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
48 
49 #ifdef HAVE_WINDOWS_ATOMICS
50 typedef LONG lock_word_t;
52 #elif defined(HAVE_ATOMIC_BUILTINS) && !defined(HAVE_ATOMIC_BUILTINS_BYTE)
53 typedef ulint lock_word_t;
54 #else
55 typedef byte lock_word_t;
56 #endif
57 
58 #if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
59 
60 /* By default, buffer mutexes and rwlocks will be excluded from
61 instrumentation due to their large number of instances. */
62 # define PFS_SKIP_BUFFER_MUTEX_RWLOCK
63 
64 /* By default, event->mutex will also be excluded from instrumentation */
65 # define PFS_SKIP_EVENT_MUTEX
66 
67 #endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
68 
69 #ifdef UNIV_PFS_MUTEX
70 /* Key defines to register InnoDB mutexes with performance schema */
71 extern mysql_pfs_key_t autoinc_mutex_key;
72 extern mysql_pfs_key_t buffer_block_mutex_key;
73 extern mysql_pfs_key_t buf_pool_mutex_key;
74 extern mysql_pfs_key_t buf_pool_zip_mutex_key;
75 extern mysql_pfs_key_t cache_last_read_mutex_key;
76 extern mysql_pfs_key_t dict_foreign_err_mutex_key;
77 extern mysql_pfs_key_t dict_sys_mutex_key;
78 extern mysql_pfs_key_t file_format_max_mutex_key;
79 extern mysql_pfs_key_t fil_system_mutex_key;
80 extern mysql_pfs_key_t flush_list_mutex_key;
81 extern mysql_pfs_key_t fts_bg_threads_mutex_key;
82 extern mysql_pfs_key_t fts_delete_mutex_key;
83 extern mysql_pfs_key_t fts_optimize_mutex_key;
84 extern mysql_pfs_key_t fts_doc_id_mutex_key;
85 extern mysql_pfs_key_t fts_pll_tokenize_mutex_key;
86 extern mysql_pfs_key_t hash_table_mutex_key;
87 extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
88 extern mysql_pfs_key_t ibuf_mutex_key;
89 extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
90 extern mysql_pfs_key_t log_sys_mutex_key;
91 extern mysql_pfs_key_t log_flush_order_mutex_key;
92 # ifndef HAVE_ATOMIC_BUILTINS
93 extern mysql_pfs_key_t server_mutex_key;
94 # endif /* !HAVE_ATOMIC_BUILTINS */
95 # ifdef UNIV_MEM_DEBUG
96 extern mysql_pfs_key_t mem_hash_mutex_key;
97 # endif /* UNIV_MEM_DEBUG */
98 extern mysql_pfs_key_t mem_pool_mutex_key;
99 extern mysql_pfs_key_t mutex_list_mutex_key;
100 extern mysql_pfs_key_t purge_sys_bh_mutex_key;
101 extern mysql_pfs_key_t recv_sys_mutex_key;
102 extern mysql_pfs_key_t recv_writer_mutex_key;
103 extern mysql_pfs_key_t rseg_mutex_key;
104 # ifdef UNIV_SYNC_DEBUG
105 extern mysql_pfs_key_t rw_lock_debug_mutex_key;
106 # endif /* UNIV_SYNC_DEBUG */
107 extern mysql_pfs_key_t rw_lock_list_mutex_key;
108 extern mysql_pfs_key_t rw_lock_mutex_key;
109 extern mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
110 extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
111 extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
112 extern mysql_pfs_key_t srv_threads_mutex_key;
113 extern mysql_pfs_key_t srv_monitor_file_mutex_key;
114 # ifdef UNIV_SYNC_DEBUG
115 extern mysql_pfs_key_t sync_thread_mutex_key;
116 # endif /* UNIV_SYNC_DEBUG */
117 extern mysql_pfs_key_t buf_dblwr_mutex_key;
118 extern mysql_pfs_key_t trx_undo_mutex_key;
119 extern mysql_pfs_key_t trx_mutex_key;
120 extern mysql_pfs_key_t lock_sys_mutex_key;
121 extern mysql_pfs_key_t lock_sys_wait_mutex_key;
122 extern mysql_pfs_key_t trx_sys_mutex_key;
123 extern mysql_pfs_key_t srv_sys_mutex_key;
124 extern mysql_pfs_key_t srv_sys_tasks_mutex_key;
125 #ifndef HAVE_ATOMIC_BUILTINS
126 extern mysql_pfs_key_t srv_conc_mutex_key;
127 #endif /* !HAVE_ATOMIC_BUILTINS */
128 #ifndef HAVE_ATOMIC_BUILTINS_64
129 extern mysql_pfs_key_t monitor_mutex_key;
130 #endif /* !HAVE_ATOMIC_BUILTINS_64 */
131 extern mysql_pfs_key_t event_os_mutex_key;
132 extern mysql_pfs_key_t ut_list_mutex_key;
133 extern mysql_pfs_key_t os_mutex_key;
134 extern mysql_pfs_key_t zip_pad_mutex_key;
135 #endif /* UNIV_PFS_MUTEX */
136 
137 /******************************************************************/
139 UNIV_INTERN
140 void
141 sync_init(void);
142 /*===========*/
143 /******************************************************************/
145 UNIV_INTERN
146 void
147 sync_close(void);
148 /*===========*/
149 
150 #undef mutex_free /* Fix for MacOS X */
151 
152 #ifdef UNIV_PFS_MUTEX
153 /**********************************************************************
154 Following mutex APIs would be performance schema instrumented
155 if "UNIV_PFS_MUTEX" is defined:
156 
157 mutex_create
158 mutex_enter
159 mutex_exit
160 mutex_enter_nowait
161 mutex_free
162 
163 These mutex APIs will point to corresponding wrapper functions that contain
164 the performance schema instrumentation if "UNIV_PFS_MUTEX" is defined.
165 The instrumented wrapper functions have the prefix of "innodb_".
166 
167 NOTE! The following macro should be used in mutex operation, not the
168 corresponding function. */
169 
170 /******************************************************************/
175 # ifdef UNIV_DEBUG
176 # ifdef UNIV_SYNC_DEBUG
177 # define mutex_create(K, M, level) \
178  pfs_mutex_create_func((K), (M), #M, (level), __FILE__, __LINE__)
179 # else
180 # define mutex_create(K, M, level) \
181  pfs_mutex_create_func((K), (M), #M, __FILE__, __LINE__)
182 # endif/* UNIV_SYNC_DEBUG */
183 # else
184 # define mutex_create(K, M, level) \
185  pfs_mutex_create_func((K), (M), __FILE__, __LINE__)
186 # endif /* UNIV_DEBUG */
187 
188 # define mutex_enter(M) \
189  pfs_mutex_enter_func((M), __FILE__, __LINE__)
190 
191 # define mutex_enter_nowait(M) \
192  pfs_mutex_enter_nowait_func((M), __FILE__, __LINE__)
193 
194 # define mutex_exit(M) pfs_mutex_exit_func(M)
195 
196 # define mutex_free(M) pfs_mutex_free_func(M)
197 
198 #else /* UNIV_PFS_MUTEX */
199 
200 /* If "UNIV_PFS_MUTEX" is not defined, the mutex APIs point to
201 original non-instrumented functions */
202 # ifdef UNIV_DEBUG
203 # ifdef UNIV_SYNC_DEBUG
204 # define mutex_create(K, M, level) \
205  mutex_create_func((M), #M, (level), __FILE__, __LINE__)
206 # else /* UNIV_SYNC_DEBUG */
207 # define mutex_create(K, M, level) \
208  mutex_create_func((M), #M, __FILE__, __LINE__)
209 # endif /* UNIV_SYNC_DEBUG */
210 # else /* UNIV_DEBUG */
211 # define mutex_create(K, M, level) \
212  mutex_create_func((M), __FILE__, __LINE__)
213 # endif /* UNIV_DEBUG */
214 
215 # define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
216 
217 # define mutex_enter_nowait(M) \
218  mutex_enter_nowait_func((M), __FILE__, __LINE__)
219 
220 # define mutex_exit(M) mutex_exit_func(M)
221 
222 # define mutex_free(M) mutex_free_func(M)
223 
224 #endif /* UNIV_PFS_MUTEX */
225 
226 /******************************************************************/
231 UNIV_INTERN
232 void
234 /*==============*/
235  ib_mutex_t* mutex,
236 #ifdef UNIV_DEBUG
237  const char* cmutex_name,
238 # ifdef UNIV_SYNC_DEBUG
239  ulint level,
240 # endif /* UNIV_SYNC_DEBUG */
241 #endif /* UNIV_DEBUG */
242  const char* cfile_name,
243  ulint cline);
245 /******************************************************************/
250 UNIV_INTERN
251 void
253 /*============*/
254  ib_mutex_t* mutex);
255 /**************************************************************/
259 /* NOTE! currently same as mutex_enter! */
260 
261 #define mutex_enter_fast(M) mutex_enter_func((M), __FILE__, __LINE__)
262 /******************************************************************/
267 UNIV_INLINE
268 void
270 /*=============*/
271  ib_mutex_t* mutex,
272  const char* file_name,
273  ulint line);
274 /********************************************************************/
279 UNIV_INTERN
280 ulint
282 /*====================*/
283  ib_mutex_t* mutex,
284  const char* file_name,
286  ulint line);
287 /******************************************************************/
290 UNIV_INLINE
291 void
293 /*============*/
294  ib_mutex_t* mutex);
297 #ifdef UNIV_PFS_MUTEX
298 /******************************************************************/
304 UNIV_INLINE
305 void
306 pfs_mutex_create_func(
307 /*==================*/
308  PSI_mutex_key key,
309  ib_mutex_t* mutex,
310 # ifdef UNIV_DEBUG
311  const char* cmutex_name,
312 # ifdef UNIV_SYNC_DEBUG
313  ulint level,
314 # endif /* UNIV_SYNC_DEBUG */
315 # endif /* UNIV_DEBUG */
316  const char* cfile_name,
317  ulint cline);
318 /******************************************************************/
323 UNIV_INLINE
324 void
325 pfs_mutex_enter_func(
326 /*=================*/
327  ib_mutex_t* mutex,
328  const char* file_name,
329  ulint line);
330 /********************************************************************/
336 UNIV_INLINE
337 ulint
338 pfs_mutex_enter_nowait_func(
339 /*========================*/
340  ib_mutex_t* mutex,
341  const char* file_name,
343  ulint line);
344 /******************************************************************/
349 UNIV_INLINE
350 void
351 pfs_mutex_exit_func(
352 /*================*/
353  ib_mutex_t* mutex);
355 /******************************************************************/
360 UNIV_INLINE
361 void
362 pfs_mutex_free_func(
363 /*================*/
364  ib_mutex_t* mutex);
366 #endif /* UNIV_PFS_MUTEX */
367 
368 #ifdef UNIV_SYNC_DEBUG
369 /******************************************************************/
373 UNIV_INTERN
374 ibool
375 sync_all_freed(void);
376 /*================*/
377 #endif /* UNIV_SYNC_DEBUG */
378 /*#####################################################################
379 FUNCTION PROTOTYPES FOR DEBUGGING */
380 /*******************************************************************/
382 UNIV_INTERN
383 void
385 /*=================*/
386  FILE* file);
387 /*******************************************************************/
389 UNIV_INTERN
390 void
391 sync_print(
392 /*=======*/
393  FILE* file);
394 #ifdef UNIV_DEBUG
395 /******************************************************************/
398 UNIV_INTERN
399 ibool
401 /*===========*/
402  const ib_mutex_t* mutex);
403 /******************************************************************/
407 UNIV_INTERN
408 ibool
409 mutex_own(
410 /*======*/
411  const ib_mutex_t* mutex)
412  __attribute__((warn_unused_result));
413 #endif /* UNIV_DEBUG */
414 #ifdef UNIV_SYNC_DEBUG
415 /******************************************************************/
419 UNIV_INTERN
420 void
422 /*==================*/
423  void* latch,
424  ulint level,
426  ibool relock)
427  __attribute__((nonnull));
428 /******************************************************************/
433 UNIV_INTERN
434 ibool
436 /*====================*/
437  void* latch);
438 /******************************************************************/
442 UNIV_INTERN
443 void*
445 /*========================*/
446  ulint level);
448 /******************************************************************/
451 UNIV_INTERN
452 void*
454 /*============================*/
455  ibool dict_mutex_allowed)
457  __attribute__((warn_unused_result));
458 /******************************************************************/
461 #define sync_thread_levels_empty_except_dict() \
462  (!sync_thread_levels_nonempty_gen(TRUE))
463 /******************************************************************/
467 UNIV_INTERN
468 void*
470 /*============================*/
471  ibool has_search_latch)
474  __attribute__((warn_unused_result));
475 
476 /******************************************************************/
478 UNIV_INTERN
479 void
481 /*=================*/
482  ib_mutex_t* mutex,
483  const char** file_name,
484  ulint* line,
485  os_thread_id_t* thread_id);
487 /******************************************************************/
490 UNIV_INTERN
491 ulint
492 mutex_n_reserved(void);
493 /*==================*/
494 #endif /* UNIV_SYNC_DEBUG */
495 /******************************************************************/
498 UNIV_INLINE
499 lock_word_t
501 /*================*/
502  const ib_mutex_t* mutex);
503 #ifdef UNIV_SYNC_DEBUG
504 /******************************************************************/
508 UNIV_INLINE
509 ulint
511 /*==============*/
512  const ib_mutex_t* mutex);
513 #endif /* UNIV_SYNC_DEBUG */
514 
515 /*
516  LATCHING ORDER WITHIN THE DATABASE
517  ==================================
518 
519 The mutex or latch in the central memory object, for instance, a rollback
520 segment object, must be acquired before acquiring the latch or latches to
521 the corresponding file data structure. In the latching order below, these
522 file page object latches are placed immediately below the corresponding
523 central memory object latch or mutex.
524 
525 Synchronization object Notes
526 ---------------------- -----
527 
528 Dictionary mutex If we have a pointer to a dictionary
529 | object, e.g., a table, it can be
530 | accessed without reserving the
531 | dictionary mutex. We must have a
532 | reservation, a memoryfix, to the
533 | appropriate table object in this case,
534 | and the table must be explicitly
535 | released later.
536 V
537 Dictionary header
538 |
539 V
540 Secondary index tree latch The tree latch protects also all
541 | the B-tree non-leaf pages. These
542 V can be read with the page only
543 Secondary index non-leaf bufferfixed to save CPU time,
544 | no s-latch is needed on the page.
545 | Modification of a page requires an
546 | x-latch on the page, however. If a
547 | thread owns an x-latch to the tree,
548 | it is allowed to latch non-leaf pages
549 | even after it has acquired the fsp
550 | latch.
551 V
552 Secondary index leaf The latch on the secondary index leaf
553 | can be kept while accessing the
554 | clustered index, to save CPU time.
555 V
556 Clustered index tree latch To increase concurrency, the tree
557 | latch is usually released when the
558 | leaf page latch has been acquired.
559 V
560 Clustered index non-leaf
561 |
562 V
563 Clustered index leaf
564 |
565 V
566 Transaction system header
567 |
568 V
569 Transaction undo mutex The undo log entry must be written
570 | before any index page is modified.
571 | Transaction undo mutex is for the undo
572 | logs the analogue of the tree latch
573 | for a B-tree. If a thread has the
574 | trx undo mutex reserved, it is allowed
575 | to latch the undo log pages in any
576 | order, and also after it has acquired
577 | the fsp latch.
578 V
579 Rollback segment mutex The rollback segment mutex must be
580 | reserved, if, e.g., a new page must
581 | be added to an undo log. The rollback
582 | segment and the undo logs in its
583 | history list can be seen as an
584 | analogue of a B-tree, and the latches
585 | reserved similarly, using a version of
586 | lock-coupling. If an undo log must be
587 | extended by a page when inserting an
588 | undo log record, this corresponds to
589 | a pessimistic insert in a B-tree.
590 V
591 Rollback segment header
592 |
593 V
594 Purge system latch
595 |
596 V
597 Undo log pages If a thread owns the trx undo mutex,
598 | or for a log in the history list, the
599 | rseg mutex, it is allowed to latch
600 | undo log pages in any order, and even
601 | after it has acquired the fsp latch.
602 | If a thread does not have the
603 | appropriate mutex, it is allowed to
604 | latch only a single undo log page in
605 | a mini-transaction.
606 V
607 File space management latch If a mini-transaction must allocate
608 | several file pages, it can do that,
609 | because it keeps the x-latch to the
610 | file space management in its memo.
611 V
612 File system pages
613 |
614 V
615 lock_sys_wait_mutex Mutex protecting lock timeout data
616 |
617 V
618 lock_sys_mutex Mutex protecting lock_sys_t
619 |
620 V
621 trx_sys->mutex Mutex protecting trx_sys_t
622 |
623 V
624 Threads mutex Background thread scheduling mutex
625 |
626 V
627 query_thr_mutex Mutex protecting query threads
628 |
629 V
630 trx_mutex Mutex protecting trx_t fields
631 |
632 V
633 Search system mutex
634 |
635 V
636 Buffer pool mutex
637 |
638 V
639 Log mutex
640 |
641 Any other latch
642 |
643 V
644 Memory pool mutex */
645 
646 /* Latching order levels. If you modify these, you have to also update
647 sync_thread_add_level(). */
648 
649 /* User transaction locks are higher than any of the latch levels below:
650 no latches are allowed when a thread goes to wait for a normal table
651 or row lock! */
652 #define SYNC_USER_TRX_LOCK 9999
653 #define SYNC_NO_ORDER_CHECK 3000 /* this can be used to suppress
654  latching order checking */
655 #define SYNC_LEVEL_VARYING 2000 /* Level is varying. Only used with
656  buffer pool page locks, which do not
657  have a fixed level, but instead have
658  their level set after the page is
659  locked; see e.g.
660  ibuf_bitmap_get_map_page(). */
661 #define SYNC_TRX_I_S_RWLOCK 1910 /* Used for
662  trx_i_s_cache_t::rw_lock */
663 #define SYNC_TRX_I_S_LAST_READ 1900 /* Used for
664  trx_i_s_cache_t::last_read_mutex */
665 #define SYNC_FILE_FORMAT_TAG 1200 /* Used to serialize access to the
666  file format tag */
667 #define SYNC_DICT_OPERATION 1010 /* table create, drop, etc. reserve
668  this in X-mode; implicit or backround
669  operations purge, rollback, foreign
670  key checks reserve this in S-mode */
671 #define SYNC_FTS_CACHE 1005 /* FTS cache rwlock */
672 #define SYNC_DICT 1000
673 #define SYNC_DICT_AUTOINC_MUTEX 999
674 #define SYNC_STATS_AUTO_RECALC 997
675 #define SYNC_DICT_HEADER 995
676 #define SYNC_IBUF_HEADER 914
677 #define SYNC_IBUF_PESS_INSERT_MUTEX 912
678 /*-------------------------------*/
679 #define SYNC_INDEX_TREE 900
680 #define SYNC_TREE_NODE_NEW 892
681 #define SYNC_TREE_NODE_FROM_HASH 891
682 #define SYNC_TREE_NODE 890
683 #define SYNC_PURGE_LATCH 800
684 #define SYNC_TRX_UNDO 700
685 #define SYNC_RSEG 600
686 #define SYNC_RSEG_HEADER_NEW 591
687 #define SYNC_RSEG_HEADER 590
688 #define SYNC_TRX_UNDO_PAGE 570
689 #define SYNC_EXTERN_STORAGE 500
690 #define SYNC_FSP 400
691 #define SYNC_FSP_PAGE 395
692 /*------------------------------------- Change buffer headers */
693 #define SYNC_IBUF_MUTEX 370 /* ibuf_mutex */
694 /*------------------------------------- Change buffer tree */
695 #define SYNC_IBUF_INDEX_TREE 360
696 #define SYNC_IBUF_TREE_NODE_NEW 359
697 #define SYNC_IBUF_TREE_NODE 358
698 #define SYNC_IBUF_BITMAP_MUTEX 351
699 #define SYNC_IBUF_BITMAP 350
700 /*------------------------------------- Change log for online create index */
701 #define SYNC_INDEX_ONLINE_LOG 340
702 /*------------------------------------- MySQL query cache mutex */
703 /*------------------------------------- MySQL binlog mutex */
704 /*-------------------------------*/
705 #define SYNC_LOCK_WAIT_SYS 300
706 #define SYNC_LOCK_SYS 299
707 #define SYNC_TRX_SYS 298
708 #define SYNC_TRX 297
709 #define SYNC_THREADS 295
710 #define SYNC_REC_LOCK 294
711 #define SYNC_TRX_SYS_HEADER 290
712 #define SYNC_PURGE_QUEUE 200
713 #define SYNC_LOG 170
714 #define SYNC_LOG_FLUSH_ORDER 147
715 #define SYNC_RECV 168
716 #define SYNC_FTS_TOKENIZE 167
717 #define SYNC_FTS_CACHE_INIT 166 /* Used for FTS cache initialization */
718 #define SYNC_FTS_BG_THREADS 165
719 #define SYNC_FTS_OPTIMIZE 164 // FIXME: is this correct number, test
720 #define SYNC_WORK_QUEUE 162
721 #define SYNC_SEARCH_SYS 160 /* NOTE that if we have a memory
722  heap that can be extended to the
723  buffer pool, its logical level is
724  SYNC_SEARCH_SYS, as memory allocation
725  can call routines there! Otherwise
726  the level is SYNC_MEM_HASH. */
727 #define SYNC_BUF_POOL 150 /* Buffer pool mutex */
728 #define SYNC_BUF_PAGE_HASH 149 /* buf_pool->page_hash rw_lock */
729 #define SYNC_BUF_BLOCK 146 /* Block mutex */
730 #define SYNC_BUF_FLUSH_LIST 145 /* Buffer flush list mutex */
731 #define SYNC_DOUBLEWRITE 140
732 #define SYNC_ANY_LATCH 135
733 #define SYNC_MEM_HASH 131
734 #define SYNC_MEM_POOL 130
735 
736 /* Codes used to designate lock operations */
737 #define RW_LOCK_NOT_LOCKED 350
738 #define RW_LOCK_EX 351
739 #define RW_LOCK_EXCLUSIVE 351
740 #define RW_LOCK_SHARED 352
741 #define RW_LOCK_WAIT_EX 353
742 #define SYNC_MUTEX 354
744 /* NOTE! The structure appears here only for the compiler to know its size.
745 Do not use its fields directly! The structure used in the spin lock
746 implementation of a mutual exclusion semaphore. */
749 struct ib_mutex_t {
751  volatile lock_word_t lock_word;
755 #if !defined(HAVE_ATOMIC_BUILTINS)
757  os_fast_mutex;
759 #endif
760  ulint waiters;
764  UT_LIST_NODE_T(ib_mutex_t) list;
766 #ifdef UNIV_SYNC_DEBUG
767  const char* file_name;
768  ulint line;
769  ulint level;
770 #endif /* UNIV_SYNC_DEBUG */
771  const char* cfile_name;
772  ulint cline;
773  ulong count_os_wait;
774 #ifdef UNIV_DEBUG
775 
777 # define MUTEX_MAGIC_N 979585UL
781  ulint magic_n;
782  const char* cmutex_name;
783  ulint ib_mutex_type;
784 #endif /* UNIV_DEBUG */
785 #ifdef UNIV_PFS_MUTEX
786  struct PSI_mutex* pfs_psi;
788 #endif
789 };
790 
795 #define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds
796 
798 extern ib_int64_t mutex_exit_count;
799 
800 #ifdef UNIV_SYNC_DEBUG
801 
803 #endif /* UNIV_SYNC_DEBUG */
804 
806 extern ibool sync_initialized;
807 
809 typedef UT_LIST_BASE_NODE_T(ib_mutex_t) ut_list_base_node_t;
811 extern ut_list_base_node_t mutex_list;
812 
814 extern ib_mutex_t mutex_list_mutex;
815 
816 #ifndef HAVE_ATOMIC_BUILTINS
817 /**********************************************************/
819 UNIV_INLINE
820 void
822 /*=====================*/
823  ib_mutex_t* mutex,
825  volatile ulint* var,
827  ulint delta);
828 /**********************************************************/
830 UNIV_INLINE
831 void
833 /*=====================*/
834  ib_mutex_t* mutex,
836  volatile ulint* var,
838  ulint delta);
839 #endif /* !HAVE_ATOMIC_BUILTINS */
840 
841 #ifndef UNIV_NONINL
842 #include "sync0sync.ic"
843 #endif
844 
845 #endif