summaryrefslogtreecommitdiff
path: root/mysys/thr_mutex.c
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-11-19 16:54:45 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-11-26 11:34:17 +0400
commite562b43222621b75516414e4f7b686031b01461a (patch)
tree2937524706b32ef0cddfb7dff8efee4cf09b9c8e /mysys/thr_mutex.c
parente4212898a649fc37869e1e678c6172d3c88c6185 (diff)
downloadmariadb-git-e562b43222621b75516414e4f7b686031b01461a.tar.gz
MDEV-8111 - remove "fast mutexes"
They aren't faster than normal mutexes. They're disabled by default for years, so de facto it's dead code, never used.
Diffstat (limited to 'mysys/thr_mutex.c')
-rw-r--r--mysys/thr_mutex.c86
1 files changed, 0 insertions, 86 deletions
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 18af5f47b10..4d6abd4ba66 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -105,8 +105,6 @@ void my_mutex_init()
#if defined(SAFE_MUTEX_DEFINED)
safe_mutex_global_init();
-#elif defined(MY_PTHREAD_FASTMUTEX)
- fastmutex_global_init();
#endif
}
@@ -838,88 +836,4 @@ static void print_deadlock_warning(safe_mutex_t *new_mutex,
DBUG_VOID_RETURN;
}
-#elif defined(MY_PTHREAD_FASTMUTEX) /* !SAFE_MUTEX_DEFINED */
-
-static ulong mutex_delay(ulong delayloops)
-{
- ulong i;
- volatile ulong j;
-
- j = 0;
-
- for (i = 0; i < delayloops * 50; i++)
- j += i;
-
- return(j);
-}
-
-#define MY_PTHREAD_FASTMUTEX_SPINS 8
-#define MY_PTHREAD_FASTMUTEX_DELAY 4
-
-static int cpu_count= 0;
-
-int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
- const pthread_mutexattr_t *attr)
-{
- if ((cpu_count > 1) && (attr == MY_MUTEX_INIT_FAST))
- mp->spins= MY_PTHREAD_FASTMUTEX_SPINS;
- else
- mp->spins= 0;
- mp->rng_state= 1;
- return pthread_mutex_init(&mp->mutex, attr);
-}
-
-/**
- Park-Miller random number generator. A simple linear congruential
- generator that operates in multiplicative group of integers modulo n.
-
- x_{k+1} = (x_k g) mod n
-
- Popular pair of parameters: n = 2^32 − 5 = 4294967291 and g = 279470273.
- The period of the generator is about 2^31.
- Largest value that can be returned: 2147483646 (RAND_MAX)
-
- Reference:
-
- S. K. Park and K. W. Miller
- "Random number generators: good ones are hard to find"
- Commun. ACM, October 1988, Volume 31, No 10, pages 1192-1201.
-*/
-
-static double park_rng(my_pthread_fastmutex_t *mp)
-{
- mp->rng_state= ((my_ulonglong)mp->rng_state * 279470273U) % 4294967291U;
- return (mp->rng_state / 2147483647.0);
-}
-
-int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp)
-{
- int res;
- uint i;
- uint maxdelay= MY_PTHREAD_FASTMUTEX_DELAY;
-
- for (i= 0; i < mp->spins; i++)
- {
- res= pthread_mutex_trylock(&mp->mutex);
-
- if (res == 0)
- return 0;
-
- if (res != EBUSY)
- return res;
-
- mutex_delay(maxdelay);
- maxdelay += park_rng(mp) * MY_PTHREAD_FASTMUTEX_DELAY + 1;
- }
- return pthread_mutex_lock(&mp->mutex);
-}
-
-
-void fastmutex_global_init(void)
-{
-#ifdef _SC_NPROCESSORS_CONF
- cpu_count= sysconf(_SC_NPROCESSORS_CONF);
#endif
-}
-
-#endif /* defined(MY_PTHREAD_FASTMUTEX) && defined(SAFE_MUTEX_DEFINED) */