1PTHREAD_GETSCHEDPARAM(3P)  POSIX Programmer's Manual PTHREAD_GETSCHEDPARAM(3P)
2
3
4

PROLOG

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
11

NAME

13       pthread_getschedparam, pthread_setschedparam — dynamic thread  schedul‐
14       ing parameters access (REALTIME THREADS)
15

SYNOPSIS

17       #include <pthread.h>
18
19       int pthread_getschedparam(pthread_t thread, int *restrict policy,
20           struct sched_param *restrict param);
21       int pthread_setschedparam(pthread_t thread, int policy,
22           const struct sched_param *param);
23

DESCRIPTION

25       The   pthread_getschedparam()   and  pthread_setschedparam()  functions
26       shall, respectively, get and set the scheduling policy  and  parameters
27       of  individual  threads within a multi-threaded process to be retrieved
28       and set. For SCHED_FIFO and SCHED_RR, the only required member  of  the
29       sched_param structure is the priority sched_priority.  For SCHED_OTHER,
30       the affected scheduling parameters are implementation-defined.
31
32       The pthread_getschedparam() function shall retrieve the scheduling pol‐
33       icy  and  scheduling parameters for the thread whose thread ID is given
34       by thread and shall store those values in  policy  and  param,  respec‐
35       tively.  The priority value returned from pthread_getschedparam() shall
36       be the value specified  by  the  most  recent  pthread_setschedparam(),
37       pthread_setschedprio(),  or  pthread_create() call affecting the target
38       thread. It shall not reflect any temporary adjustments to its  priority
39       as  a  result  of  any  priority  inheritance or ceiling functions. The
40       pthread_setschedparam() function shall set the  scheduling  policy  and
41       associated  scheduling  parameters  for  the  thread whose thread ID is
42       given by thread to the policy and  associated  parameters  provided  in
43       policy and param, respectively.
44
45       The  policy  parameter  may  have the value SCHED_OTHER, SCHED_FIFO, or
46       SCHED_RR. The scheduling parameters  for  the  SCHED_OTHER  policy  are
47       implementation-defined. The SCHED_FIFO and SCHED_RR policies shall have
48       a single scheduling parameter, priority.
49
50       If _POSIX_THREAD_SPORADIC_SERVER is defined, then the  policy  argument
51       may   have  the  value  SCHED_SPORADIC,  with  the  exception  for  the
52       pthread_setschedparam() function that if the scheduling policy was  not
53       SCHED_SPORADIC  at  the  time of the call, it is implementation-defined
54       whether the function is supported; in other words,  the  implementation
55       need  not  allow  the  application to dynamically change the scheduling
56       policy to SCHED_SPORADIC. The sporadic server scheduling policy has the
57       associated   parameters   sched_ss_low_priority,  sched_ss_repl_period,
58       sched_ss_init_budget, sched_priority, and sched_ss_max_repl.  The spec‐
59       ified sched_ss_repl_period shall be greater than or equal to the speci‐
60       fied sched_ss_init_budget for the function to succeed; if  it  is  not,
61       then  the  function shall fail. The value of sched_ss_max_repl shall be
62       within the inclusive range [1,{SS_REPL_MAX}] for the function  to  suc‐
63       ceed;  if  not, the function shall fail.  It is unspecified whether the
64       sched_ss_repl_period and sched_ss_init_budget values are stored as pro‐
65       vided  by  this function or are rounded to align with the resolution of
66       the clock being used.
67
68       If the pthread_setschedparam() function fails, the  scheduling  parame‐
69       ters shall not be changed for the target thread.
70

RETURN VALUE

72       If  successful, the pthread_getschedparam() and pthread_setschedparam()
73       functions shall return  zero;  otherwise,  an  error  number  shall  be
74       returned to indicate the error.
75

ERRORS

77       The pthread_setschedparam() function shall fail if:
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       The pthread_setschedparam() function may fail if:
89
90       EINVAL The value specified by policy or one of the  scheduling  parame‐
91              ters associated with the scheduling policy policy is invalid.
92
93       EPERM  The  caller  does  not have appropriate privileges to set either
94              the scheduling parameters or the scheduling policy of the speci‐
95              fied thread.
96
97       EPERM  The  implementation does not allow the application to modify one
98              of the parameters to the value specified.
99
100       These functions shall not return an error code of [EINTR].
101
102       The following sections are informative.
103

EXAMPLES

105       None.
106

APPLICATION USAGE

108       None.
109

RATIONALE

111       If an implementation detects use of a thread ID after the  end  of  its
112       lifetime, it is recommended that the function should fail and report an
113       [ESRCH] error.
114

FUTURE DIRECTIONS

116       None.
117

SEE ALSO

119       pthread_setschedprio(), sched_getparam(), sched_getscheduler()
120
121       The Base Definitions volume of POSIX.1‐2008, <pthread.h>, <sched.h>
122
124       Portions of this text are reprinted and reproduced in  electronic  form
125       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
126       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
127       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
128       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
129       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
130       event of any discrepancy between this version and the original IEEE and
131       The  Open Group Standard, the original IEEE and The Open Group Standard
132       is the referee document. The original Standard can be  obtained  online
133       at http://www.unix.org/online.html .
134
135       Any  typographical  or  formatting  errors that appear in this page are
136       most likely to have been introduced during the conversion of the source
137       files  to  man page format. To report such errors, see https://www.ker
138       nel.org/doc/man-pages/reporting_bugs.html .
139
140
141
142IEEE/The Open Group                  2013            PTHREAD_GETSCHEDPARAM(3P)
Impressum