1pthread_attr_setschedparam(3L)ibrary Functions Manuaplthread_attr_setschedparam(3)
2
3
4
6 pthread_attr_setschedparam, pthread_attr_getschedparam - set/get sched‐
7 uling parameter attributes in thread attributes object
8
10 POSIX threads library (libpthread, -lpthread)
11
13 #include <pthread.h>
14
15 int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
16 const struct sched_param *restrict param);
17 int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
18 struct sched_param *restrict param);
19
21 The pthread_attr_setschedparam() function sets the scheduling parameter
22 attributes of the thread attributes object referred to by attr to the
23 values specified in the buffer pointed to by param. These attributes
24 determine the scheduling parameters of a thread created using the
25 thread attributes object attr.
26
27 The pthread_attr_getschedparam() returns the scheduling parameter at‐
28 tributes of the thread attributes object attr in the buffer pointed to
29 by param.
30
31 Scheduling parameters are maintained in the following structure:
32
33 struct sched_param {
34 int sched_priority; /* Scheduling priority */
35 };
36
37 As can be seen, only one scheduling parameter is supported. For de‐
38 tails of the permitted ranges for scheduling priorities in each sched‐
39 uling policy, see sched(7).
40
41 In order for the parameter setting made by pthread_attr_setschedparam()
42 to have effect when calling pthread_create(3), the caller must use
43 pthread_attr_setinheritsched(3) to set the inherit-scheduler attribute
44 of the attributes object attr to PTHREAD_EXPLICIT_SCHED.
45
47 On success, these functions return 0; on error, they return a nonzero
48 error number.
49
51 pthread_attr_setschedparam() can fail with the following error:
52
53 EINVAL The priority specified in param does not make sense for the cur‐
54 rent scheduling policy of attr.
55
56 POSIX.1 also documents an ENOTSUP error for pthread_attr_setsched‐
57 param(). This value is never returned on Linux (but portable and fu‐
58 ture-proof applications should nevertheless handle this error return
59 value).
60
62 For an explanation of the terms used in this section, see at‐
63 tributes(7).
64
65 ┌────────────────────────────────────────────┬───────────────┬─────────┐
66 │Interface │ Attribute │ Value │
67 ├────────────────────────────────────────────┼───────────────┼─────────┤
68 │pthread_attr_setschedparam(), │ Thread safety │ MT-Safe │
69 │pthread_attr_getschedparam() │ │ │
70 └────────────────────────────────────────────┴───────────────┴─────────┘
71
73 POSIX.1-2008.
74
76 POSIX.1-2001. glibc 2.0.
77
79 See pthread_attr_setschedpolicy(3) for a list of the thread scheduling
80 policies supported on Linux.
81
83 See pthread_setschedparam(3).
84
86 sched_get_priority_min(2), pthread_attr_init(3),
87 pthread_attr_setinheritsched(3), pthread_attr_setschedpolicy(3),
88 pthread_create(3), pthread_setschedparam(3), pthread_setschedprio(3),
89 pthreads(7), sched(7)
90
91
92
93Linux man-pages 6.05 2023-07-20 pthread_attr_setschedparam(3)