OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[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 2012-03-15 "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 .fi
39 .SH DESCRIPTION
40 The
41 .BR pthread_attr_setinheritsched ()
42 function sets the inherit scheduler attribute of the
43 thread attributes object referred to by
44 .IR attr
45 to the value specified in
46 .IR inheritsched .
47 The inherit scheduler attribute determines whether a thread created using
48 the thread attributes object
49 .I attr
50 will inherit its scheduling attributes from the calling thread
51 or whether it will take them from
52 .IR attr .
53
54 The following values may be specified in
55 .IR inheritsched :
56 .TP
57 .B PTHREAD_INHERIT_SCHED
58 Threads that are created using
59 .I attr
60 inherit scheduling attributes from the creating thread;
61 the scheduling attributes in
62 .I attr
63 are ignored.
64 .TP
65 .B PTHREAD_EXPLICIT_SCHED
66 Threads that are created using
67 .I attr
68 take their scheduling attributes from the values specified
69 by the attributes object.
70 .\" FIXME what are the defaults for scheduler settings?
71 .PP
72 The default setting of the inherit scheduler attribute in
73 a newly initialized thread attributes object is
74 .BR PTHREAD_INHERIT_SCHED .
75
76 The
77 .BR pthread_attr_getinheritsched ()
78 returns the inherit scheduler attribute of the thread attributes object
79 .IR attr
80 in the buffer pointed to by
81 .IR inheritsched .
82 .SH RETURN VALUE
83 On success, these functions return 0;
84 on error, they return a nonzero error number.
85 .SH ERRORS
86 .BR pthread_attr_setinheritsched ()
87 can fail with the following error:
88 .TP
89 .B EINVAL
90 Invalid value in
91 .IR inheritsched .
92 .PP
93 POSIX.1-2001 also documents an optional
94 .B ENOTSUP
95 error ("attempt was made to set the attribute to an unsupported value") for
96 .BR pthread_attr_setinheritsched ().
97 .\" .SH VERSIONS
98 .\" Available since glibc 2.0.
99 .SH CONFORMING TO
100 POSIX.1-2001.
101 .SH BUGS
102 As at glibc 2.8, if a thread attributes object is initialized using
103 .BR pthread_attr_init (3),
104 then the scheduling policy of the attributes object is set to
105 .BR SCHED_OTHER
106 and the scheduling priority is set to 0.
107 However, if the inherit scheduler attribute is then set to
108 .BR PTHREAD_EXPLICIT_SCHED ,
109 then a thread created using the attribute object
110 wrongly inherits its scheduling attributes from the creating thread.
111 This bug does not occur if either the scheduling policy or
112 scheduling priority attribute is explicitly set
113 in the thread attributes object before calling
114 .BR pthread_create (3).
115 .\" FIXME . Track status of the following bug:
116 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
117 .SH EXAMPLE
118 See
119 .BR pthread_setschedparam (3).
120 .SH SEE ALSO
121 .BR sched_setscheduler (2),
122 .BR pthread_attr_init (3),
123 .BR pthread_attr_setschedparam (3),
124 .BR pthread_attr_setschedpolicy (3),
125 .BR pthread_create (3),
126 .BR pthread_setschedparam (3),
127 .BR pthread_setschedprio (3),
128 .BR pthreads (7)