Blame man3/pthread_attr_setinheritsched.3

Packit 7cfc04
.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
Packit 7cfc04
.\"     <mtk.manpages@gmail.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.TH PTHREAD_ATTR_SETINHERITSCHED 3 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get
Packit 7cfc04
inherit-scheduler attribute in thread attributes object
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <pthread.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int pthread_attr_setinheritsched(pthread_attr_t *" attr ,
Packit 7cfc04
.BI "                                 int " inheritsched );
Packit 7cfc04
.BI "int pthread_attr_getinheritsched(const pthread_attr_t *" attr ,
Packit 7cfc04
.BI "                                 int *" inheritsched );
Packit 7cfc04
.PP
Packit 7cfc04
Compile and link with \fI\-pthread\fP.
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.BR pthread_attr_setinheritsched ()
Packit 7cfc04
function sets the inherit-scheduler attribute of the
Packit 7cfc04
thread attributes object referred to by
Packit 7cfc04
.IR attr
Packit 7cfc04
to the value specified in
Packit 7cfc04
.IR inheritsched .
Packit 7cfc04
The inherit-scheduler attribute determines whether a thread created using
Packit 7cfc04
the thread attributes object
Packit 7cfc04
.I attr
Packit 7cfc04
will inherit its scheduling attributes from the calling thread
Packit 7cfc04
or whether it will take them from
Packit 7cfc04
.IR attr .
Packit 7cfc04
.PP
Packit 7cfc04
The following scheduling attributes are affected by the
Packit 7cfc04
inherit-scheduler attribute:
Packit 7cfc04
scheduling policy
Packit 7cfc04
.RB ( pthread_attr_setschedpolicy (3)),
Packit 7cfc04
scheduling priority
Packit 7cfc04
.RB ( pthread_attr_setschedparam (3)),
Packit 7cfc04
and contention scope
Packit 7cfc04
.RB ( pthread_attr_setscope (3)).
Packit 7cfc04
.PP
Packit 7cfc04
The following values may be specified in
Packit 7cfc04
.IR inheritsched :
Packit 7cfc04
.TP
Packit 7cfc04
.B PTHREAD_INHERIT_SCHED
Packit 7cfc04
Threads that are created using
Packit 7cfc04
.I attr
Packit 7cfc04
inherit scheduling attributes from the creating thread;
Packit 7cfc04
the scheduling attributes in
Packit 7cfc04
.I attr
Packit 7cfc04
are ignored.
Packit 7cfc04
.TP
Packit 7cfc04
.B PTHREAD_EXPLICIT_SCHED
Packit 7cfc04
Threads that are created using
Packit 7cfc04
.I attr
Packit 7cfc04
take their scheduling attributes from the values specified
Packit 7cfc04
by the attributes object.
Packit 7cfc04
.\" FIXME Document the defaults for scheduler settings
Packit 7cfc04
.PP
Packit 7cfc04
The default setting of the inherit-scheduler attribute in
Packit 7cfc04
a newly initialized thread attributes object is
Packit 7cfc04
.BR PTHREAD_INHERIT_SCHED .
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.BR pthread_attr_getinheritsched ()
Packit 7cfc04
returns the inherit-scheduler attribute of the thread attributes object
Packit 7cfc04
.IR attr
Packit 7cfc04
in the buffer pointed to by
Packit 7cfc04
.IR inheritsched .
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success, these functions return 0;
Packit 7cfc04
on error, they return a nonzero error number.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.BR pthread_attr_setinheritsched ()
Packit 7cfc04
can fail with the following error:
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
Invalid value in
Packit 7cfc04
.IR inheritsched .
Packit 7cfc04
.PP
Packit 7cfc04
POSIX.1 also documents an optional
Packit 7cfc04
.B ENOTSUP
Packit 7cfc04
error ("attempt was made to set the attribute to an unsupported value") for
Packit 7cfc04
.BR pthread_attr_setinheritsched ().
Packit 7cfc04
.\" .SH VERSIONS
Packit 7cfc04
.\" Available since glibc 2.0.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lbw31 lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR pthread_attr_setinheritsched (),
Packit 7cfc04
.BR pthread_attr_getinheritsched ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
As at glibc 2.8, if a thread attributes object is initialized using
Packit 7cfc04
.BR pthread_attr_init (3),
Packit 7cfc04
then the scheduling policy of the attributes object is set to
Packit 7cfc04
.BR SCHED_OTHER
Packit 7cfc04
and the scheduling priority is set to 0.
Packit 7cfc04
However, if the inherit-scheduler attribute is then set to
Packit 7cfc04
.BR PTHREAD_EXPLICIT_SCHED ,
Packit 7cfc04
then a thread created using the attribute object
Packit 7cfc04
wrongly inherits its scheduling attributes from the creating thread.
Packit 7cfc04
This bug does not occur if either the scheduling policy or
Packit 7cfc04
scheduling priority attribute is explicitly set
Packit 7cfc04
in the thread attributes object before calling
Packit 7cfc04
.BR pthread_create (3).
Packit 7cfc04
.\" FIXME . Track status of the following bug:
Packit 7cfc04
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007
Packit 7cfc04
.SH EXAMPLE
Packit 7cfc04
See
Packit 7cfc04
.BR pthread_setschedparam (3).
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.ad l
Packit 7cfc04
.nh
Packit 7cfc04
.BR pthread_attr_init (3),
Packit 7cfc04
.BR pthread_attr_setschedparam (3),
Packit 7cfc04
.BR pthread_attr_setschedpolicy (3),
Packit 7cfc04
.BR pthread_attr_setscope (3),
Packit 7cfc04
.BR pthread_create (3),
Packit 7cfc04
.BR pthread_setschedparam (3),
Packit 7cfc04
.BR pthread_setschedprio (3),
Packit 7cfc04
.BR pthreads (7),
Packit 7cfc04
.BR sched (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.