diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index f72dcbc82bf..3b78af9fc7b 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -18,15 +18,16 @@ Created 1/20/1994 Heikki Tuuri typedef time_t ib_time_t; #ifdef HAVE_PAUSE_INSTRUCTION -#define PAUSE_INSTRUCTION(volatile_var) {__asm__ __volatile__ ("pause");} +#define PAUSE_INSTRUCTION() {__asm__ __volatile__ ("pause");} #else #ifdef UNIV_SYNC_ATOMIC -#define PAUSE_INSTRUCTION(volatile_var) \ +#define PAUSE_INSTRUCTION() \ { \ + volatile lint volatile_var; os_compare_and_swap(volatile_var, 0, 1); \ } #else -#define PAUSE_INSTRUCTION(volatile_var) +#define PAUSE_INSTRUCTION() #endif #endif diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 23a20393939..20f5db80676 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -1063,6 +1063,7 @@ ulong srv_max_purge_lag = 0; Puts an OS thread to wait if there are too many concurrent threads (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */ +#ifdef UNIV_SYNC_ATOMIC static void inc_srv_conc_n_threads(lint *n_threads) { @@ -1074,6 +1075,7 @@ dec_srv_conc_n_threads() { os_atomic_increment(&srv_conc_n_threads, -1); } +#endif static void print_already_in_error(trx_t* trx) @@ -1087,6 +1089,7 @@ print_already_in_error(trx_t* trx) return; } +#ifdef UNIV_SYNC_ATOMIC static void enter_innodb_with_tickets(trx_t* trx) { @@ -1108,7 +1111,7 @@ srv_conc_enter_innodb_timer_based(trx_t* trx) retry: if (srv_conc_n_threads < (lint) srv_thread_concurrency) { inc_srv_conc_n_threads(&conc_n_threads); - if (conc_n_threads <= srv_thread_concurrency) { + if (conc_n_threads <= (lint) srv_thread_concurrency) { enter_innodb_with_tickets(trx); return; } @@ -1147,6 +1150,7 @@ srv_conc_exit_innodb_timer_based(trx_t* trx) trx->n_tickets_to_enter_innodb = 0; return; } +#endif void srv_conc_enter_innodb( @@ -1315,7 +1319,6 @@ srv_conc_force_enter_innodb( trx_t* trx) /* in: transaction object associated with the thread */ { - lint conc_n_threads; if (UNIV_LIKELY(!srv_thread_concurrency)) { @@ -1324,6 +1327,8 @@ srv_conc_force_enter_innodb( #ifdef UNIV_SYNC_ATOMIC if (srv_thread_concurrency_timer_based) { + lint conc_n_threads; + inc_srv_conc_n_threads(&conc_n_threads); trx->declared_to_be_inside_innodb = TRUE; trx->n_tickets_to_enter_innodb = 1; diff --git a/storage/innobase/ut/ut0ut.c b/storage/innobase/ut/ut0ut.c index 9b45fe279a2..4a0bd802404 100644 --- a/storage/innobase/ut/ut0ut.c +++ b/storage/innobase/ut/ut0ut.c @@ -336,13 +336,12 @@ ut_delay( ulint delay) /* in: delay in microseconds on 100 MHz Pentium */ { ulint i, j; - volatile lint volatile_var; j = 0; for (i = 0; i < delay * 50; i++) { + PAUSE_INSTRUCTION(); j += i; - PAUSE_INSTRUCTION(&volatile_var); } if (ut_always_false) {