Commit 1c3442e2 authored by Mikael Ronstrom's avatar Mikael Ronstrom

Added a PAUSE instruction to the SPIN loop

according to recommendation from Intel.
parent cad9fe0c
...@@ -2342,6 +2342,17 @@ fi ...@@ -2342,6 +2342,17 @@ fi
fi fi
#---END: #---END:
#Check for x86 PAUSE instruction
AC_MSG_CHECKING("for x86 PAUSE instruction")
AC_TRY_COMPILE(
[],
[{__asm__ __volatile__ ("pause");}],
x86_pause_exists=yes, x86_pause_exists=no)
if test "$x86_pause_exists" = "yes"
then
AC_DEFINE([HAVE_PAUSE_INSTRUCTION], [1], [Does x86 PAUSE instruction exist])
fi
# Check if pthread_attr_setscope() exists # Check if pthread_attr_setscope() exists
AC_CACHE_CHECK("for pthread_attr_setscope", mysql_cv_pthread_attr_setscope, AC_CACHE_CHECK("for pthread_attr_setscope", mysql_cv_pthread_attr_setscope,
AC_TRY_LINK( AC_TRY_LINK(
......
...@@ -17,6 +17,19 @@ Created 1/20/1994 Heikki Tuuri ...@@ -17,6 +17,19 @@ Created 1/20/1994 Heikki Tuuri
typedef time_t ib_time_t; typedef time_t ib_time_t;
#ifdef HAVE_PAUSE_INSTRUCTION
#define PAUSE_INSTRUCTION(volatile_var) {__asm__ __volatile__ ("pause");}
#elif
#ifdef UNIV_SYNC_ATOMIC
#define PAUSE_INSTRUCTION(volatile_var) \
{ \
os_compare_and_swap(volatile_var, 0, 1); \
}
#elif
#define PAUSE_INSTRUCTION(volatile_var)
#endif
#endif
/************************************************************ /************************************************************
Gets the high 32 bits in a ulint. That is makes a shift >> 32, Gets the high 32 bits in a ulint. That is makes a shift >> 32,
but since there seem to be compiler bugs in both gcc and Visual C++, but since there seem to be compiler bugs in both gcc and Visual C++,
......
...@@ -336,11 +336,13 @@ ut_delay( ...@@ -336,11 +336,13 @@ ut_delay(
ulint delay) /* in: delay in microseconds on 100 MHz Pentium */ ulint delay) /* in: delay in microseconds on 100 MHz Pentium */
{ {
ulint i, j; ulint i, j;
volatile lint volatile_var;
j = 0; j = 0;
for (i = 0; i < delay * 50; i++) { for (i = 0; i < delay * 50; i++) {
j += i; j += i;
PAUSE_INSTRUCTION(&volatile_var);
} }
if (ut_always_false) { if (ut_always_false) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment