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
jcole@abel.spaceapes.com
monty@donna.mysql.fi
sasha@mysql.sashanet.com
heikki@donna.mysql.fi
......@@ -122,7 +122,7 @@ os_thread_yield(void)
#ifdef __WIN__
Sleep(0);
#else
os_thread_sleep(0);
pthread_yield();
#endif
}
......
......@@ -367,6 +367,15 @@ spin_loop:
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) {
goto spin_loop;
......
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