Debian Codegraph @

upstream/debian-trixie/man3/pthread_attr_setschedparam.3

raw
1 '\" t
2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <[email protected]>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH pthread_attr_setschedparam 3 2024-05-02 "Linux man-pages 6.9.1"
8 .SH NAME
9 pthread_attr_setschedparam, pthread_attr_getschedparam \- set/get
10 scheduling parameter attributes in thread attributes object
11 .SH LIBRARY
12 POSIX threads library
13 .RI ( libpthread ", " \-lpthread )
14 .SH SYNOPSIS
15 .nf
16 .B #include <pthread.h>
17 .P
18 .BI "int pthread_attr_setschedparam(pthread_attr_t *restrict " attr ,
19 .BI " const struct sched_param *restrict " param );
20 .BI "int pthread_attr_getschedparam(const pthread_attr_t *restrict " attr ,
21 .BI " struct sched_param *restrict " param );
22 .fi
23 .SH DESCRIPTION
24 The
25 .BR pthread_attr_setschedparam ()
26 function sets the scheduling parameter attributes of the
27 thread attributes object referred to by
28 .I attr
29 to the values specified in the buffer pointed to by
30 .IR param .
31 These attributes determine the scheduling parameters of
32 a thread created using the thread attributes object
33 .IR attr .
34 .P
35 The
36 .BR pthread_attr_getschedparam ()
37 returns the scheduling parameter attributes of the thread attributes object
38 .I attr
39 in the buffer pointed to by
40 .IR param .
41 .P
42 Scheduling parameters are maintained in the following structure:
43 .P
44 .in +4n
45 .EX
46 struct sched_param {
47 int sched_priority; /* Scheduling priority */
48 };
49 .EE
50 .in
51 .P
52 As can be seen, only one scheduling parameter is supported.
53 For details of the permitted ranges for scheduling priorities
54 in each scheduling policy, see
55 .BR sched (7).
56 .P
57 In order for the parameter setting made by
58 .BR pthread_attr_setschedparam ()
59 to have effect when calling
60 .BR pthread_create (3),
61 the caller must use
62 .BR pthread_attr_setinheritsched (3)
63 to set the inherit-scheduler attribute of the attributes object
64 .I attr
65 to
66 .BR PTHREAD_EXPLICIT_SCHED .
67 .SH RETURN VALUE
68 On success, these functions return 0;
69 on error, they return a nonzero error number.
70 .SH ERRORS
71 .BR pthread_attr_setschedparam ()
72 can fail with the following error:
73 .TP
74 .B EINVAL
75 The priority specified in
76 .I param
77 does not make sense for the current scheduling policy of
78 .IR attr .
79 .P
80 POSIX.1 also documents an
81 .B ENOTSUP
82 error for
83 .BR pthread_attr_setschedparam ().
84 This value is never returned on Linux
85 (but portable and future-proof applications should nevertheless
86 handle this error return value).
87 .SH ATTRIBUTES
88 For an explanation of the terms used in this section, see
89 .BR attributes (7).
90 .TS
91 allbox;
92 lbx lb lb
93 l l l.
94 Interface Attribute Value
95 T{
96 .na
97 .nh
98 .BR pthread_attr_setschedparam (),
99 .BR pthread_attr_getschedparam ()
100 T} Thread safety MT-Safe
101 .TE
102 .SH STANDARDS
103 POSIX.1-2008.
104 .SH HISTORY
105 POSIX.1-2001.
106 glibc 2.0.
107 .SH NOTES
108 See
109 .BR pthread_attr_setschedpolicy (3)
110 for a list of the thread scheduling policies supported on Linux.
111 .SH EXAMPLES
112 See
113 .BR pthread_setschedparam (3).
114 .SH SEE ALSO
115 .ad l
116 .nh
117 .BR sched_get_priority_min (2),
118 .BR pthread_attr_init (3),
119 .BR pthread_attr_setinheritsched (3),
120 .BR pthread_attr_setschedpolicy (3),
121 .BR pthread_create (3),
122 .BR pthread_setschedparam (3),
123 .BR pthread_setschedprio (3),
124 .BR pthreads (7),
125 .BR sched (7)