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, POSIX.1-2008.
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
43       sched_yield() is intended for use with  read-time  scheduling  policies
44       (i.e., SCHED_FIFO or SCHED_RR).  Use of sched_yield() with nondetermin‐
45       istic scheduling policies such as SCHED_OTHER is unspecified  and  very
46       likely means your application design is broken.
47

SEE ALSO

49       sched(7)
50

COLOPHON

52       This  page  is  part of release 4.15 of the Linux man-pages project.  A
53       description of the project, information about reporting bugs,  and  the
54       latest     version     of     this    page,    can    be    found    at
55       https://www.kernel.org/doc/man-pages/.
56
57
58
59Linux                             2017-09-15                    SCHED_YIELD(2)
Impressum