~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/srv/srv0srv.c

Tags: innodb-plugin-1.0.3
InnoDB Plugin 1.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2008, Google Inc.
 
5
 
 
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.
 
11
 
 
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.
 
15
 
 
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.
 
19
 
 
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., 59 Temple
 
22
Place, Suite 330, Boston, MA 02111-1307 USA
 
23
 
 
24
*****************************************************************************/
 
25
 
1
26
/******************************************************
2
27
The database server main program
3
28
 
20
45
Another possibility could be to use some very fast user space
21
46
thread library. This might confuse NT though.
22
47
 
23
 
(c) 1995 Innobase Oy
24
 
 
25
48
Created 10/8/1995 Heikki Tuuri
26
49
*******************************************************/
 
50
 
27
51
/* Dummy comment */
28
52
#include "srv0srv.h"
29
53
 
136
160
collation */
137
161
UNIV_INTERN const byte* srv_latin1_ordering;
138
162
 
 
163
/* use os/external memory allocator */
 
164
UNIV_INTERN my_bool     srv_use_sys_malloc      = TRUE;
139
165
/* requested size in kilobytes */
140
 
UNIV_INTERN ulong       srv_buf_pool_size       = ULINT_MAX;
 
166
UNIV_INTERN ulint       srv_buf_pool_size       = ULINT_MAX;
141
167
/* previously requested size */
142
 
UNIV_INTERN ulong       srv_buf_pool_old_size;
 
168
UNIV_INTERN ulint       srv_buf_pool_old_size;
143
169
/* current size in kilobytes */
144
 
UNIV_INTERN ulong       srv_buf_pool_curr_size  = 0;
 
170
UNIV_INTERN ulint       srv_buf_pool_curr_size  = 0;
145
171
/* size in bytes */
146
172
UNIV_INTERN ulint       srv_mem_pool_size       = ULINT_MAX;
147
173
UNIV_INTERN ulint       srv_lock_table_size     = ULINT_MAX;
256
282
 
257
283
/* this mutex protects srv_conc data structures */
258
284
UNIV_INTERN os_fast_mutex_t     srv_conc_mutex;
259
 
/* number of OS threads currently inside InnoDB; it is not an error if
260
 
this drops temporarily below zero because we do not demand that every
261
 
thread increments this, but a thread waiting for a lock decrements
262
 
this temporarily */
 
285
/* number of transactions that have declared_to_be_inside_innodb set.
 
286
It used to be a non-error for this value to drop below zero temporarily.
 
287
This is no longer true. We'll, however, keep the lint datatype to add
 
288
assertions to catch any corner cases that we may have missed. */
263
289
UNIV_INTERN lint        srv_conc_n_threads      = 0;
264
290
/* number of OS threads waiting in the FIFO for a permission to enter
265
291
InnoDB */
941
967
srv_general_init(void)
942
968
/*==================*/
943
969
{
 
970
        ut_mem_init();
944
971
        os_sync_init();
945
972
        sync_init();
946
973
        mem_init(srv_mem_pool_size);
999
1026
                return;
1000
1027
        }
1001
1028
 
 
1029
        ut_ad(srv_conc_n_threads >= 0);
 
1030
 
1002
1031
        if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
1003
1032
 
1004
1033
                srv_conc_n_threads++;
1125
1154
                return;
1126
1155
        }
1127
1156
 
 
1157
        ut_ad(srv_conc_n_threads >= 0);
 
1158
 
1128
1159
        os_fast_mutex_lock(&srv_conc_mutex);
1129
1160
 
1130
1161
        srv_conc_n_threads++;
1146
1177
{
1147
1178
        srv_conc_slot_t*        slot    = NULL;
1148
1179
 
1149
 
        if (UNIV_LIKELY(!srv_thread_concurrency)) {
1150
 
 
1151
 
                return;
1152
 
        }
1153
 
 
1154
1180
        if (trx->mysql_thd != NULL
1155
1181
            && thd_is_replication_slave_thread(trx->mysql_thd)) {
1156
1182
 
1164
1190
 
1165
1191
        os_fast_mutex_lock(&srv_conc_mutex);
1166
1192
 
 
1193
        ut_ad(srv_conc_n_threads > 0);
1167
1194
        srv_conc_n_threads--;
1168
1195
        trx->declared_to_be_inside_innodb = FALSE;
1169
1196
        trx->n_tickets_to_enter_innodb = 0;
1457
1484
 
1458
1485
        ut_a(trx->dict_operation_lock_mode == 0);
1459
1486
 
1460
 
        /* Wait for the release */
 
1487
        /* Suspend this thread and wait for the event. */
1461
1488
 
1462
1489
        os_event_wait(event);
1463
1490
 
 
1491
        /* After resuming, reacquire the data dictionary latch if
 
1492
        necessary. */
 
1493
 
1464
1494
        switch (had_dict_lock) {
1465
1495
        case RW_S_LATCH:
1466
1496
                row_mysql_freeze_data_dictionary(trx);
1817
1847
        export_vars.innodb_buffer_pool_pages_misc = buf_pool->curr_size
1818
1848
                - UT_LIST_GET_LEN(buf_pool->LRU)
1819
1849
                - UT_LIST_GET_LEN(buf_pool->free);
 
1850
#ifdef HAVE_GCC_ATOMIC_BUILTINS
 
1851
        export_vars.innodb_have_atomic_builtins = 1;
 
1852
#else
 
1853
        export_vars.innodb_have_atomic_builtins = 0;
 
1854
#endif
1820
1855
        export_vars.innodb_page_size = UNIV_PAGE_SIZE;
1821
1856
        export_vars.innodb_log_waits = srv_log_waits;
1822
1857
        export_vars.innodb_os_log_written = srv_os_log_written;