[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#3950) sched_yield() considered harmful



At 07:24 PM 8/17/2005, bernie@develer.com wrote:
>Full_Name: Bernardo Innocenti
>Version: 2.2.26 to 2.3.5, possibly others
>OS: Linux
>URL: ftp://ftp.openldap.org/incoming/
>Submission from: (NULL) (151.38.19.110)
>
>
>Calling sched_yield() makes slapd slow down considerably
>under load since kernel 2.6.
>
>See:
>
>  http://www.ussg.iu.edu/hypermail/linux/kernel/0508.2/0516.html

I note that pthread_yield is not actually part of the
POSIX Thread standard.   It's part of the old DCE Thread
interface, which was deprecated in favor of the POSIX
Thread standard.  No modern threaded application should
be calling pthread_yield(3).  sched_yield(3) should do
the right thing.

Guess we'll have to consider this yet another Linux
pthread implementation quirk.  Now, the fun thing would
be to devise a configure test to determine that the
deprecated pthread_yield(3) interface should be used
(without resorting to #ifdef linux or equivalent).

Oh, BTW, sched_yield(3p) on my SuSE Linux box says:
       The  sched_yield() function shall force the running thread
       to relinquish the processor until  it  again  becomes  the
       head of its thread list. It takes no arguments.

Kurt