lkml.org 
[lkml]   [2008]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: sched_yield() options
david@lang.hm wrote:
> I've seen a lot of discussion about how sched_yield is abused by
> applications. I'm working with a developer on one application that looks
> like it's falling into this same trap (mutexes between threads and using
> sched_yield (or more precisely pthread_yield()) to let other threads get
> the lock)
>
> however I've been having a hard time tracking down the appropriate
> discussions to forward on to the developer (both for why what he's doing
> is bad, and for what he should be doing instead)
>
> could someone point out appropriate mailing list threads, or other
> documentation for this?

The main reason why it's bad is that the behaviour of yield() for
SCHED_OTHER tasks is not strongly defined in the spec. Depending on
OS/version you may yield to all other SCHED_OTHER tasks, only one task,
or anywhere in between.

Also, yield() gives the kernel no information on why it's yielding and
to whom, so it is impossible for the kernel to make the optimal decision
in all cases.

For more information, try searching the linux.kernel google groups
archive. There's a thread called "yield API" with some information.
See also " CFS: some bad numbers with Java/database threading [FIXED]".

Chris


\
 
 \ /
  Last update: 2008-10-21 01:05    [W:0.048 / U:0.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site