1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
4
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
5
<TITLE>"SCHED_SETSCHEDULER"(P) manual page</TITLE>
6
<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
7
<META NAME="CREATED" CONTENT="20050505;13012200">
8
<META NAME="CHANGED" CONTENT="20050505;13193700">
9
<!-- manual page source format generated by PolyglotMan v3.2, -->
10
<!-- available at http://polyglotman.sourceforge.net/ -->
12
<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
13
<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
14
<P><A HREF="index.html">Reference Index</A></P>
15
<P><A HREF="#toc">Table of Contents</A></P>
16
<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
17
<P>sched_setscheduler - set scheduling policy and parameters
20
<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
21
<P><B>#include <sched.h> </B>
23
<P><B>int sched_setscheduler(pid_t</B> <I>pid</I><B>, int</B> <I>policy</I><B>,
24
const struct sched_param *</B><I>param</I><B>); </B>
26
<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
27
<P>The <B>sched_setscheduler</B> function shall set the scheduling
28
policy and scheduling parameters of the process specified by <I>pid</I>
29
to <I>policy</I> and the parameters specified in the <B>sched_param</B>
30
structure pointed to by <I>param</I>, respectively. The value of the
31
<I>sched_priority</I> member in the <B>sched_param</B> structure
32
shall be any integer within the inclusive priority range for the
33
scheduling policy specified by <I>policy</I>. If the value of <I>pid</I>
34
is negative, the behavior of the <B>sched_setscheduler</B> function
37
<P>The possible values for the <I>policy</I> parameter are defined in
38
the <I><sched.h></I> header.
40
<P><B>Pthreads-w32</B> only supports the <B>SCHED_OTHER</B> policy.
41
Any other value for <I>policy</I> will return failure with errno set
42
to <B>ENOSYS</B>. However, checks on <I>pid</I> and permissions are
43
performed first so that the other useful side effects of this routine
45
<P>If a process specified by <I>pid</I> exists, and if the calling
46
process has permission, the scheduling policy and scheduling
47
parameters shall be set for the process whose process ID is equal to
50
<P>If <I>pid</I> is zero, the scheduling policy and scheduling
51
parameters shall be set for the calling process.
53
<P>Implementations may require that the requesting process have
54
permission to set its own scheduling parameters or those of another
55
process. Additionally, implementation-defined restrictions may apply
56
as to the appropriate privileges required to set a process’ own
57
scheduling policy, or another process’ scheduling policy, to a
60
<P>The <B>sched_setscheduler</B> function shall be considered
61
successful if it succeeds in setting the scheduling policy and
62
scheduling parameters of the process specified by <I>pid</I> to the
63
values specified by <I>policy</I> and the structure pointed to by
64
<I>param</I>, respectively.
66
<P>The effect of this function on individual threads is dependent on
67
the scheduling contention scope of the threads:
71
</DT><DD STYLE="margin-bottom: 0.5cm">
72
For threads with system scheduling contention scope, these functions
73
shall have no effect on their scheduling.
76
</DT><DD STYLE="margin-bottom: 0.5cm">
77
For threads with process scheduling contention scope, the threads’
78
scheduling policy and associated parameters shall not be affected.
79
However, the scheduling of these threads with respect to threads in
80
other processes may be dependent on the scheduling parameters of
81
their process, which are governed using these functions.
84
This function is not atomic with respect to other threads in the
85
process. Threads may continue to execute while this function call is
86
in the process of changing the scheduling policy and associated
87
scheduling parameters for the underlying kernel-scheduled entities
88
used by the process contention scope threads.
90
<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
91
<P>Upon successful completion, the function shall return the former
92
scheduling policy of the specified process. If the <B>sched_setscheduler</B>
93
function fails to complete successfully, the policy and scheduling
94
parameters shall remain unchanged, and the function shall return a
95
value of -1 and set <I>errno</I> to indicate the error.
97
<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
98
<P>The <B>sched_setscheduler</B> function shall fail if:
103
The value of the <I>policy</I> parameter is invalid, or one or more
104
of the parameters contained in <I>param</I> is outside the valid
105
range for the specified scheduling policy.
109
The requesting process does not have permission to set either or
110
both of the scheduling parameters or the scheduling policy of the
114
</DT><DD STYLE="margin-bottom: 0.5cm">
115
No process can be found corresponding to that specified by <I>pid</I>.
118
<I>The following sections are informative.</I>
120
<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2>
123
<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2>
126
<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2>
129
<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2>
132
<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2>
133
<P><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B>(3)</A>
134
<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001,
135
<I><sched.h></I>
137
<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2>
138
<P>Portions of this text are reprinted and reproduced in electronic
139
form from IEEE Std 1003.1, 2003 Edition, Standard for Information
140
Technology -- Portable Operating System Interface (POSIX), The Open
141
Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the
142
Institute of Electrical and Electronics Engineers, Inc and The Open
143
Group. In the event of any discrepancy between this version and the
144
original IEEE and The Open Group Standard, the original IEEE and The
145
Open Group Standard is the referee document. The original Standard
146
can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A>
149
<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
151
<P><A NAME="toc"></A><B>Table of Contents</B></P>
153
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
155
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
157
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
159
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
162
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
164
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A>
166
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application
169
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A>
171
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future
174
<LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See
177
<LI><P><A HREF="#sect10" NAME="toc10">Copyright</A>