1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH PTHREAD_ATTR_SETSCHEDPARAM 3 2021-03-22 "Linux" "Linux Programmer's Manual"
8 pthread_attr_setschedparam, pthread_attr_getschedparam \- set/get
9 scheduling parameter attributes in thread attributes object
12 .RI ( libpthread ", " \-lpthread )
15 .B #include <pthread.h>
17 .BI "int pthread_attr_setschedparam(pthread_attr_t *restrict " attr ,
18 .BI " const struct sched_param *restrict " param );
19 .BI "int pthread_attr_getschedparam(const pthread_attr_t *restrict " attr ,
20 .BI " struct sched_param *restrict " param );
24 .BR pthread_attr_setschedparam ()
25 function sets the scheduling parameter attributes of the
26 thread attributes object referred to by
28 to the values specified in the buffer pointed to by
30 These attributes determine the scheduling parameters of
31 a thread created using the thread attributes object
35 .BR pthread_attr_getschedparam ()
36 returns the scheduling parameter attributes of the thread attributes object
38 in the buffer pointed to by
41 Scheduling parameters are maintained in the following structure:
46 int sched_priority; /* Scheduling priority */
51 As can be seen, only one scheduling parameter is supported.
52 For details of the permitted ranges for scheduling priorities
53 in each scheduling policy, see
56 In order for the parameter setting made by
57 .BR pthread_attr_setschedparam ()
58 to have effect when calling
59 .BR pthread_create (3),
61 .BR pthread_attr_setinheritsched (3)
62 to set the inherit-scheduler attribute of the attributes object
65 .BR PTHREAD_EXPLICIT_SCHED .
67 On success, these functions return 0;
68 on error, they return a nonzero error number.
70 .BR pthread_attr_setschedparam ()
71 can fail with the following error:
74 The priority specified in
76 does not make sense for the current scheduling policy of
79 POSIX.1 also documents an
82 .BR pthread_attr_setschedparam ().
83 This value is never returned on Linux
84 (but portable and future-proof applications should nevertheless
85 handle this error return value).
87 .\" Available since glibc 2.0.
89 For an explanation of the terms used in this section, see
97 Interface Attribute Value
99 .BR pthread_attr_setschedparam (),
100 .BR pthread_attr_getschedparam ()
101 T} Thread safety MT-Safe
107 POSIX.1-2001, POSIX.1-2008.
110 .BR pthread_attr_setschedpolicy (3)
111 for a list of the thread scheduling policies supported on Linux.
114 .BR pthread_setschedparam (3).
118 .BR sched_get_priority_min (2),
119 .BR pthread_attr_init (3),
120 .BR pthread_attr_setinheritsched (3),
121 .BR pthread_attr_setschedpolicy (3),
122 .BR pthread_create (3),
123 .BR pthread_setschedparam (3),
124 .BR pthread_setschedprio (3),