| 1 |
'\" t |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH pthread_attr_setschedparam 3 2025-05-17 "Linux man-pages 6.18" |
| 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 |
.P |
| 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 |
.I 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 |
.P |
| 34 |
The |
| 35 |
.BR pthread_attr_getschedparam () |
| 36 |
returns the scheduling parameter attributes of the thread attributes object |
| 37 |
.I attr |
| 38 |
in the buffer pointed to by |
| 39 |
.IR param . |
| 40 |
.P |
| 41 |
Scheduling parameters are maintained in the following structure: |
| 42 |
.P |
| 43 |
.in +4n |
| 44 |
.EX |
| 45 |
struct sched_param { |
| 46 |
int sched_priority; /* Scheduling priority */ |
| 47 |
}; |
| 48 |
.EE |
| 49 |
.in |
| 50 |
.P |
| 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 |
.P |
| 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 |
.P |
| 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 ATTRIBUTES |
| 87 |
For an explanation of the terms used in this section, see |
| 88 |
.BR attributes (7). |
| 89 |
.TS |
| 90 |
allbox; |
| 91 |
lbx lb lb |
| 92 |
l l l. |
| 93 |
Interface Attribute Value |
| 94 |
T{ |
| 95 |
.na |
| 96 |
.nh |
| 97 |
.BR pthread_attr_setschedparam (), |
| 98 |
.BR pthread_attr_getschedparam () |
| 99 |
T} Thread safety MT-Safe |
| 100 |
.TE |
| 101 |
.SH STANDARDS |
| 102 |
POSIX.1-2008. |
| 103 |
.SH HISTORY |
| 104 |
POSIX.1-2001. |
| 105 |
glibc 2.0. |
| 106 |
.SH NOTES |
| 107 |
See |
| 108 |
.BR pthread_attr_setschedpolicy (3) |
| 109 |
for a list of the thread scheduling policies supported on Linux. |
| 110 |
.SH EXAMPLES |
| 111 |
See |
| 112 |
.BR pthread_setschedparam (3). |
| 113 |
.SH SEE ALSO |
| 114 |
.ad l |
| 115 |
.nh |
| 116 |
.BR sched_get_priority_min (2), |
| 117 |
.BR pthread_attr_init (3), |
| 118 |
.BR pthread_attr_setinheritsched (3), |
| 119 |
.BR pthread_attr_setschedpolicy (3), |
| 120 |
.BR pthread_create (3), |
| 121 |
.BR pthread_setschedparam (3), |
| 122 |
.BR pthread_setschedprio (3), |
| 123 |
.BR pthreads (7), |
| 124 |
.BR sched (7) |