OSDN Git Service

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