Debian Codegraph @

upstream/debian-unstable/man2/sched_yield.2

raw
1 .\" Copyright 1996, Tom Bjorkholm <[email protected]>
2 .\" Copyright 1996, Markus Kuhn <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .\"
7 .TH sched_yield 2 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 sched_yield \- yield the processor
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <sched.h>
16 .P
17 .B int sched_yield(void);
18 .fi
19 .SH DESCRIPTION
20 .BR sched_yield ()
21 causes the calling thread to relinquish the CPU.
22 The thread is moved to the end of the queue for its static
23 priority and a new thread gets to run.
24 .SH RETURN VALUE
25 On success,
26 .BR sched_yield ()
27 returns 0.
28 On error, \-1 is returned, and
29 .I errno
30 is set to indicate the error.
31 .SH ERRORS
32 In the Linux implementation,
33 .BR sched_yield ()
34 always succeeds.
35 .SH STANDARDS
36 POSIX.1-2024.
37 .SH HISTORY
38 POSIX.1-2001 (but optional).
39 POSIX.1-2008.
40 .P
41 Before POSIX.1-2008,
42 systems on which
43 .BR sched_yield ()
44 is available defined
45 .B _POSIX_PRIORITY_SCHEDULING
46 in
47 .IR <unistd.h> .
48 .SH CAVEATS
49 .BR sched_yield ()
50 is intended for use with real-time scheduling policies (i.e.,
51 .B SCHED_FIFO
52 or
53 .BR SCHED_RR ).
54 Use of
55 .BR sched_yield ()
56 with nondeterministic scheduling policies such as
57 .B SCHED_OTHER
58 is unspecified and very likely means your application design is broken.
59 .P
60 If the calling thread is the only thread in the highest
61 priority list at that time,
62 it will continue to run after a call to
63 .BR sched_yield ().
64 .P
65 Avoid calling
66 .BR sched_yield ()
67 unnecessarily or inappropriately
68 (e.g., when resources needed by other
69 schedulable threads are still held by the caller),
70 since doing so will result in unnecessary context switches,
71 which will degrade system performance.
72 .SH SEE ALSO
73 .BR sched (7)