1SCHED_SETSCHEDULER(P)      POSIX Programmer's Manual     SCHED_SETSCHEDULER(P)
2
3
4

NAME

6       sched_setscheduler - set scheduling policy and parameters (REALTIME)
7

SYNOPSIS

9       #include <sched.h>
10
11       int sched_setscheduler(pid_t pid, int policy,
12              const struct sched_param *param);
13
14

DESCRIPTION

16       The  sched_setscheduler()  function shall set the scheduling policy and
17       scheduling parameters of the process specified by pid to policy and the
18       parameters  specified in the sched_param structure pointed to by param,
19       respectively. The value of the sched_priority member in the sched_param
20       structure  shall be any integer within the inclusive priority range for
21       the scheduling policy specified by policy.  If the value of pid is neg‐
22       ative,  the  behavior  of the sched_setscheduler() function is unspeci‐
23       fied.
24
25       The possible values  for  the  policy  parameter  are  defined  in  the
26       <sched.h> header.
27
28       If  a  process  specified by pid exists, and if the calling process has
29       permission, the scheduling policy and scheduling  parameters  shall  be
30       set for the process whose process ID is equal to pid.
31
32       If  pid  is zero, the scheduling policy and scheduling parameters shall
33       be set for the calling process.
34
35       The conditions under which one process has the appropriate privilege to
36       change the scheduling parameters of another process are implementation-
37       defined.
38
39       Implementations may require that the requesting process have permission
40       to set its own scheduling parameters or those of another process. Addi‐
41       tionally, implementation-defined  restrictions  may  apply  as  to  the
42       appropriate  privileges  required to set a process' own scheduling pol‐
43       icy, or another process' scheduling policy, to a particular value.
44
45       The sched_setscheduler() function shall be considered successful if  it
46       succeeds  in setting the scheduling policy and scheduling parameters of
47       the process specified by pid to the values specified by policy and  the
48       structure pointed to by param, respectively.
49
50       If  the  scheduling  policy  specified by policy is SCHED_SPORADIC, the
51       value specified by the sched_ss_low_priority member of the param  argu‐
52       ment  shall  be any integer within the inclusive priority range for the
53       sporadic server policy. The sched_ss_repl_period and sched_ss_init_bud‐
54       get  members  of the param argument shall represent the time parameters
55       used by the sporadic server scheduling policy for the  target  process.
56       The  sched_ss_max_repl member of the param argument shall represent the
57       maximum number of replenishments that are allowed to be pending  simul‐
58       taneously for the process scheduled under this scheduling policy.
59
60       The  specified  sched_ss_repl_period  shall be greater than or equal to
61       the specified sched_ss_init_budget for the function to succeed;  if  it
62       is not, then the function shall fail.
63
64       The  value of sched_ss_max_repl shall be within the inclusive range [1,
65       {SS_REPL_MAX}] for the function to succeed; if not, the function  shall
66       fail.
67
68       If  the  scheduling  policy specified by policy is either SCHED_FIFO or
69       SCHED_RR,   the   sched_ss_low_priority,   sched_ss_repl_period,    and
70       sched_ss_init_budget members of the param argument shall have no effect
71       on the scheduling behavior.
72
73       The effect of this function on individual threads is dependent  on  the
74       scheduling contention scope of the threads:
75
76        * For threads with system scheduling contention scope, these functions
77          shall have no effect on their scheduling.
78
79        * For threads with process scheduling contention scope,  the  threads'
80          scheduling  policy  and associated parameters shall not be affected.
81          However, the scheduling of these threads with respect to threads  in
82          other  processes  may  be  dependent on the scheduling parameters of
83          their process, which are governed using these functions.
84
85       If an implementation supports a two-level  scheduling  model  in  which
86       library  threads  are  multiplexed  on  top of several kernel-scheduled
87       entities, then the underlying kernel-scheduled entities for the  system
88       contention scope threads shall not be affected by these functions.
89
90       The  underlying  kernel-scheduled  entities  for the process contention
91       scope threads shall have their scheduling policy and associated  sched‐
92       uling  parameters  changed to the values specified in policy and param,
93       respectively. Kernel-scheduled entities for use by  process  contention
94       scope  threads that are created after this call completes shall inherit
95       their scheduling policy and associated scheduling parameters  from  the
96       process.
97
98       This  function  is  not  atomic  with  respect  to other threads in the
99       process.  Threads may continue to execute while this function  call  is
100       in  the process of changing the scheduling policy and associated sched‐
101       uling parameters for the underlying kernel-scheduled entities  used  by
102       the process contention scope threads.
103

RETURN VALUE

105       Upon successful completion, the function shall return the former sched‐
106       uling policy of the  specified  process.  If  the  sched_setscheduler()
107       function  fails  to  complete  successfully,  the policy and scheduling
108       parameters shall remain unchanged, and  the  function  shall  return  a
109       value of -1 and set errno to indicate the error.
110

ERRORS

112       The sched_setscheduler() function shall fail if:
113
114       EINVAL The  value of the policy parameter is invalid, or one or more of
115              the parameters contained in param is outside the valid range for
116              the specified scheduling policy.
117
118       EPERM  The requesting process does not have permission to set either or
119              both of the scheduling parameters or the  scheduling  policy  of
120              the specified process.
121
122       ESRCH  No process can be found corresponding to that specified by pid.
123
124
125       The following sections are informative.
126

EXAMPLES

128       None.
129

APPLICATION USAGE

131       None.
132

RATIONALE

134       None.
135

FUTURE DIRECTIONS

137       None.
138

SEE ALSO

140       sched_getparam()  ,  sched_getscheduler() , sched_setparam() , the Base
141       Definitions volume of IEEE Std 1003.1-2001, <sched.h>
142
144       Portions of this text are reprinted and reproduced in  electronic  form
145       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
146       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
147       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
148       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
149       event of any discrepancy between this version and the original IEEE and
150       The Open Group Standard, the original IEEE and The Open Group  Standard
151       is  the  referee document. The original Standard can be obtained online
152       at http://www.opengroup.org/unix/online.html .
153
154
155
156IEEE/The Open Group                  2003                SCHED_SETSCHEDULER(P)
Impressum