1PTHREAD_ATTR_SETINHERITSCHEDL(i3n)ux Programmer's MaPnTuHaRlEAD_ATTR_SETINHERITSCHED(3)
2
3
4
6 pthread_attr_setinheritsched, pthread_attr_getinheritsched - set/get
7 inherit-scheduler attribute in thread attributes object
8
10 #include <pthread.h>
11
12 int pthread_attr_setinheritsched(pthread_attr_t *attr,
13 int inheritsched);
14 int pthread_attr_getinheritsched(const pthread_attr_t *attr,
15 int *inheritsched);
16
17 Compile and link with -pthread.
18
20 The pthread_attr_setinheritsched() function sets the inherit-scheduler
21 attribute of the thread attributes object referred to by attr to the
22 value specified in inheritsched. The inherit-scheduler attribute
23 determines whether a thread created using the thread attributes object
24 attr will inherit its scheduling attributes from the calling thread or
25 whether it will take them from attr.
26
27 The following scheduling attributes are affected by the inherit-sched‐
28 uler attribute: scheduling policy (pthread_attr_setschedpolicy(3)),
29 scheduling priority (pthread_attr_setschedparam(3)), and contention
30 scope (pthread_attr_setscope(3)).
31
32 The following values may be specified in inheritsched:
33
34 PTHREAD_INHERIT_SCHED
35 Threads that are created using attr inherit scheduling
36 attributes from the creating thread; the scheduling attributes
37 in attr are ignored.
38
39 PTHREAD_EXPLICIT_SCHED
40 Threads that are created using attr take their scheduling
41 attributes from the values specified by the attributes object.
42
43 The default setting of the inherit-scheduler attribute in a newly ini‐
44 tialized thread attributes object is PTHREAD_INHERIT_SCHED.
45
46 The pthread_attr_getinheritsched() returns the inherit-scheduler
47 attribute of the thread attributes object attr in the buffer pointed to
48 by inheritsched.
49
51 On success, these functions return 0; on error, they return a nonzero
52 error number.
53
55 pthread_attr_setinheritsched() can fail with the following error:
56
57 EINVAL Invalid value in inheritsched.
58
59 POSIX.1 also documents an optional ENOTSUP error ("attempt was made to
60 set the attribute to an unsupported value") for pthread_attr_setinher‐
61 itsched().
62
64 For an explanation of the terms used in this section, see
65 attributes(7).
66
67 ┌────────────────────────────────┬───────────────┬─────────┐
68 │Interface │ Attribute │ Value │
69 ├────────────────────────────────┼───────────────┼─────────┤
70 │pthread_attr_setinheritsched(), │ Thread safety │ MT-Safe │
71 │pthread_attr_getinheritsched() │ │ │
72 └────────────────────────────────┴───────────────┴─────────┘
74 POSIX.1-2001, POSIX.1-2008.
75
77 As at glibc 2.8, if a thread attributes object is initialized using
78 pthread_attr_init(3), then the scheduling policy of the attributes
79 object is set to SCHED_OTHER and the scheduling priority is set to 0.
80 However, if the inherit-scheduler attribute is then set to
81 PTHREAD_EXPLICIT_SCHED, then a thread created using the attribute
82 object wrongly inherits its scheduling attributes from the creating
83 thread. This bug does not occur if either the scheduling policy or
84 scheduling priority attribute is explicitly set in the thread
85 attributes object before calling pthread_create(3).
86
88 See pthread_setschedparam(3).
89
91 pthread_attr_init(3), pthread_attr_setschedparam(3),
92 pthread_attr_setschedpolicy(3), pthread_attr_setscope(3),
93 pthread_create(3), pthread_setschedparam(3), pthread_setschedprio(3),
94 pthreads(7), sched(7)
95
97 This page is part of release 4.15 of the Linux man-pages project. A
98 description of the project, information about reporting bugs, and the
99 latest version of this page, can be found at
100 https://www.kernel.org/doc/man-pages/.
101
102
103
104Linux 2017-09-15 PTHREAD_ATTR_SETINHERITSCHED(3)