mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
Added a PAUSE instruction to the SPIN loop
according to recommendation from Intel.
This commit is contained in:
parent
abae8a2c9c
commit
8e2b83e733
3 changed files with 26 additions and 0 deletions
11
configure.in
11
configure.in
|
@ -2342,6 +2342,17 @@ fi
|
|||
fi
|
||||
#---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
|
||||
AC_CACHE_CHECK("for pthread_attr_setscope", mysql_cv_pthread_attr_setscope,
|
||||
AC_TRY_LINK(
|
||||
|
|
|
@ -17,6 +17,19 @@ Created 1/20/1994 Heikki Tuuri
|
|||
|
||||
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,
|
||||
but since there seem to be compiler bugs in both gcc and Visual C++,
|
||||
|
|
|
@ -336,11 +336,13 @@ 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++) {
|
||||
j += i;
|
||||
PAUSE_INSTRUCTION(&volatile_var);
|
||||
}
|
||||
|
||||
if (ut_always_false) {
|
||||
|
|
Loading…
Reference in a new issue