[lkml]   [2005]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: sched_yield() makes OpenLDAP slow
Howard Chu writes:
> Nikita Danilov wrote:


> > What prevents transaction monitor from using, say, condition
> > variables to "yield cpu"? That would have an additional advantage of
> > blocking thread precisely until specific event occurs, instead of
> > blocking for some vague indeterminate load and platform dependent
> > amount of time.
> Condition variables offer no control over which thread is waken up.

When only one thread waits on a condition variable, which is exactly a
scenario involved, --sorry if I weren't clear enough-- condition signal
provides precise control over which thread is woken up.

> We're wandering into the design of the SleepyCat BerkeleyDB library
> here, and we don't exert any control over that either. BerkeleyDB
> doesn't appear to use pthread condition variables; it seems to construct
> its own synchronization mechanisms on top of mutexes (and yield calls).

That returns us to the core of the problem: sched_yield() is used to
implement a synchronization primitive and non-portable assumptions are
made about its behavior: SUS defines that after sched_yield() thread
ceases to run on the CPU "until it again becomes the head of its thread
list", and "thread list" discipline is only defined for real-time
scheduling policies. E.g.,

int sched_yield(void)
return 0;


int sched_yield(void)
return 0;

are both valid sched_yield() implementation for non-rt (SCHED_OTHER)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-08-20 15:28    [W:0.042 / U:33.748 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site