~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/sync0sync.h

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "os0sync.h"
18
18
#include "sync0arr.h"
19
19
 
 
20
#ifndef UNIV_HOTBACKUP
 
21
extern bool     timed_mutexes;
 
22
#endif /* UNIV_HOTBACKUP */
20
23
 
21
24
/**********************************************************************
22
25
Initializes the synchronization data structures. */
23
 
UNIV_INTERN
 
26
 
24
27
void
25
28
sync_init(void);
26
29
/*===========*/
27
30
/**********************************************************************
28
31
Frees the resources in synchronization data structures. */
29
 
UNIV_INTERN
 
32
 
30
33
void
31
34
sync_close(void);
32
35
/*===========*/
54
57
location (which must be appropriately aligned). The mutex is initialized
55
58
in the reset state. Explicit freeing of the mutex with mutex_free is
56
59
necessary only if the memory block containing it is freed. */
57
 
UNIV_INTERN
 
60
 
58
61
void
59
62
mutex_create_func(
60
63
/*==============*/
67
70
#endif /* UNIV_DEBUG */
68
71
        const char*     cfile_name,     /* in: file name where created */
69
72
        ulint           cline);         /* in: file line where created */
70
 
 
71
 
#undef mutex_free                       /* Fix for MacOS X */
72
 
 
73
73
/**********************************************************************
74
74
Calling this function is obligatory only if the memory buffer containing
75
75
the mutex is freed. Removes a mutex object from the mutex list. The mutex
76
76
is checked to be in the reset state. */
77
 
UNIV_INTERN
 
77
 
 
78
#undef mutex_free                       /* Fix for MacOS X */
78
79
void
79
80
mutex_free(
80
81
/*=======*/
84
85
corresponding function. */
85
86
 
86
87
#define mutex_enter(M)    mutex_enter_func((M), __FILE__, __LINE__)
 
88
/**********************************************************************
 
89
A noninlined function that reserves a mutex. In ha_innodb.cc we have disabled
 
90
inlining of InnoDB functions, and no inlined functions should be called from
 
91
there. That is why we need to duplicate the inlined function here. */
 
92
 
 
93
void
 
94
mutex_enter_noninline(
 
95
/*==================*/
 
96
        mutex_t*        mutex); /* in: mutex */
87
97
/******************************************************************
88
98
NOTE! The following macro should be used in mutex locking, not the
89
99
corresponding function. */
91
101
/* NOTE! currently same as mutex_enter! */
92
102
 
93
103
#define mutex_enter_fast(M)     mutex_enter_func((M), __FILE__, __LINE__)
 
104
#define mutex_enter_fast_func   mutex_enter_func;
94
105
/**********************************************************************
95
106
NOTE! Use the corresponding macro in the header file, not this function
96
107
directly. Locks a mutex for the current thread. If the mutex is reserved
113
124
NOTE! Use the corresponding macro in the header file, not this function
114
125
directly. Tries to lock the mutex for the current thread. If the lock is not
115
126
acquired immediately, returns with return value 1. */
116
 
UNIV_INTERN
 
127
 
117
128
ulint
118
129
mutex_enter_nowait_func(
119
130
/*====================*/
130
141
/*=======*/
131
142
        mutex_t*        mutex); /* in: pointer to mutex */
132
143
/**********************************************************************
 
144
Releases a mutex. */
 
145
 
 
146
void
 
147
mutex_exit_noninline(
 
148
/*=================*/
 
149
        mutex_t*        mutex); /* in: mutex */
 
150
/**********************************************************************
133
151
Returns TRUE if no mutex or rw-lock is currently locked.
134
152
Works only in the debug version. */
135
 
UNIV_INTERN
 
153
 
136
154
ibool
137
155
sync_all_freed(void);
138
156
/*================*/
140
158
FUNCTION PROTOTYPES FOR DEBUGGING */
141
159
/***********************************************************************
142
160
Prints wait info of the sync system. */
143
 
UNIV_INTERN
 
161
 
144
162
void
145
163
sync_print_wait_info(
146
164
/*=================*/
147
165
        FILE*   file);          /* in: file where to print */
148
166
/***********************************************************************
149
167
Prints info of the sync system. */
150
 
UNIV_INTERN
 
168
 
151
169
void
152
170
sync_print(
153
171
/*=======*/
155
173
#ifdef UNIV_DEBUG
156
174
/**********************************************************************
157
175
Checks that the mutex has been initialized. */
158
 
UNIV_INTERN
 
176
 
159
177
ibool
160
178
mutex_validate(
161
179
/*===========*/
163
181
/**********************************************************************
164
182
Checks that the current thread owns the mutex. Works only
165
183
in the debug version. */
166
 
UNIV_INTERN
 
184
 
167
185
ibool
168
186
mutex_own(
169
187
/*======*/
175
193
Adds a latch and its level in the thread level array. Allocates the memory
176
194
for the array if called first time for this OS thread. Makes the checks
177
195
against other latch levels stored in the array for this thread. */
178
 
UNIV_INTERN
 
196
 
179
197
void
180
198
sync_thread_add_level(
181
199
/*==================*/
184
202
                        SYNC_LEVEL_VARYING, nothing is done */
185
203
/**********************************************************************
186
204
Removes a latch from the thread level array if it is found there. */
187
 
UNIV_INTERN
 
205
 
188
206
ibool
189
207
sync_thread_reset_level(
190
208
/*====================*/
195
213
        void*   latch); /* in: pointer to a mutex or an rw-lock */
196
214
/**********************************************************************
197
215
Checks that the level array for the current thread is empty. */
198
 
UNIV_INTERN
 
216
 
199
217
ibool
200
218
sync_thread_levels_empty(void);
201
219
/*==========================*/
202
220
                        /* out: TRUE if empty */
203
221
/**********************************************************************
204
222
Checks that the level array for the current thread is empty. */
205
 
UNIV_INTERN
 
223
 
206
224
ibool
207
225
sync_thread_levels_empty_gen(
208
226
/*=========================*/
214
232
                                        allowed */
215
233
/**********************************************************************
216
234
Gets the debug information for a reserved mutex. */
217
 
UNIV_INTERN
 
235
 
218
236
void
219
237
mutex_get_debug_info(
220
238
/*=================*/
225
243
                                        the mutex */
226
244
/**********************************************************************
227
245
Counts currently reserved mutexes. Works only in the debug version. */
228
 
UNIV_INTERN
 
246
 
229
247
ulint
230
248
mutex_n_reserved(void);
231
249
/*==================*/
382
400
                                        their level set after the page is
383
401
                                        locked; see e.g.
384
402
                                        ibuf_bitmap_get_map_page(). */
385
 
#define SYNC_TRX_I_S_RWLOCK     1910    /* Used for
386
 
                                        trx_i_s_cache_t::rw_lock */
387
 
#define SYNC_TRX_I_S_LAST_READ  1900    /* Used for
388
 
                                        trx_i_s_cache_t::last_read_mutex */
389
 
#define SYNC_FILE_FORMAT_TAG    1200    /* Used to serialize access to the
390
 
                                        file format tag */
391
403
#define SYNC_DICT_OPERATION     1001    /* table create, drop, etc. reserve
392
404
                                        this in X-mode, implicit or backround
393
405
                                        operations purge, rollback, foreign
458
470
implementation of a mutual exclusion semaphore. */
459
471
 
460
472
struct mutex_struct {
461
 
        os_event_t      event;  /* Used by sync0arr.c for the wait queue */
462
473
        ulint   lock_word;      /* This ulint is the target of the atomic
463
474
                                test-and-set instruction in Win32 */
464
 
#if defined WIN32 && defined UNIV_CAN_USE_X86_ASSEMBLER
465
 
#else
 
475
#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
466
476
        os_fast_mutex_t
467
477
                os_fast_mutex;  /* In other systems we use this OS mutex
468
478
                                in place of lock_word */
493
503
        ulong           count_spin_loop; /* count of spin loops */
494
504
        ulong           count_spin_rounds; /* count of spin rounds */
495
505
        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 */
 
506
        uint64_t        lspent_time; /* mutex os_wait timer msec */
 
507
        uint64_t        lmax_spent_time; /* mutex os_wait timer msec */
498
508
        const char*     cmutex_name;/* mutex name */
499
509
        ulint           mutex_type;/* 0 - usual mutex 1 - rw_lock mutex  */
500
510
# endif /* UNIV_DEBUG */