Skip to contentSkip to conversation

sched_yield() makes OpenLDAP slow

DISCUSSION Robert Hancock 1 participant 1 message Jan 14, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 2 lines · Howard Chu

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:

Quoted 3 lines

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.

Quoted 1 line

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.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/