| 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_setschedpolicy 3 2025-05-17 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
pthread_attr_setschedpolicy, pthread_attr_getschedpolicy \- set/get |
| 9 |
scheduling policy attribute 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_setschedpolicy(pthread_attr_t *" attr ", int " policy ); |
| 18 |
.BI "int pthread_attr_getschedpolicy(const pthread_attr_t *restrict " attr , |
| 19 |
.BI " int *restrict " policy ); |
| 20 |
.fi |
| 21 |
.SH DESCRIPTION |
| 22 |
The |
| 23 |
.BR pthread_attr_setschedpolicy () |
| 24 |
function sets the scheduling policy attribute of the |
| 25 |
thread attributes object referred to by |
| 26 |
.I attr |
| 27 |
to the value specified in |
| 28 |
.IR policy . |
| 29 |
This attribute determines the scheduling policy of |
| 30 |
a thread created using the thread attributes object |
| 31 |
.IR attr . |
| 32 |
.P |
| 33 |
The supported values for |
| 34 |
.I policy |
| 35 |
are |
| 36 |
.BR SCHED_FIFO , |
| 37 |
.BR SCHED_RR , |
| 38 |
and |
| 39 |
.BR SCHED_OTHER , |
| 40 |
with the semantics described in |
| 41 |
.BR sched (7). |
| 42 |
.\" FIXME . pthread_setschedparam() places no restriction on the policy, |
| 43 |
.\" but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER |
| 44 |
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7013 |
| 45 |
.P |
| 46 |
The |
| 47 |
.BR pthread_attr_getschedpolicy () |
| 48 |
returns the scheduling policy attribute of the thread attributes object |
| 49 |
.I attr |
| 50 |
in the buffer pointed to by |
| 51 |
.IR policy . |
| 52 |
.P |
| 53 |
In order for the policy setting made by |
| 54 |
.BR pthread_attr_setschedpolicy () |
| 55 |
to have effect when calling |
| 56 |
.BR pthread_create (3), |
| 57 |
the caller must use |
| 58 |
.BR pthread_attr_setinheritsched (3) |
| 59 |
to set the inherit-scheduler attribute of the attributes object |
| 60 |
.I attr |
| 61 |
to |
| 62 |
.BR PTHREAD_EXPLICIT_SCHED . |
| 63 |
.SH RETURN VALUE |
| 64 |
On success, these functions return 0; |
| 65 |
on error, they return a nonzero error number. |
| 66 |
.SH ERRORS |
| 67 |
.BR pthread_attr_setschedpolicy () |
| 68 |
can fail with the following error: |
| 69 |
.TP |
| 70 |
.B EINVAL |
| 71 |
Invalid value in |
| 72 |
.IR policy . |
| 73 |
.P |
| 74 |
POSIX.1 also documents an optional |
| 75 |
.B ENOTSUP |
| 76 |
error ("attempt was made to set the attribute to an unsupported value") for |
| 77 |
.BR pthread_attr_setschedpolicy (). |
| 78 |
.SH ATTRIBUTES |
| 79 |
For an explanation of the terms used in this section, see |
| 80 |
.BR attributes (7). |
| 81 |
.TS |
| 82 |
allbox; |
| 83 |
lbx lb lb |
| 84 |
l l l. |
| 85 |
Interface Attribute Value |
| 86 |
T{ |
| 87 |
.na |
| 88 |
.nh |
| 89 |
.BR pthread_attr_setschedpolicy (), |
| 90 |
.BR pthread_attr_getschedpolicy () |
| 91 |
T} Thread safety MT-Safe |
| 92 |
.TE |
| 93 |
.SH STANDARDS |
| 94 |
POSIX.1-2008. |
| 95 |
.SH HISTORY |
| 96 |
glibc 2.0. |
| 97 |
POSIX.1-2001. |
| 98 |
.SH EXAMPLES |
| 99 |
See |
| 100 |
.BR pthread_setschedparam (3). |
| 101 |
.SH SEE ALSO |
| 102 |
.ad l |
| 103 |
.nh |
| 104 |
.BR pthread_attr_init (3), |
| 105 |
.BR pthread_attr_setinheritsched (3), |
| 106 |
.BR pthread_attr_setschedparam (3), |
| 107 |
.BR pthread_create (3), |
| 108 |
.BR pthread_setschedparam (3), |
| 109 |
.BR pthread_setschedprio (3), |
| 110 |
.BR pthreads (7), |
| 111 |
.BR sched (7) |