143 lines
3.2 KiB
HTML
143 lines
3.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SCHED_YIELD</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SCHED_YIELD</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sched_yield - yield the processor
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sched.h">sched.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int sched_yield(void);</B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>sched_yield</B>()
|
|
|
|
causes the calling thread to relinquish the CPU.
|
|
The thread is moved to the end of the queue for its static
|
|
priority and a new thread gets to run.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success,
|
|
<B>sched_yield</B>()
|
|
|
|
returns 0.
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
In the Linux implementation,
|
|
<B>sched_yield</B>()
|
|
|
|
always succeeds.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
If the calling thread is the only thread in the highest
|
|
priority list at that time,
|
|
it will continue to run after a call to
|
|
<B>sched_yield</B>().
|
|
|
|
<P>
|
|
|
|
POSIX systems on which
|
|
<B>sched_yield</B>()
|
|
|
|
is available define
|
|
<B>_POSIX_PRIORITY_SCHEDULING</B>
|
|
|
|
in
|
|
<I><<A HREF="file:///usr/include/unistd.h">unistd.h</A>></I>.
|
|
|
|
<P>
|
|
|
|
Strategic calls to
|
|
<B>sched_yield</B>()
|
|
|
|
can improve performance by giving other threads or processes
|
|
a chance to run when (heavily) contended resources (e.g., mutexes)
|
|
have been released by the caller.
|
|
Avoid calling
|
|
<B>sched_yield</B>()
|
|
|
|
unnecessarily or inappropriately
|
|
(e.g., when resources needed by other
|
|
schedulable threads are still held by the caller),
|
|
since doing so will result in unnecessary context switches,
|
|
which will degrade system performance.
|
|
<P>
|
|
|
|
<B>sched_yield</B>()
|
|
|
|
is intended for use with real-time scheduling policies (i.e.,
|
|
<B>SCHED_FIFO</B>
|
|
|
|
or
|
|
<B>SCHED_RR</B>).
|
|
|
|
Use of
|
|
<B>sched_yield</B>()
|
|
|
|
with nondeterministic scheduling policies such as
|
|
<B>SCHED_OTHER</B>
|
|
|
|
is unspecified and very likely means your application design is broken.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sched">sched</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:34 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|