[lkml]   [2006]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: sched_yield() makes OpenLDAP slow

    Robert Hancock wrote:
    > Howard Chu wrote:
    > > POSIX requires a reschedule to occur, as noted here:
    > >
    > No, it doesn't:
    > >
    > > The relevant SUSv3 text is here
    > >

    > "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.

    No, because the thread that just released the mutex is obviously not one
    of the threads blocked on the mutex. When a mutex is unlocked, one of
    the *waiting* threads at the time of the unlock must acquire it, and the
    scheduling policy can determine that. But the thread the released the
    mutex is not one of the waiting threads, and is not eligible for

    > > I suppose if pthread_mutex_unlock() actually behaved correctly we
    > > 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
    > Home Page:

    -- Howard Chu
    Chief Architect, Symas Corp.
    Director, Highland Sun
    OpenLDAP Core Team

    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: 2006-01-25 14:54    [W:0.020 / U:217.824 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site