1sched_yield(2)                System Calls Manual               sched_yield(2)
2
3
4

NAME

6       sched_yield - yield the processor
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sched.h>
13
14       int sched_yield(void);
15

DESCRIPTION

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

RETURN VALUE

22       On success, sched_yield() returns 0.  On error, -1 is returned, and er‐
23       rno is set to indicate the error.
24

ERRORS

26       In the Linux implementation, sched_yield() always succeeds.
27

STANDARDS

29       POSIX.1-2008.
30

HISTORY

32       POSIX.1-2001 (but optional).  POSIX.1-2008.
33
34       Before POSIX.1-2008, systems on which sched_yield()  is  available  de‐
35       fined _POSIX_PRIORITY_SCHEDULING in <unistd.h>.
36

CAVEATS

38       sched_yield()  is  intended  for use with real-time scheduling policies
39       (i.e., SCHED_FIFO or SCHED_RR).  Use of sched_yield() with nondetermin‐
40       istic  scheduling  policies such as SCHED_OTHER is unspecified and very
41       likely means your application design is broken.
42
43       If the calling thread is the only thread in the highest  priority  list
44       at that time, it will continue to run after a call to sched_yield().
45
46       Avoid  calling  sched_yield()  unnecessarily  or inappropriately (e.g.,
47       when resources needed by other schedulable threads are  still  held  by
48       the  caller),  since  doing  so  will  result  in  unnecessary  context
49       switches, which will degrade system performance.
50

SEE ALSO

52       sched(7)
53
54
55
56Linux man-pages 6.05              2023-05-03                    sched_yield(2)
Impressum