1SCHED_YIELD(2)             Linux Programmer's Manual            SCHED_YIELD(2)
2
3
4

NAME

6       sched_yield - yield the processor
7

SYNOPSIS

9       #include <sched.h>
10
11       int sched_yield(void);
12

DESCRIPTION

14       sched_yield()  causes  the  calling  thread to relinquish the CPU.  The
15       thread is moved to the end of the queue for its static priority  and  a
16       new thread gets to run.
17

RETURN VALUE

19       On  success,  sched_yield()  returns  0.  On error, -1 is returned, and
20       errno is set appropriately.
21

ERRORS

23       In the Linux implementation, sched_yield() always succeeds.
24

CONFORMING TO

26       POSIX.1-2001.
27

NOTES

29       If the calling thread is the only thread in the highest  priority  list
30       at that time, it will continue to run after a call to sched_yield().
31
32       POSIX  systems on which sched_yield() is available define _POSIX_PRIOR‐
33       ITY_SCHEDULING in <unistd.h>.
34
35       Strategic calls to sched_yield()  can  improve  performance  by  giving
36       other  threads  or  processes  a chance to run when (heavily) contended
37       resources (e.g., mutexes) have been  released  by  the  caller.   Avoid
38       calling  sched_yield()  unnecessarily  or  inappropriately  (e.g., when
39       resources needed by other schedulable threads are  still  held  by  the
40       caller),  since  doing  so will result in unnecessary context switches,
41       which will degrade system performance.
42

SEE ALSO

44       sched_setscheduler(2) for a description of Linux scheduling.
45
46       Programming for the real  world  -  POSIX.4  by  Bill  O.  Gallmeister,
47       O'Reilly & Associates, Inc., ISBN 1-56592-074-0
48

COLOPHON

50       This  page  is  part of release 3.22 of the Linux man-pages project.  A
51       description of the project, and information about reporting  bugs,  can
52       be found at http://www.kernel.org/doc/man-pages/.
53
54
55
56Linux                             2008-10-18                    SCHED_YIELD(2)
Impressum