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