]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/pthread_attr_setschedparam.3
47d1d4199709728cfd6370d732d66e66153e0413
[thirdparty/man-pages.git] / man3 / pthread_attr_setschedparam.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH PTHREAD_ATTR_SETSCHEDPARAM 3 2021-03-22 "Linux" "Linux Programmer's Manual"
7 .SH NAME
8 pthread_attr_setschedparam, pthread_attr_getschedparam \- set/get
9 scheduling parameter attributes in thread attributes object
10 .SH LIBRARY
11 POSIX threads library
12 .RI ( libpthread ", " \-lpthread )
13 .SH SYNOPSIS
14 .nf
15 .B #include <pthread.h>
16 .PP
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 );
21 .fi
22 .SH DESCRIPTION
23 The
24 .BR pthread_attr_setschedparam ()
25 function sets the scheduling parameter attributes of the
26 thread attributes object referred to by
27 .IR attr
28 to the values specified in the buffer pointed to by
29 .IR param .
30 These attributes determine the scheduling parameters of
31 a thread created using the thread attributes object
32 .IR attr .
33 .PP
34 The
35 .BR pthread_attr_getschedparam ()
36 returns the scheduling parameter attributes of the thread attributes object
37 .IR attr
38 in the buffer pointed to by
39 .IR param .
40 .PP
41 Scheduling parameters are maintained in the following structure:
42 .PP
43 .in +4n
44 .EX
45 struct sched_param {
46 int sched_priority; /* Scheduling priority */
47 };
48 .EE
49 .in
50 .PP
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
54 .BR sched (7).
55 .PP
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),
60 the caller must use
61 .BR pthread_attr_setinheritsched (3)
62 to set the inherit-scheduler attribute of the attributes object
63 .I attr
64 to
65 .BR PTHREAD_EXPLICIT_SCHED .
66 .SH RETURN VALUE
67 On success, these functions return 0;
68 on error, they return a nonzero error number.
69 .SH ERRORS
70 .BR pthread_attr_setschedparam ()
71 can fail with the following error:
72 .TP
73 .B EINVAL
74 The priority specified in
75 .I param
76 does not make sense for the current scheduling policy of
77 .IR attr .
78 .PP
79 POSIX.1 also documents an
80 .B ENOTSUP
81 error for
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).
86 .\" .SH VERSIONS
87 .\" Available since glibc 2.0.
88 .SH ATTRIBUTES
89 For an explanation of the terms used in this section, see
90 .BR attributes (7).
91 .ad l
92 .nh
93 .TS
94 allbox;
95 lbx lb lb
96 l l l.
97 Interface Attribute Value
98 T{
99 .BR pthread_attr_setschedparam (),
100 .BR pthread_attr_getschedparam ()
101 T} Thread safety MT-Safe
102 .TE
103 .hy
104 .ad
105 .sp 1
106 .SH CONFORMING TO
107 POSIX.1-2001, POSIX.1-2008.
108 .SH NOTES
109 See
110 .BR pthread_attr_setschedpolicy (3)
111 for a list of the thread scheduling policies supported on Linux.
112 .SH EXAMPLES
113 See
114 .BR pthread_setschedparam (3).
115 .SH SEE ALSO
116 .ad l
117 .nh
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),
125 .BR pthreads (7),
126 .BR sched (7)