1PTHREAD_GETSCHEDPARAM(P) POSIX Programmer's Manual PTHREAD_GETSCHEDPARAM(P)
2
3
4
6 pthread_getschedparam, pthread_setschedparam - dynamic thread schedul‐
7 ing parameters access (REALTIME THREADS)
8
10 #include <pthread.h>
11
12 int pthread_getschedparam(pthread_t thread, int *restrict policy,
13 struct sched_param *restrict param);
14 int pthread_setschedparam(pthread_t thread, int policy,
15 const struct sched_param *param);
16
17
19 The pthread_getschedparam() and pthread_setschedparam() functions
20 shall, respectively, get and set the scheduling policy and parameters
21 of individual threads within a multi-threaded process to be retrieved
22 and set. For SCHED_FIFO and SCHED_RR, the only required member of the
23 sched_param structure is the priority sched_priority. For SCHED_OTHER,
24 the affected scheduling parameters are implementation-defined.
25
26 The pthread_getschedparam() function shall retrieve the scheduling pol‐
27 icy and scheduling parameters for the thread whose thread ID is given
28 by thread and shall store those values in policy and param, respec‐
29 tively. The priority value returned from pthread_getschedparam() shall
30 be the value specified by the most recent pthread_setschedparam(),
31 pthread_setschedprio(), or pthread_create() call affecting the target
32 thread. It shall not reflect any temporary adjustments to its priority
33 as a result of any priority inheritance or ceiling functions. The
34 pthread_setschedparam() function shall set the scheduling policy and
35 associated scheduling parameters for the thread whose thread ID is
36 given by thread to the policy and associated parameters provided in
37 policy and param, respectively.
38
39 The policy parameter may have the value SCHED_OTHER, SCHED_FIFO, or
40 SCHED_RR. The scheduling parameters for the SCHED_OTHER policy are
41 implementation-defined. The SCHED_FIFO and SCHED_RR policies shall have
42 a single scheduling parameter, priority.
43
44 If _POSIX_THREAD_SPORADIC_SERVER is defined, then the policy argument
45 may have the value SCHED_SPORADIC, with the exception for the
46 pthread_setschedparam() function that if the scheduling policy was not
47 SCHED_SPORADIC at the time of the call, it is implementation-defined
48 whether the function is supported; in other words, the implementation
49 need not allow the application to dynamically change the scheduling
50 policy to SCHED_SPORADIC. The sporadic server scheduling policy has the
51 associated parameters sched_ss_low_priority, sched_ss_repl_period,
52 sched_ss_init_budget, sched_priority, and sched_ss_max_repl. The speci‐
53 fied sched_ss_repl_period shall be greater than or equal to the speci‐
54 fied sched_ss_init_budget for the function to succeed; if it is not,
55 then the function shall fail. The value of sched_ss_max_repl shall be
56 within the inclusive range [1, {SS_REPL_MAX}] for the function to suc‐
57 ceed; if not, the function shall fail.
58
59 If the pthread_setschedparam() function fails, the scheduling parame‐
60 ters shall not be changed for the target thread.
61
63 If successful, the pthread_getschedparam() and pthread_setschedparam()
64 functions shall return zero; otherwise, an error number shall be
65 returned to indicate the error.
66
68 The pthread_getschedparam() function may fail if:
69
70 ESRCH The value specified by thread does not refer to an existing
71 thread.
72
73
74 The pthread_setschedparam() function may fail if:
75
76 EINVAL The value specified by policy or one of the scheduling parame‐
77 ters associated with the scheduling policy policy is invalid.
78
79 ENOTSUP
80 An attempt was made to set the policy or scheduling parameters
81 to an unsupported value.
82
83 ENOTSUP
84 An attempt was made to dynamically change the scheduling policy
85 to SCHED_SPORADIC, and the implementation does not support this
86 change.
87
88 EPERM The caller does not have the appropriate permission to set
89 either the scheduling parameters or the scheduling policy of the
90 specified thread.
91
92 EPERM The implementation does not allow the application to modify one
93 of the parameters to the value specified.
94
95 ESRCH The value specified by thread does not refer to a existing
96 thread.
97
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 None.
111
113 None.
114
116 pthread_setschedprio() , sched_getparam() , sched_getscheduler() , the
117 Base Definitions volume of IEEE Std 1003.1-2001, <pthread.h>, <sched.h>
118
120 Portions of this text are reprinted and reproduced in electronic form
121 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
122 -- Portable Operating System Interface (POSIX), The Open Group Base
123 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
124 Electrical and Electronics Engineers, Inc and The Open Group. In the
125 event of any discrepancy between this version and the original IEEE and
126 The Open Group Standard, the original IEEE and The Open Group Standard
127 is the referee document. The original Standard can be obtained online
128 at http://www.opengroup.org/unix/online.html .
129
130
131
132IEEE/The Open Group 2003 PTHREAD_GETSCHEDPARAM(P)