1sched_setparam(2) System Calls Manual sched_setparam(2)
2
3
4
6 sched_setparam, sched_getparam - set and get scheduling parameters
7
9 Standard C library (libc, -lc)
10
12 #include <sched.h>
13
14 int sched_setparam(pid_t pid, const struct sched_param *param);
15 int sched_getparam(pid_t pid, struct sched_param *param);
16
17 struct sched_param {
18 ...
19 int sched_priority;
20 ...
21 };
22
24 sched_setparam() sets the scheduling parameters associated with the
25 scheduling policy for the thread whose thread ID is specified in pid.
26 If pid is zero, then the parameters of the calling thread are set. The
27 interpretation of the argument param depends on the scheduling policy
28 of the thread identified by pid. See sched(7) for a description of the
29 scheduling policies supported under Linux.
30
31 sched_getparam() retrieves the scheduling parameters for the thread
32 identified by pid. If pid is zero, then the parameters of the calling
33 thread are retrieved.
34
35 sched_setparam() checks the validity of param for the scheduling policy
36 of the thread. The value param->sched_priority must lie within the
37 range given by sched_get_priority_min(2) and sched_get_priority_max(2).
38
39 For a discussion of the privileges and resource limits related to
40 scheduling priority and policy, see sched(7).
41
42 POSIX systems on which sched_setparam() and sched_getparam() are avail‐
43 able define _POSIX_PRIORITY_SCHEDULING in <unistd.h>.
44
46 On success, sched_setparam() and sched_getparam() return 0. On error,
47 -1 is returned, and errno is set to indicate the error.
48
50 EINVAL Invalid arguments: param is NULL or pid is negative
51
52 EINVAL (sched_setparam()) The argument param does not make sense for
53 the current scheduling policy.
54
55 EPERM (sched_setparam()) The caller does not have appropriate privi‐
56 leges (Linux: does not have the CAP_SYS_NICE capability).
57
58 ESRCH The thread whose ID is pid could not be found.
59
61 POSIX.1-2008.
62
64 POSIX.1-2001.
65
67 getpriority(2), gettid(2), nice(2), sched_get_priority_max(2),
68 sched_get_priority_min(2), sched_getaffinity(2), sched_getscheduler(2),
69 sched_setaffinity(2), sched_setattr(2), sched_setscheduler(2),
70 setpriority(2), capabilities(7), sched(7)
71
72
73
74Linux man-pages 6.04 2023-03-30 sched_setparam(2)