OSDN Git Service

b858f72ac9d3021fca961ca0259ca30bc7de7118
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_attr_setinheritsched.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_ATTR_SETINHERITSCHED 3 2008-11-10 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get
27 inherit scheduler attribute in thread attributes object
28 .SH SYNOPSIS
29 .nf
30 .B #include <pthread.h>
31
32 .BI "int pthread_attr_setinheritsched(pthread_attr_t *" attr ,
33 .BI "                                 int " inheritsched );
34 .BI "int pthread_attr_getinheritsched(pthread_attr_t *" attr ,
35 .BI "                                 int *" inheritsched );
36 .sp
37 Compile and link with \fI\-pthread\fP.
38 .SH DESCRIPTION
39 The
40 .BR pthread_attr_setinheritsched ()
41 function sets the inherit scheduler attribute of the
42 thread attributes object referred to by
43 .IR attr
44 to the value specified in
45 .IR inheritsched .
46 The inherit scheduler attribute determines whether a thread created using
47 the thread attributes object
48 .I attr
49 will inherit its scheduling attributes from the calling thread
50 or whether it will take them from
51 .IR attr .
52
53 The following values may be specified in
54 .IR inheritsched :
55 .TP
56 .B PTHREAD_INHERIT_SCHED
57 Threads that are created using
58 .I attr
59 inherit scheduling attributes from the creating thread;
60 the scheduling attributes in
61 .I attr
62 are ignored.
63 .TP
64 .B PTHREAD_EXPLICIT_SCHED
65 Threads that are created using
66 .I attr
67 take their scheduling attributes from the values specified
68 by the attributes object.
69 .\" FIXME what are the defaults for scheduler settings?
70 .PP
71 The default setting of the inherit scheduler attribute in
72 a newly initialized thread attributes object is
73 .BR PTHREAD_INHERIT_SCHED .
74
75 The
76 .BR pthread_attr_getinheritsched ()
77 returns the inherit scheduler attribute of the thread attributes object
78 .IR attr
79 in the buffer pointed to by
80 .IR inheritsched .
81 .SH RETURN VALUE
82 On success, these functions return 0;
83 on error, they return a nonzero error number.
84 .SH ERRORS
85 .BR pthread_attr_setinheritsched ()
86 can fail with the following error:
87 .TP
88 .B EINVAL
89 Invalid value in
90 .IR inheritsched .
91 .PP
92 POSIX.1-2001 also documents an optional
93 .B ENOTSUP
94 error ("attempt was made to set the attribute to an unsupported value") for
95 .BR pthread_attr_setinheritsched ().
96 .\" .SH VERSIONS
97 .\" Available since glibc 2.0.
98 .SH CONFORMING TO
99 POSIX.1-2001.
100 .SH EXAMPLE
101 See
102 .BR pthread_setschedparam (3).
103 .SH BUGS
104 As at glibc 2.8, if a thread attributes object is initialized using
105 .BR pthread_attr_init (3),
106 then the scheduling policy of the attributes object is set to
107 .BR SCHED_OTHER
108 and the scheduling priority is set to 0.
109 However, if the inherit scheduler attribute is then set to
110 .BR PTHREAD_EXPLICIT_SCHED ,
111 then a thread created using the attribute object
112 wrongly inherits its scheduling attributes from the creating thread.
113 This bug does not occur if either the scheduling policy or
114 scheduling priority attribute is explicitly set
115 in the thread attributes object before calling
116 .BR pthread_create (3).
117 .\" FIXME . Track status of the following bug:
118 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
119 .SH SEE ALSO
120 .BR sched_setscheduler (2),
121 .BR pthread_attr_init (3),
122 .BR pthread_attr_setschedparam (3),
123 .BR pthread_attr_setschedpolicy (3),
124 .BR pthread_create (3),
125 .BR pthread_setschedparam (3),
126 .BR pthread_setschedprio (3),
127 .BR pthreads (7)