1pthread_attr_setinheritschedL(i3b)rary Functions Manputahlread_attr_setinheritsched(3)
2
3
4

NAME

6       pthread_attr_setinheritsched,  pthread_attr_getinheritsched  -  set/get
7       inherit-scheduler attribute in thread attributes object
8

LIBRARY

10       POSIX threads library (libpthread, -lpthread)
11

SYNOPSIS

13       #include <pthread.h>
14
15       int pthread_attr_setinheritsched(pthread_attr_t *attr,
16                                        int inheritsched);
17       int pthread_attr_getinheritsched(const pthread_attr_t *restrict attr,
18                                        int *restrict inheritsched);
19

DESCRIPTION

21       The pthread_attr_setinheritsched() function sets the  inherit-scheduler
22       attribute  of  the  thread attributes object referred to by attr to the
23       value specified in inheritsched.  The inherit-scheduler  attribute  de‐
24       termines  whether  a  thread created using the thread attributes object
25       attr will inherit its scheduling attributes from the calling thread  or
26       whether it will take them from attr.
27
28       The  following scheduling attributes are affected by the inherit-sched‐
29       uler  attribute:  scheduling  policy  (pthread_attr_setschedpolicy(3)),
30       scheduling  priority  (pthread_attr_setschedparam(3)),  and  contention
31       scope (pthread_attr_setscope(3)).
32
33       The following values may be specified in inheritsched:
34
35       PTHREAD_INHERIT_SCHED
36              Threads that are  created  using  attr  inherit  scheduling  at‐
37              tributes  from the creating thread; the scheduling attributes in
38              attr are ignored.
39
40       PTHREAD_EXPLICIT_SCHED
41              Threads that are created using attr take  their  scheduling  at‐
42              tributes from the values specified by the attributes object.
43
44       The  default setting of the inherit-scheduler attribute in a newly ini‐
45       tialized thread attributes object is PTHREAD_INHERIT_SCHED.
46
47       The pthread_attr_getinheritsched() returns the inherit-scheduler attri‐
48       bute  of  the thread attributes object attr in the buffer pointed to by
49       inheritsched.
50

RETURN VALUE

52       On success, these functions return 0; on error, they return  a  nonzero
53       error number.
54

ERRORS

56       pthread_attr_setinheritsched() can fail with the following error:
57
58       EINVAL Invalid value in inheritsched.
59
60       POSIX.1  also documents an optional ENOTSUP error ("attempt was made to
61       set the attribute to an unsupported value") for  pthread_attr_setinher‐
62       itsched().
63

ATTRIBUTES

65       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
66       tributes(7).
67
68       ┌────────────────────────────────────────────┬───────────────┬─────────┐
69Interface                                   Attribute     Value   
70       ├────────────────────────────────────────────┼───────────────┼─────────┤
71pthread_attr_setinheritsched(),             │ Thread safety │ MT-Safe │
72pthread_attr_getinheritsched()              │               │         │
73       └────────────────────────────────────────────┴───────────────┴─────────┘
74

STANDARDS

76       POSIX.1-2008.
77

HISTORY

79       glibc 2.0.  POSIX.1-2001.
80

BUGS

82       As  at  glibc  2.8,  if a thread attributes object is initialized using
83       pthread_attr_init(3), then the scheduling policy of the attributes  ob‐
84       ject  is  set  to  SCHED_OTHER and the scheduling priority is set to 0.
85       However, if the inherit-scheduler attribute is then set to  PTHREAD_EX‐
86       PLICIT_SCHED,  then a thread created using the attribute object wrongly
87       inherits its scheduling attributes from the creating thread.  This  bug
88       does  not  occur if either the scheduling policy or scheduling priority
89       attribute is explicitly set in  the  thread  attributes  object  before
90       calling pthread_create(3).
91

EXAMPLES

93       See pthread_setschedparam(3).
94

SEE ALSO

96       pthread_attr_init(3), pthread_attr_setschedparam(3),
97       pthread_attr_setschedpolicy(3), pthread_attr_setscope(3),
98       pthread_create(3), pthread_setschedparam(3), pthread_setschedprio(3),
99       pthreads(7), sched(7)
100
101
102
103Linux man-pages 6.04              2023-03-30   pthread_attr_setinheritsched(3)
Impressum