Commit e6765fdc authored by heikki@donna.mysql.fi's avatar heikki@donna.mysql.fi

sync0sync.c Fix the infinite spin on FreeBSD

os0thread.c	Use pthread_yield instead of os_thread_sleep(0)
parent 09fa56ff
mwagner@evoq.mwagner.org heikki@donna.mysql.fi
jcole@abel.spaceapes.com
monty@donna.mysql.fi
sasha@mysql.sashanet.com
...@@ -122,7 +122,7 @@ os_thread_yield(void) ...@@ -122,7 +122,7 @@ os_thread_yield(void)
#ifdef __WIN__ #ifdef __WIN__
Sleep(0); Sleep(0);
#else #else
os_thread_sleep(0); pthread_yield();
#endif #endif
} }
......
...@@ -366,6 +366,15 @@ spin_loop: ...@@ -366,6 +366,15 @@ spin_loop:
return; return;
} }
/* We may end up with a situation where lock_word is
0 but the OS fast mutex is still reserved. On FreeBSD
the OS does not seem to schedule a thread which is constantly
calling pthread_mutex_trylock (in mutex_test_and_set
implementation). Then we could end up spinning here indefinitely.
The following 'i++' stops this infinite spin. */
i++;
if (i < SYNC_SPIN_ROUNDS) { if (i < SYNC_SPIN_ROUNDS) {
......
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