1PTHREAD_GETSCHEDPARAM(3P) POSIX Programmer's Manual PTHREAD_GETSCHEDPARAM(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 pthread_getschedparam, pthread_setschedparam — dynamic thread schedul‐
13 ing parameters access (REALTIME THREADS)
14
16 #include <pthread.h>
17
18 int pthread_getschedparam(pthread_t thread, int *restrict policy,
19 struct sched_param *restrict param);
20 int pthread_setschedparam(pthread_t thread, int policy,
21 const struct sched_param *param);
22
24 The pthread_getschedparam() and pthread_setschedparam() functions
25 shall, respectively, get and set the scheduling policy and parameters
26 of individual threads within a multi-threaded process to be retrieved
27 and set. For SCHED_FIFO and SCHED_RR, the only required member of the
28 sched_param structure is the priority sched_priority. For SCHED_OTHER,
29 the affected scheduling parameters are implementation-defined.
30
31 The pthread_getschedparam() function shall retrieve the scheduling pol‐
32 icy and scheduling parameters for the thread whose thread ID is given
33 by thread and shall store those values in policy and param, respec‐
34 tively. The priority value returned from pthread_getschedparam() shall
35 be the value specified by the most recent pthread_setschedparam(),
36 pthread_setschedprio(), or pthread_create() call affecting the target
37 thread. It shall not reflect any temporary adjustments to its priority
38 as a result of any priority inheritance or ceiling functions. The
39 pthread_setschedparam() function shall set the scheduling policy and
40 associated scheduling parameters for the thread whose thread ID is
41 given by thread to the policy and associated parameters provided in
42 policy and param, respectively.
43
44 The policy parameter may have the value SCHED_OTHER, SCHED_FIFO, or
45 SCHED_RR. The scheduling parameters for the SCHED_OTHER policy are
46 implementation-defined. The SCHED_FIFO and SCHED_RR policies shall have
47 a single scheduling parameter, priority.
48
49 If _POSIX_THREAD_SPORADIC_SERVER is defined, then the policy argument
50 may have the value SCHED_SPORADIC, with the exception for the
51 pthread_setschedparam() function that if the scheduling policy was not
52 SCHED_SPORADIC at the time of the call, it is implementation-defined
53 whether the function is supported; in other words, the implementation
54 need not allow the application to dynamically change the scheduling
55 policy to SCHED_SPORADIC. The sporadic server scheduling policy has the
56 associated parameters sched_ss_low_priority, sched_ss_repl_period,
57 sched_ss_init_budget, sched_priority, and sched_ss_max_repl. The spec‐
58 ified sched_ss_repl_period shall be greater than or equal to the speci‐
59 fied sched_ss_init_budget for the function to succeed; if it is not,
60 then the function shall fail. The value of sched_ss_max_repl shall be
61 within the inclusive range [1,{SS_REPL_MAX}] for the function to suc‐
62 ceed; if not, the function shall fail. It is unspecified whether the
63 sched_ss_repl_period and sched_ss_init_budget values are stored as pro‐
64 vided by this function or are rounded to align with the resolution of
65 the clock being used.
66
67 If the pthread_setschedparam() function fails, the scheduling parame‐
68 ters shall not be changed for the target thread.
69
71 If successful, the pthread_getschedparam() and pthread_setschedparam()
72 functions shall return zero; otherwise, an error number shall be
73 returned to indicate the error.
74
76 The pthread_setschedparam() function shall fail if:
77
78 ENOTSUP
79 An attempt was made to set the policy or scheduling parameters
80 to an unsupported value.
81
82 ENOTSUP
83 An attempt was made to dynamically change the scheduling policy
84 to SCHED_SPORADIC, and the implementation does not support this
85 change.
86
87 The pthread_setschedparam() function may fail if:
88
89 EINVAL The value specified by policy or one of the scheduling parame‐
90 ters associated with the scheduling policy policy is invalid.
91
92 EPERM The caller does not have appropriate privileges to set either
93 the scheduling parameters or the scheduling policy of the speci‐
94 fied thread.
95
96 EPERM The implementation does not allow the application to modify one
97 of the parameters to the value specified.
98
99 These functions shall not return an error code of [EINTR].
100
101 The following sections are informative.
102
104 None.
105
107 None.
108
110 If an implementation detects use of a thread ID after the end of its
111 lifetime, it is recommended that the function should fail and report an
112 [ESRCH] error.
113
115 None.
116
118 pthread_setschedprio(), sched_getparam(), sched_getscheduler()
119
120 The Base Definitions volume of POSIX.1‐2017, <pthread.h>, <sched.h>
121
123 Portions of this text are reprinted and reproduced in electronic form
124 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
125 table Operating System Interface (POSIX), The Open Group Base Specifi‐
126 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
127 Electrical and Electronics Engineers, Inc and The Open Group. In the
128 event of any discrepancy between this version and the original IEEE and
129 The Open Group Standard, the original IEEE and The Open Group Standard
130 is the referee document. The original Standard can be obtained online
131 at http://www.opengroup.org/unix/online.html .
132
133 Any typographical or formatting errors that appear in this page are
134 most likely to have been introduced during the conversion of the source
135 files to man page format. To report such errors, see https://www.ker‐
136 nel.org/doc/man-pages/reporting_bugs.html .
137
138
139
140IEEE/The Open Group 2017 PTHREAD_GETSCHEDPARAM(3P)