MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #else
53 typedef byte lock_word_t;
54 #endif
55 
56 #if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
57 
58 /* By default, buffer mutexes and rwlocks will be excluded from
59 instrumentation due to their large number of instances. */
60 # define PFS_SKIP_BUFFER_MUTEX_RWLOCK
61 
62 /* By default, event->mutex will also be excluded from instrumentation */
63 # define PFS_SKIP_EVENT_MUTEX
64 
65 #endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
66 
67 #ifdef UNIV_PFS_MUTEX
68 /* Key defines to register InnoDB mutexes with performance schema */
69 extern mysql_pfs_key_t autoinc_mutex_key;
70 extern mysql_pfs_key_t buffer_block_mutex_key;
71 extern mysql_pfs_key_t buf_pool_mutex_key;
72 extern mysql_pfs_key_t buf_pool_zip_mutex_key;
73 extern mysql_pfs_key_t cache_last_read_mutex_key;
74 extern mysql_pfs_key_t dict_foreign_err_mutex_key;
75 extern mysql_pfs_key_t dict_sys_mutex_key;
76 extern mysql_pfs_key_t file_format_max_mutex_key;
77 extern mysql_pfs_key_t fil_system_mutex_key;
78 extern mysql_pfs_key_t flush_list_mutex_key;
79 extern mysql_pfs_key_t fts_bg_threads_mutex_key;
80 extern mysql_pfs_key_t fts_delete_mutex_key;
81 extern mysql_pfs_key_t fts_optimize_mutex_key;
82 extern mysql_pfs_key_t fts_doc_id_mutex_key;
83 extern mysql_pfs_key_t hash_table_mutex_key;
84 extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
85 extern mysql_pfs_key_t ibuf_mutex_key;
86 extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
87 extern mysql_pfs_key_t log_sys_mutex_key;
88 extern mysql_pfs_key_t log_flush_order_mutex_key;
89 # ifndef HAVE_ATOMIC_BUILTINS
90 extern mysql_pfs_key_t server_mutex_key;
91 # endif /* !HAVE_ATOMIC_BUILTINS */
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_bh_mutex_key;
98 extern mysql_pfs_key_t recv_sys_mutex_key;
99 extern mysql_pfs_key_t recv_writer_mutex_key;
100 extern mysql_pfs_key_t rseg_mutex_key;
101 # ifdef UNIV_SYNC_DEBUG
102 extern mysql_pfs_key_t rw_lock_debug_mutex_key;
103 # endif /* UNIV_SYNC_DEBUG */
104 extern mysql_pfs_key_t rw_lock_list_mutex_key;
105 extern mysql_pfs_key_t rw_lock_mutex_key;
106 extern mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
107 extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
108 extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
109 extern mysql_pfs_key_t srv_threads_mutex_key;
110 extern mysql_pfs_key_t srv_monitor_file_mutex_key;
111 # ifdef UNIV_SYNC_DEBUG
112 extern mysql_pfs_key_t sync_thread_mutex_key;
113 # endif /* UNIV_SYNC_DEBUG */
114 extern mysql_pfs_key_t buf_dblwr_mutex_key;
115 extern mysql_pfs_key_t trx_undo_mutex_key;
116 extern mysql_pfs_key_t trx_mutex_key;
117 extern mysql_pfs_key_t lock_sys_mutex_key;
118 extern mysql_pfs_key_t lock_sys_wait_mutex_key;
119 extern mysql_pfs_key_t trx_sys_mutex_key;
120 extern mysql_pfs_key_t srv_sys_mutex_key;
121 extern mysql_pfs_key_t srv_sys_tasks_mutex_key;
122 #ifndef HAVE_ATOMIC_BUILTINS
123 extern mysql_pfs_key_t srv_conc_mutex_key;
124 #endif /* !HAVE_ATOMIC_BUILTINS */
125 #ifndef HAVE_ATOMIC_BUILTINS_64
126 extern mysql_pfs_key_t monitor_mutex_key;
127 #endif /* !HAVE_ATOMIC_BUILTINS_64 */
128 extern mysql_pfs_key_t event_os_mutex_key;
129 extern mysql_pfs_key_t ut_list_mutex_key;
130 extern mysql_pfs_key_t os_mutex_key;
131 extern mysql_pfs_key_t zip_pad_mutex_key;
132 #endif /* UNIV_PFS_MUTEX */
133 
134 /******************************************************************/
136 UNIV_INTERN
137 void
138 sync_init(void);
139 /*===========*/
140 /******************************************************************/
142 UNIV_INTERN
143 void
144 sync_close(void);
145 /*===========*/
146 
147 #undef mutex_free /* Fix for MacOS X */
148 
149 #ifdef UNIV_PFS_MUTEX
150 /**********************************************************************
151 Following mutex APIs would be performance schema instrumented
152 if "UNIV_PFS_MUTEX" is defined:
153 
154 mutex_create
155 mutex_enter
156 mutex_exit
157 mutex_enter_nowait
158 mutex_free
159 
160 These mutex APIs will point to corresponding wrapper functions that contain
161 the performance schema instrumentation if "UNIV_PFS_MUTEX" is defined.
162 The instrumented wrapper functions have the prefix of "innodb_".
163 
164 NOTE! The following macro should be used in mutex operation, not the
165 corresponding function. */
166 
167 /******************************************************************/
172 # ifdef UNIV_DEBUG
173 # ifdef UNIV_SYNC_DEBUG
174 # define mutex_create(K, M, level) \
175  pfs_mutex_create_func((K), (M), #M, (level), __FILE__, __LINE__)
176 # else
177 # define mutex_create(K, M, level) \
178  pfs_mutex_create_func((K), (M), #M, __FILE__, __LINE__)
179 # endif/* UNIV_SYNC_DEBUG */
180 # else
181 # define mutex_create(K, M, level) \
182  pfs_mutex_create_func((K), (M), __FILE__, __LINE__)
183 # endif /* UNIV_DEBUG */
184 
185 # define mutex_enter(M) \
186  pfs_mutex_enter_func((M), __FILE__, __LINE__)
187 
188 # define mutex_enter_nowait(M) \
189  pfs_mutex_enter_nowait_func((M), __FILE__, __LINE__)
190 
191 # define mutex_exit(M) pfs_mutex_exit_func(M)
192 
193 # define mutex_free(M) pfs_mutex_free_func(M)
194 
195 #else /* UNIV_PFS_MUTEX */
196 
197 /* If "UNIV_PFS_MUTEX" is not defined, the mutex APIs point to
198 original non-instrumented functions */
199 # ifdef UNIV_DEBUG
200 # ifdef UNIV_SYNC_DEBUG
201 # define mutex_create(K, M, level) \
202  mutex_create_func((M), #M, (level), __FILE__, __LINE__)
203 # else /* UNIV_SYNC_DEBUG */
204 # define mutex_create(K, M, level) \
205  mutex_create_func((M), #M, __FILE__, __LINE__)
206 # endif /* UNIV_SYNC_DEBUG */
207 # else /* UNIV_DEBUG */
208 # define mutex_create(K, M, level) \
209  mutex_create_func((M), __FILE__, __LINE__)
210 # endif /* UNIV_DEBUG */
211 
212 # define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
213 
214 # define mutex_enter_nowait(M) \
215  mutex_enter_nowait_func((M), __FILE__, __LINE__)
216 
217 # define mutex_exit(M) mutex_exit_func(M)
218 
219 # define mutex_free(M) mutex_free_func(M)
220 
221 #endif /* UNIV_PFS_MUTEX */
222 
223 /******************************************************************/
228 UNIV_INTERN
229 void
231 /*==============*/
232  ib_mutex_t* mutex,
233 #ifdef UNIV_DEBUG
234  const char* cmutex_name,
235 # ifdef UNIV_SYNC_DEBUG
236  ulint level,
237 # endif /* UNIV_SYNC_DEBUG */
238 #endif /* UNIV_DEBUG */
239  const char* cfile_name,
240  ulint cline);
242 /******************************************************************/
247 UNIV_INTERN
248 void
250 /*============*/
251  ib_mutex_t* mutex);
252 /**************************************************************/
256 /* NOTE! currently same as mutex_enter! */
257 
258 #define mutex_enter_fast(M) mutex_enter_func((M), __FILE__, __LINE__)
259 /******************************************************************/
264 UNIV_INLINE
265 void
267 /*=============*/
268  ib_mutex_t* mutex,
269  const char* file_name,
270  ulint line);
271 /********************************************************************/
276 UNIV_INTERN
277 ulint
279 /*====================*/
280  ib_mutex_t* mutex,
281  const char* file_name,
283  ulint line);
284 /******************************************************************/
287 UNIV_INLINE
288 void
290 /*============*/
291  ib_mutex_t* mutex);
294 #ifdef UNIV_PFS_MUTEX
295 /******************************************************************/
301 UNIV_INLINE
302 void
303 pfs_mutex_create_func(
304 /*==================*/
305  PSI_mutex_key key,
306  ib_mutex_t* mutex,
307 # ifdef UNIV_DEBUG
308  const char* cmutex_name,
309 # ifdef UNIV_SYNC_DEBUG
310  ulint level,
311 # endif /* UNIV_SYNC_DEBUG */
312 # endif /* UNIV_DEBUG */
313  const char* cfile_name,
314  ulint cline);
315 /******************************************************************/
320 UNIV_INLINE
321 void
322 pfs_mutex_enter_func(
323 /*=================*/
324  ib_mutex_t* mutex,
325  const char* file_name,
326  ulint line);
327 /********************************************************************/
333 UNIV_INLINE
334 ulint
335 pfs_mutex_enter_nowait_func(
336 /*========================*/
337  ib_mutex_t* mutex,
338  const char* file_name,
340  ulint line);
341 /******************************************************************/
346 UNIV_INLINE
347 void
348 pfs_mutex_exit_func(
349 /*================*/
350  ib_mutex_t* mutex);
352 /******************************************************************/
357 UNIV_INLINE
358 void
359 pfs_mutex_free_func(
360 /*================*/
361  ib_mutex_t* mutex);
363 #endif /* UNIV_PFS_MUTEX */
364 
365 #ifdef UNIV_SYNC_DEBUG
366 /******************************************************************/
370 UNIV_INTERN
371 ibool
372 sync_all_freed(void);
373 /*================*/
374 #endif /* UNIV_SYNC_DEBUG */
375 /*#####################################################################
376 FUNCTION PROTOTYPES FOR DEBUGGING */
377 /*******************************************************************/
379 UNIV_INTERN
380 void
382 /*=================*/
383  FILE* file);
384 /*******************************************************************/
386 UNIV_INTERN
387 void
388 sync_print(
389 /*=======*/
390  FILE* file);
391 #ifdef UNIV_DEBUG
392 /******************************************************************/
395 UNIV_INTERN
396 ibool
397 mutex_validate(
398 /*===========*/
399  const ib_mutex_t* mutex);
400 /******************************************************************/
404 UNIV_INTERN
405 ibool
406 mutex_own(
407 /*======*/
408  const ib_mutex_t* mutex)
409  __attribute__((warn_unused_result));
410 #endif /* UNIV_DEBUG */
411 #ifdef UNIV_SYNC_DEBUG
412 /******************************************************************/
416 UNIV_INTERN
417 void
418 sync_thread_add_level(
419 /*==================*/
420  void* latch,
421  ulint level,
423  ibool relock)
424  __attribute__((nonnull));
425 /******************************************************************/
430 UNIV_INTERN
431 ibool
432 sync_thread_reset_level(
433 /*====================*/
434  void* latch);
435 /******************************************************************/
439 UNIV_INTERN
440 void*
441 sync_thread_levels_contains(
442 /*========================*/
443  ulint level);
445 /******************************************************************/
448 UNIV_INTERN
449 void*
450 sync_thread_levels_nonempty_gen(
451 /*============================*/
452  ibool dict_mutex_allowed)
454  __attribute__((warn_unused_result));
455 /******************************************************************/
458 #define sync_thread_levels_empty_except_dict() \
459  (!sync_thread_levels_nonempty_gen(TRUE))
460 /******************************************************************/
464 UNIV_INTERN
465 void*
466 sync_thread_levels_nonempty_trx(
467 /*============================*/
468  ibool has_search_latch)
471  __attribute__((warn_unused_result));
472 
473 /******************************************************************/
475 UNIV_INTERN
476 void
477 mutex_get_debug_info(
478 /*=================*/
479  ib_mutex_t* mutex,
480  const char** file_name,
481  ulint* line,
482  os_thread_id_t* thread_id);
484 /******************************************************************/
487 UNIV_INTERN
488 ulint
489 mutex_n_reserved(void);
490 /*==================*/
491 #endif /* UNIV_SYNC_DEBUG */
492 /******************************************************************/
495 UNIV_INLINE
496 lock_word_t
498 /*================*/
499  const ib_mutex_t* mutex);
500 #ifdef UNIV_SYNC_DEBUG
501 /******************************************************************/
505 UNIV_INLINE
506 ulint
507 mutex_get_waiters(
508 /*==============*/
509  const ib_mutex_t* mutex);
510 #endif /* UNIV_SYNC_DEBUG */
511 
512 /*
513  LATCHING ORDER WITHIN THE DATABASE
514  ==================================
515 
516 The mutex or latch in the central memory object, for instance, a rollback
517 segment object, must be acquired before acquiring the latch or latches to
518 the corresponding file data structure. In the latching order below, these
519 file page object latches are placed immediately below the corresponding
520 central memory object latch or mutex.
521 
522 Synchronization object Notes
523 ---------------------- -----
524 
525 Dictionary mutex If we have a pointer to a dictionary
526 | object, e.g., a table, it can be
527 | accessed without reserving the
528 | dictionary mutex. We must have a
529 | reservation, a memoryfix, to the
530 | appropriate table object in this case,
531 | and the table must be explicitly
532 | released later.
533 V
534 Dictionary header
535 |
536 V
537 Secondary index tree latch The tree latch protects also all
538 | the B-tree non-leaf pages. These
539 V can be read with the page only
540 Secondary index non-leaf bufferfixed to save CPU time,
541 | no s-latch is needed on the page.
542 | Modification of a page requires an
543 | x-latch on the page, however. If a
544 | thread owns an x-latch to the tree,
545 | it is allowed to latch non-leaf pages
546 | even after it has acquired the fsp
547 | latch.
548 V
549 Secondary index leaf The latch on the secondary index leaf
550 | can be kept while accessing the
551 | clustered index, to save CPU time.
552 V
553 Clustered index tree latch To increase concurrency, the tree
554 | latch is usually released when the
555 | leaf page latch has been acquired.
556 V
557 Clustered index non-leaf
558 |
559 V
560 Clustered index leaf
561 |
562 V
563 Transaction system header
564 |
565 V
566 Transaction undo mutex The undo log entry must be written
567 | before any index page is modified.
568 | Transaction undo mutex is for the undo
569 | logs the analogue of the tree latch
570 | for a B-tree. If a thread has the
571 | trx undo mutex reserved, it is allowed
572 | to latch the undo log pages in any
573 | order, and also after it has acquired
574 | the fsp latch.
575 V
576 Rollback segment mutex The rollback segment mutex must be
577 | reserved, if, e.g., a new page must
578 | be added to an undo log. The rollback
579 | segment and the undo logs in its
580 | history list can be seen as an
581 | analogue of a B-tree, and the latches
582 | reserved similarly, using a version of
583 | lock-coupling. If an undo log must be
584 | extended by a page when inserting an
585 | undo log record, this corresponds to
586 | a pessimistic insert in a B-tree.
587 V
588 Rollback segment header
589 |
590 V
591 Purge system latch
592 |
593 V
594 Undo log pages If a thread owns the trx undo mutex,
595 | or for a log in the history list, the
596 | rseg mutex, it is allowed to latch
597 | undo log pages in any order, and even
598 | after it has acquired the fsp latch.
599 | If a thread does not have the
600 | appropriate mutex, it is allowed to
601 | latch only a single undo log page in
602 | a mini-transaction.
603 V
604 File space management latch If a mini-transaction must allocate
605 | several file pages, it can do that,
606 | because it keeps the x-latch to the
607 | file space management in its memo.
608 V
609 File system pages
610 |
611 V
612 lock_sys_wait_mutex Mutex protecting lock timeout data
613 |
614 V
615 lock_sys_mutex Mutex protecting lock_sys_t
616 |
617 V
618 trx_sys->mutex Mutex protecting trx_sys_t
619 |
620 V
621 Threads mutex Background thread scheduling mutex
622 |
623 V
624 query_thr_mutex Mutex protecting query threads
625 |
626 V
627 trx_mutex Mutex protecting trx_t fields
628 |
629 V
630 Search system mutex
631 |
632 V
633 Buffer pool mutex
634 |
635 V
636 Log mutex
637 |
638 Any other latch
639 |
640 V
641 Memory pool mutex */
642 
643 /* Latching order levels. If you modify these, you have to also update
644 sync_thread_add_level(). */
645 
646 /* User transaction locks are higher than any of the latch levels below:
647 no latches are allowed when a thread goes to wait for a normal table
648 or row lock! */
649 #define SYNC_USER_TRX_LOCK 9999
650 #define SYNC_NO_ORDER_CHECK 3000 /* this can be used to suppress
651  latching order checking */
652 #define SYNC_LEVEL_VARYING 2000 /* Level is varying. Only used with
653  buffer pool page locks, which do not
654  have a fixed level, but instead have
655  their level set after the page is
656  locked; see e.g.
657  ibuf_bitmap_get_map_page(). */
658 #define SYNC_TRX_I_S_RWLOCK 1910 /* Used for
659  trx_i_s_cache_t::rw_lock */
660 #define SYNC_TRX_I_S_LAST_READ 1900 /* Used for
661  trx_i_s_cache_t::last_read_mutex */
662 #define SYNC_FILE_FORMAT_TAG 1200 /* Used to serialize access to the
663  file format tag */
664 #define SYNC_DICT_OPERATION 1010 /* table create, drop, etc. reserve
665  this in X-mode; implicit or backround
666  operations purge, rollback, foreign
667  key checks reserve this in S-mode */
668 #define SYNC_FTS_CACHE 1005 /* FTS cache rwlock */
669 #define SYNC_DICT 1000
670 #define SYNC_DICT_AUTOINC_MUTEX 999
671 #define SYNC_STATS_AUTO_RECALC 997
672 #define SYNC_DICT_HEADER 995
673 #define SYNC_IBUF_HEADER 914
674 #define SYNC_IBUF_PESS_INSERT_MUTEX 912
675 /*-------------------------------*/
676 #define SYNC_INDEX_TREE 900
677 #define SYNC_TREE_NODE_NEW 892
678 #define SYNC_TREE_NODE_FROM_HASH 891
679 #define SYNC_TREE_NODE 890
680 #define SYNC_PURGE_LATCH 800
681 #define SYNC_TRX_UNDO 700
682 #define SYNC_RSEG 600
683 #define SYNC_RSEG_HEADER_NEW 591
684 #define SYNC_RSEG_HEADER 590
685 #define SYNC_TRX_UNDO_PAGE 570
686 #define SYNC_EXTERN_STORAGE 500
687 #define SYNC_FSP 400
688 #define SYNC_FSP_PAGE 395
689 /*------------------------------------- Change buffer headers */
690 #define SYNC_IBUF_MUTEX 370 /* ibuf_mutex */
691 /*------------------------------------- Change buffer tree */
692 #define SYNC_IBUF_INDEX_TREE 360
693 #define SYNC_IBUF_TREE_NODE_NEW 359
694 #define SYNC_IBUF_TREE_NODE 358
695 #define SYNC_IBUF_BITMAP_MUTEX 351
696 #define SYNC_IBUF_BITMAP 350
697 /*------------------------------------- Change log for online create index */
698 #define SYNC_INDEX_ONLINE_LOG 340
699 /*------------------------------------- MySQL query cache mutex */
700 /*------------------------------------- MySQL binlog mutex */
701 /*-------------------------------*/
702 #define SYNC_LOCK_WAIT_SYS 300
703 #define SYNC_LOCK_SYS 299
704 #define SYNC_TRX_SYS 298
705 #define SYNC_TRX 297
706 #define SYNC_THREADS 295
707 #define SYNC_REC_LOCK 294
708 #define SYNC_TRX_SYS_HEADER 290
709 #define SYNC_PURGE_QUEUE 200
710 #define SYNC_LOG 170
711 #define SYNC_LOG_FLUSH_ORDER 147
712 #define SYNC_RECV 168
713 #define SYNC_FTS_CACHE_INIT 166 /* Used for FTS cache initialization */
714 #define SYNC_FTS_BG_THREADS 165
715 #define SYNC_FTS_OPTIMIZE 164 // FIXME: is this correct number, test
716 #define SYNC_WORK_QUEUE 162
717 #define SYNC_SEARCH_SYS 160 /* NOTE that if we have a memory
718  heap that can be extended to the
719  buffer pool, its logical level is
720  SYNC_SEARCH_SYS, as memory allocation
721  can call routines there! Otherwise
722  the level is SYNC_MEM_HASH. */
723 #define SYNC_BUF_POOL 150 /* Buffer pool mutex */
724 #define SYNC_BUF_PAGE_HASH 149 /* buf_pool->page_hash rw_lock */
725 #define SYNC_BUF_BLOCK 146 /* Block mutex */
726 #define SYNC_BUF_FLUSH_LIST 145 /* Buffer flush list mutex */
727 #define SYNC_DOUBLEWRITE 140
728 #define SYNC_ANY_LATCH 135
729 #define SYNC_MEM_HASH 131
730 #define SYNC_MEM_POOL 130
731 
732 /* Codes used to designate lock operations */
733 #define RW_LOCK_NOT_LOCKED 350
734 #define RW_LOCK_EX 351
735 #define RW_LOCK_EXCLUSIVE 351
736 #define RW_LOCK_SHARED 352
737 #define RW_LOCK_WAIT_EX 353
738 #define SYNC_MUTEX 354
740 /* NOTE! The structure appears here only for the compiler to know its size.
741 Do not use its fields directly! The structure used in the spin lock
742 implementation of a mutual exclusion semaphore. */
743 
745 struct ib_mutex_t {
746  os_event_t event;
747  volatile lock_word_t lock_word;
751 #if !defined(HAVE_ATOMIC_BUILTINS)
753  os_fast_mutex;
755 #endif
756  ulint waiters;
760  UT_LIST_NODE_T(ib_mutex_t) list;
762 #ifdef UNIV_SYNC_DEBUG
763  const char* file_name;
764  ulint line;
765  ulint level;
766 #endif /* UNIV_SYNC_DEBUG */
767  const char* cfile_name;
768  ulint cline;
769  ulong count_os_wait;
770 #ifdef UNIV_DEBUG
771 
773 # define MUTEX_MAGIC_N 979585UL
775  os_thread_id_t thread_id;
777  ulint magic_n;
778  const char* cmutex_name;
779  ulint ib_mutex_type;
780 #endif /* UNIV_DEBUG */
781 #ifdef UNIV_PFS_MUTEX
782  struct PSI_mutex* pfs_psi;
784 #endif
785 };
786 
791 #define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds
792 
794 extern ib_int64_t mutex_exit_count;
795 
796 #ifdef UNIV_SYNC_DEBUG
797 
798 extern ibool sync_order_checks_on;
799 #endif /* UNIV_SYNC_DEBUG */
800 
802 extern ibool sync_initialized;
803 
805 typedef UT_LIST_BASE_NODE_T(ib_mutex_t) ut_list_base_node_t;
807 extern ut_list_base_node_t mutex_list;
808 
811 
812 #ifndef HAVE_ATOMIC_BUILTINS
813 /**********************************************************/
815 UNIV_INLINE
816 void
818 /*=====================*/
819  ib_mutex_t* mutex,
821  volatile ulint* var,
823  ulint delta);
824 /**********************************************************/
826 UNIV_INLINE
827 void
829 /*=====================*/
830  ib_mutex_t* mutex,
832  volatile ulint* var,
834  ulint delta);
835 #endif /* !HAVE_ATOMIC_BUILTINS */
836 
837 #ifndef UNIV_NONINL
838 #include "sync0sync.ic"
839 #endif
840 
841 #endif