1SCHED_SETPARAM(P) POSIX Programmer's Manual SCHED_SETPARAM(P)
2
3
4
6 sched_setparam - set scheduling parameters (REALTIME)
7
9 #include <sched.h>
10
11 int sched_setparam(pid_t pid, const struct sched_param *param);
12
13
15 The sched_setparam() function shall set the scheduling parameters of
16 the process specified by pid to the values specified by the sched_param
17 structure pointed to by param. The value of the sched_priority member
18 in the sched_param structure shall be any integer within the inclusive
19 priority range for the current scheduling policy of the process speci‐
20 fied by pid. Higher numerical values for the priority represent higher
21 priorities. If the value of pid is negative, the behavior of the
22 sched_setparam() function is unspecified.
23
24 If a process specified by pid exists, and if the calling process has
25 permission, the scheduling parameters shall be set for the process
26 whose process ID is equal to pid.
27
28 If pid is zero, the scheduling parameters shall be set for the calling
29 process.
30
31 The conditions under which one process has permission to change the
32 scheduling parameters of another process are implementation-defined.
33
34 Implementations may require the requesting process to have the appro‐
35 priate privilege to set its own scheduling parameters or those of
36 another process.
37
38 The target process, whether it is running or not running, shall be
39 moved to the tail of the thread list for its priority.
40
41 If the priority of the process specified by the pid argument is set
42 higher than that of the lowest priority running process and if the
43 specified process is ready to run, the process specified by the pid
44 argument shall preempt a lowest priority running process. Similarly, if
45 the process calling sched_setparam() sets its own priority lower than
46 that of one or more other non-empty process lists, then the process
47 that is the head of the highest priority list shall also preempt the
48 calling process. Thus, in either case, the originating process might
49 not receive notification of the completion of the requested priority
50 change until the higher priority process has executed.
51
52 If the scheduling policy of the target process is SCHED_SPORADIC, the
53 value specified by the sched_ss_low_priority member of the param argu‐
54 ment shall be any integer within the inclusive priority range for the
55 sporadic server policy. The sched_ss_repl_period and sched_ss_init_bud‐
56 get members of the param argument shall represent the time parameters
57 to be used by the sporadic server scheduling policy for the target
58 process. The sched_ss_max_repl member of the param argument shall rep‐
59 resent the maximum number of replenishments that are allowed to be
60 pending simultaneously for the process scheduled under this scheduling
61 policy.
62
63 The specified sched_ss_repl_period shall be greater than or equal to
64 the specified sched_ss_init_budget for the function to succeed; if it
65 is not, then the function shall fail.
66
67 The value of sched_ss_max_repl shall be within the inclusive range [1,
68 {SS_REPL_MAX}] for the function to succeed; if not, the function shall
69 fail.
70
71 If the scheduling policy of the target process is either SCHED_FIFO or
72 SCHED_RR, the sched_ss_low_priority, sched_ss_repl_period, and
73 sched_ss_init_budget members of the param argument shall have no effect
74 on the scheduling behavior. If the scheduling policy of this process is
75 not SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC, the effects of these mem‐
76 bers are implementation-defined; this case includes the SCHED_OTHER
77 policy.
78
79 If the current scheduling policy for the process specified by pid is
80 not SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC, the result is imple‐
81 mentation-defined; this case includes the SCHED_OTHER policy.
82
83 The effect of this function on individual threads is dependent on the
84 scheduling contention scope of the threads:
85
86 * For threads with system scheduling contention scope, these functions
87 shall have no effect on their scheduling.
88
89 * For threads with process scheduling contention scope, the threads'
90 scheduling parameters shall not be affected. However, the scheduling
91 of these threads with respect to threads in other processes may be
92 dependent on the scheduling parameters of their process, which are
93 governed using these functions.
94
95 If an implementation supports a two-level scheduling model in which
96 library threads are multiplexed on top of several kernel-scheduled
97 entities, then the underlying kernel-scheduled entities for the system
98 contention scope threads shall not be affected by these functions.
99
100 The underlying kernel-scheduled entities for the process contention
101 scope threads shall have their scheduling parameters changed to the
102 value specified in param. Kernel-scheduled entities for use by process
103 contention scope threads that are created after this call completes
104 shall inherit their scheduling policy and associated scheduling parame‐
105 ters from the process.
106
107 This function is not atomic with respect to other threads in the
108 process. Threads may continue to execute while this function call is
109 in the process of changing the scheduling policy for the underlying
110 kernel-scheduled entities used by the process contention scope threads.
111
113 If successful, the sched_setparam() function shall return zero.
114
115 If the call to sched_setparam() is unsuccessful, the priority shall
116 remain unchanged, and the function shall return a value of -1 and set
117 errno to indicate the error.
118
120 The sched_setparam() function shall fail if:
121
122 EINVAL One or more of the requested scheduling parameters is outside
123 the range defined for the scheduling policy of the specified
124 pid.
125
126 EPERM The requesting process does not have permission to set the
127 scheduling parameters for the specified process, or does not
128 have the appropriate privilege to invoke sched_setparam().
129
130 ESRCH No process can be found corresponding to that specified by pid.
131
132
133 The following sections are informative.
134
136 None.
137
139 None.
140
142 None.
143
145 None.
146
148 sched_getparam() , sched_getscheduler() , sched_setscheduler() , the
149 Base Definitions volume of IEEE Std 1003.1-2001, <sched.h>
150
152 Portions of this text are reprinted and reproduced in electronic form
153 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
154 -- Portable Operating System Interface (POSIX), The Open Group Base
155 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
156 Electrical and Electronics Engineers, Inc and The Open Group. In the
157 event of any discrepancy between this version and the original IEEE and
158 The Open Group Standard, the original IEEE and The Open Group Standard
159 is the referee document. The original Standard can be obtained online
160 at http://www.opengroup.org/unix/online.html .
161
162
163
164IEEE/The Open Group 2003 SCHED_SETPARAM(P)