Debian Codegraph @

upstream/debian-trixie/man2/sched_yield.2

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