1sched_setscheduler(3C) Standard C Library Functions sched_setscheduler(3C)
2
3
4
6 sched_setscheduler - set scheduling policy and scheduling parameters
7
9 #include <sched.h>
10
11 int sched_setscheduler(pid_t pid, int policy,
12 const struct sched_param *param);
13
14
16 The sched_setscheduler() function sets the scheduling policy and sched‐
17 uling 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 is any integer within the inclusive priority range for the
21 scheduling policy specified by policy. The sched_setscheduler() func‐
22 tion ignores the other members of the sched_param structure. If the
23 value of pid is negative, the behavior of the sched_setscheduler()
24 function is unspecified.
25
26
27 The possible values for the policy parameter are defined in the header
28 <sched.h> (see sched.h(3HEAD)):
29
30
31 If a process specified by pid exists and if the calling process has
32 permission, the scheduling policy and scheduling parameters are set for
33 the process whose process ID is equal to pid. The real or effective
34 user ID of the calling process must match the real or saved (from
35 exec(2)) user ID of the target process unless the effective user ID
36 of the calling process is 0. See Intro(2).
37
38
39 If pid is 0, the scheduling policy and scheduling parameters are set
40 for the calling process.
41
42
43 To change the policy of any process to either of the real time policies
44 SCHED_FIFO or SCHED_RR, the calling process must either have the
45 SCHED_FIFO or SCHED_RR policy or have an effective user ID of 0.
46
47
48 The sched_setscheduler() function is considered successful if it suc‐
49 ceeds in setting the scheduling policy and scheduling parameters of the
50 process specified by pid to the values specified by policy and the
51 structure pointed to by param, respectively.
52
54 Upon successful completion, the function returns the former scheduling
55 policy of the specified process. If the sched_setscheduler() function
56 fails to complete successfully, the policy and scheduling paramenters
57 remain unchanged, and the function returns −1 and sets errno to indi‐
58 cate the error.
59
61 The sched_setscheduler() function will fail if:
62
63 EINVAL The value of policy is invalid, or one or more of the parame‐
64 ters contained in param is outside the valid range for the
65 specified scheduling policy.
66
67
68 EPERM The requesting process does not have permission to set either
69 or both of the scheduling parameters or the scheduling policy
70 of the specified process.
71
72
73 ESRCH No process can be found corresponding to that specified by
74 pid.
75
76
78 See attributes(5) for descriptions of the following attributes:
79
80
81
82
83 ┌─────────────────────────────┬─────────────────────────────┐
84 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
85 ├─────────────────────────────┼─────────────────────────────┤
86 │Interface Stability │Committed │
87 ├─────────────────────────────┼─────────────────────────────┤
88 │MT-Level │MT-Safe │
89 ├─────────────────────────────┼─────────────────────────────┤
90 │Standard │See standards(5). │
91 └─────────────────────────────┴─────────────────────────────┘
92
94 priocntl(1), Intro(2), exec(2), priocntl(2), librt(3LIB),
95 sched.h(3HEAD), sched_get_priority_max(3C), sched_getparam(3C),
96 sched_getscheduler(3C), sched_setparam(3C), attributes(5), standards(5)
97
98
99
100SunOS 5.11 1 Apr 2008 sched_setscheduler(3C)