]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/sched_yield.2
getent.1, _syscall.2, acct.2, adjtimex.2, bdflush.2, brk.2, cacheflush.2, getsid...
[thirdparty/man-pages.git] / man2 / sched_yield.2
1 .\" Copyright (C) Tom Bjorkholm & Markus Kuhn, 1996
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, see
20 .\" <http://www.gnu.org/licenses/>.
21 .\"
22 .\" 1996-04-01 Tom Bjorkholm <tomb@mydata.se>
23 .\" First version written
24 .\" 1996-04-10 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
25 .\" revision
26 .\"
27 .TH SCHED_YIELD 2 2008-10-18 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 sched_yield \- yield the processor
30 .SH SYNOPSIS
31 .B #include <sched.h>
32 .sp
33 .B int sched_yield(void);
34 .SH DESCRIPTION
35 .BR sched_yield ()
36 causes the calling thread to relinquish the CPU.
37 The thread is moved to the end of the queue for its static
38 priority and a new thread gets to run.
39 .SH RETURN VALUE
40 On success,
41 .BR sched_yield ()
42 returns 0.
43 On error, \-1 is returned, and
44 .I errno
45 is set appropriately.
46 .SH ERRORS
47 In the Linux implementation,
48 .BR sched_yield ()
49 always succeeds.
50 .SH CONFORMING TO
51 POSIX.1-2001.
52 .SH NOTES
53 If the calling thread is the only thread in the highest
54 priority list at that time,
55 it will continue to run after a call to
56 .BR sched_yield ().
57
58 POSIX systems on which
59 .BR sched_yield ()
60 is available define
61 .B _POSIX_PRIORITY_SCHEDULING
62 in \fI<unistd.h>\fP.
63
64 Strategic calls to
65 .BR sched_yield ()
66 can improve performance by giving other threads or processes
67 a chance to run when (heavily) contended resources (e.g., mutexes)
68 have been released by the caller.
69 Avoid calling
70 .BR sched_yield ()
71 unnecessarily or inappropriately
72 (e.g., when resources needed by other
73 schedulable threads are still held by the caller),
74 since doing so will result in unnecessary context switches,
75 which will degrade system performance.
76 .SH SEE ALSO
77 .BR sched_setscheduler (2)
78 for a description of Linux scheduling
79 .PP
80 .I Programming for the real world \- POSIX.4
81 by Bill O. Gallmeister, O'Reilly & Associates, Inc., ISBN 1-56592-074-0.