1PTHREAD_ATTR_SETSCHEDPARAM(3L)inux Programmer's ManuPaTlHREAD_ATTR_SETSCHEDPARAM(3)
2
3
4

NAME

6       pthread_attr_setschedparam, pthread_attr_getschedparam - set/get sched‐
7       uling parameter attributes in thread attributes object
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
13                                     const struct sched_param *restrict param);
14       int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
15                                     struct sched_param *restrict param);
16
17       Compile and link with -pthread.
18

DESCRIPTION

20       The pthread_attr_setschedparam() function sets the scheduling parameter
21       attributes  of  the thread attributes object referred to by attr to the
22       values specified in the buffer pointed to by param.   These  attributes
23       determine  the  scheduling  parameters  of  a  thread created using the
24       thread attributes object attr.
25
26       The pthread_attr_getschedparam() returns the scheduling  parameter  at‐
27       tributes  of the thread attributes object attr in the buffer pointed to
28       by param.
29
30       Scheduling parameters are maintained in the following structure:
31
32           struct sched_param {
33               int sched_priority;     /* Scheduling priority */
34           };
35
36       As can be seen, only one scheduling parameter is  supported.   For  de‐
37       tails  of the permitted ranges for scheduling priorities in each sched‐
38       uling policy, see sched(7).
39
40       In order for the parameter setting made by pthread_attr_setschedparam()
41       to  have  effect  when  calling  pthread_create(3), the caller must use
42       pthread_attr_setinheritsched(3) to set the inherit-scheduler  attribute
43       of the attributes object attr to PTHREAD_EXPLICIT_SCHED.
44

RETURN VALUE

46       On  success,  these functions return 0; on error, they return a nonzero
47       error number.
48

ERRORS

50       pthread_attr_setschedparam() can fail with the following error:
51
52       EINVAL The priority specified in param does not make sense for the cur‐
53              rent scheduling policy of attr.
54
55       POSIX.1  also  documents  an  ENOTSUP  error for pthread_attr_setsched‐
56       param().  This value is never returned on Linux (but portable  and  fu‐
57       ture-proof  applications  should  nevertheless handle this error return
58       value).
59

ATTRIBUTES

61       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
62       tributes(7).
63
64       ┌────────────────────────────────────────────┬───────────────┬─────────┐
65Interface                                   Attribute     Value   
66       ├────────────────────────────────────────────┼───────────────┼─────────┤
67pthread_attr_setschedparam(),               │ Thread safety │ MT-Safe │
68pthread_attr_getschedparam()                │               │         │
69       └────────────────────────────────────────────┴───────────────┴─────────┘
70

CONFORMING TO

72       POSIX.1-2001, POSIX.1-2008.
73

NOTES

75       See pthread_attr_setschedpolicy(3) for a list of the thread  scheduling
76       policies supported on Linux.
77

EXAMPLES

79       See pthread_setschedparam(3).
80

SEE ALSO

82       sched_get_priority_min(2), pthread_attr_init(3),
83       pthread_attr_setinheritsched(3), pthread_attr_setschedpolicy(3),
84       pthread_create(3), pthread_setschedparam(3), pthread_setschedprio(3),
85       pthreads(7), sched(7)
86

COLOPHON

88       This page is part of release 5.13 of the Linux man-pages project.  A
89       description of the project, information about reporting bugs, and the
90       latest version of this page, can be found at
91       https://www.kernel.org/doc/man-pages/.
92
93
94
95Linux                             2021-03-22     PTHREAD_ATTR_SETSCHEDPARAM(3)
Impressum