1SCHED_SETSCHEDULER(3P) POSIX Programmer's Manual SCHED_SETSCHEDULER(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 sched_setscheduler — set scheduling policy and parameters (REALTIME)
14
16 #include <sched.h>
17
18 int sched_setscheduler(pid_t pid, int policy,
19 const struct sched_param *param);
20
22 The sched_setscheduler() function shall set the scheduling policy and
23 scheduling parameters of the process specified by pid to policy and the
24 parameters specified in the sched_param structure pointed to by param,
25 respectively. The value of the sched_priority member in the sched_param
26 structure shall be any integer within the inclusive priority range for
27 the scheduling policy specified by policy. If the value of pid is neg‐
28 ative, the behavior of the sched_setscheduler() function is unspeci‐
29 fied.
30
31 The possible values for the policy parameter are defined in the
32 <sched.h> header.
33
34 If a process specified by pid exists, and if the calling process has
35 permission, the scheduling policy and scheduling parameters shall be
36 set for the process whose process ID is equal to pid.
37
38 If pid is zero, the scheduling policy and scheduling parameters shall
39 be set for the calling process.
40
41 The conditions under which one process has appropriate privileges to
42 change the scheduling parameters of another process are implementation-
43 defined.
44
45 Implementations may require that the requesting process have permission
46 to set its own scheduling parameters or those of another process.
47 Additionally, implementation-defined restrictions may apply as to the
48 appropriate privileges required to set the scheduling policy of the
49 process, or the scheduling policy of another process, to a particular
50 value.
51
52 The sched_setscheduler() function shall be considered successful if it
53 succeeds in setting the scheduling policy and scheduling parameters of
54 the process specified by pid to the values specified by policy and the
55 structure pointed to by param, respectively.
56
57 See Scheduling Policies for a description on how this function affects
58 the scheduling of the threads within the target process.
59
60 If the current scheduling policy for the target process is not
61 SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC, the result is implementation-
62 defined; this case includes the SCHED_OTHER policy.
63
64 The specified sched_ss_repl_period shall be greater than or equal to
65 the specified sched_ss_init_budget for the function to succeed; if it
66 is not, then the function shall fail.
67
68 The value of sched_ss_max_repl shall be within the inclusive range
69 [1,{SS_REPL_MAX}] for the function to succeed; if not, the function
70 shall fail. It is unspecified whether the sched_ss_repl_period and
71 sched_ss_init_budget values are stored as provided by this function or
72 are rounded to align with the resolution of the clock being used.
73
74 This function is not atomic with respect to other threads in the
75 process. Threads may continue to execute while this function call is in
76 the process of changing the scheduling policy and associated scheduling
77 parameters for the underlying kernel-scheduled entities used by the
78 process contention scope threads.
79
81 Upon successful completion, the function shall return the former sched‐
82 uling policy of the specified process. If the sched_setscheduler()
83 function fails to complete successfully, the policy and scheduling
84 parameters shall remain unchanged, and the function shall return a
85 value of −1 and set errno to indicate the error.
86
88 The sched_setscheduler() function shall fail if:
89
90 EINVAL The value of the policy parameter is invalid, or one or more of
91 the parameters contained in param is outside the valid range for
92 the specified scheduling policy.
93
94 EPERM The requesting process does not have permission to set either or
95 both of the scheduling parameters or the scheduling policy of
96 the specified process.
97
98 ESRCH No process can be found corresponding to that specified by pid.
99
100 The following sections are informative.
101
103 None.
104
106 None.
107
109 None.
110
112 None.
113
115 Scheduling Policies, sched_getparam(), sched_getscheduler(), sched_set‐
116 param()
117
118 The Base Definitions volume of POSIX.1‐2008, <sched.h>
119
121 Portions of this text are reprinted and reproduced in electronic form
122 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
123 -- Portable Operating System Interface (POSIX), The Open Group Base
124 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
125 cal and Electronics Engineers, Inc and The Open Group. (This is
126 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
127 event of any discrepancy between this version and the original IEEE and
128 The Open Group Standard, the original IEEE and The Open Group Standard
129 is the referee document. The original Standard can be obtained online
130 at http://www.unix.org/online.html .
131
132 Any typographical or formatting errors that appear in this page are
133 most likely to have been introduced during the conversion of the source
134 files to man page format. To report such errors, see https://www.ker‐
135 nel.org/doc/man-pages/reporting_bugs.html .
136
137
138
139IEEE/The Open Group 2013 SCHED_SETSCHEDULER(3P)