Re: sched_yield() makes OpenLDAP slow
From: Robert Hancock
Date: Sat Jan 14 2006 - 17:45:51 EST
Howard Chu wrote:
POSIX requires a reschedule to occur, as noted here:
http://blog.firetree.net/2005/06/22/thread-yield-after-mutex-unlock/
No, it doesn't:
The relevant SUSv3 text is here
http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutex_unlock.html
"If there are threads blocked on the mutex object referenced by mutex
when pthread_mutex_unlock() is called, resulting in the mutex becoming
available, the scheduling policy shall determine which thread shall
acquire the mutex."
This says nothing about requiring a reschedule. The "scheduling policy"
can well decide that the thread which just released the mutex can
re-acquire it.
I suppose if pthread_mutex_unlock() actually behaved correctly we could
remove the other sched_yield() hacks that didn't belong there in the
first place and go on our merry way.
Generally, needing to implement hacks like this is a sign that there are
problems with the synchronization design of the code (like a mutex which
has excessive contention). Programs should not rely on the scheduling
behavior of the kernel for proper operation when that behavior is not
defined.
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@xxxxxxxxxxxxx
Home Page: http://www.roberthancock.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/