]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/sched_yield.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / sched_yield.2
CommitLineData
fea681da
MK
1.\" Copyright (C) Tom Bjorkholm & Markus Kuhn, 1996
2.\"
1dd72f9c 3.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
fea681da
MK
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
8.\"
9.\" The GNU General Public License's references to "object code"
10.\" and "executables" are to be interpreted as the output of any
11.\" document formatting or typesetting system, including
12.\" intermediate and printed output.
13.\"
14.\" This manual is distributed in the hope that it will be useful,
15.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.\" GNU General Public License for more details.
18.\"
19.\" You should have received a copy of the GNU General Public
c715f741
MK
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
6a8d8745 22.\" %%%LICENSE_END
fea681da
MK
23.\"
24.\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
25.\" First version written
26.\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
27.\" revision
28.\"
4b8c67d9 29.TH SCHED_YIELD 2 2017-09-15 "Linux" "Linux Programmer's Manual"
fea681da
MK
30.SH NAME
31sched_yield \- yield the processor
32.SH SYNOPSIS
33.B #include <sched.h>
68e4db0a 34.PP
c307030c 35.B int sched_yield(void);
fea681da 36.SH DESCRIPTION
15eeae41
MK
37.BR sched_yield ()
38causes the calling thread to relinquish the CPU.
39The thread is moved to the end of the queue for its static
40priority and a new thread gets to run.
47297adb 41.SH RETURN VALUE
fea681da 42On success,
e511ffb6 43.BR sched_yield ()
fea681da
MK
44returns 0.
45On error, \-1 is returned, and
46.I errno
47is set appropriately.
f5cb430b
MK
48.SH ERRORS
49In the Linux implementation,
50.BR sched_yield ()
51always succeeds.
47297adb 52.SH CONFORMING TO
02d658b2 53POSIX.1-2001, POSIX.1-2008.
7559496c
MK
54.SH NOTES
55If the calling thread is the only thread in the highest
56priority list at that time,
57it will continue to run after a call to
58.BR sched_yield ().
efeece04 59.PP
7559496c
MK
60POSIX systems on which
61.BR sched_yield ()
62is available define
63.B _POSIX_PRIORITY_SCHEDULING
c9942389
MK
64in
65.IR <unistd.h> .
efeece04 66.PP
e70c986b
MK
67Strategic calls to
68.BR sched_yield ()
69can improve performance by giving other threads or processes
70a chance to run when (heavily) contended resources (e.g., mutexes)
71have been released by the caller.
72Avoid calling
73.BR sched_yield ()
74unnecessarily or inappropriately
75(e.g., when resources needed by other
76schedulable threads are still held by the caller),
77since doing so will result in unnecessary context switches,
78which will degrade system performance.
9ce1d920
MK
79.PP
80.BR sched_yield ()
956dc827 81is intended for use with real-time scheduling policies (i.e.,
9ce1d920
MK
82.BR SCHED_FIFO
83or
84.BR SCHED_RR ).
85Use of
86.BR sched_yield ()
87with nondeterministic scheduling policies such as
88.BR SCHED_OTHER
89is unspecified and very likely means your application design is broken.
47297adb 90.SH SEE ALSO
b22400c0 91.BR sched (7)