]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_setconcurrency.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man3 / pthread_setconcurrency.3
CommitLineData
354fd38d
MK
1.\" Copyright (c) 2009 Michael Kerrisk, <mtk.manpages@gmail.com>
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
354fd38d
MK
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.
4b72fb64 23.\" %%%LICENSE_END
354fd38d 24.\"
4b8c67d9 25.TH PTHREAD_SETCONCURRENCY 3 2017-09-15 "Linux" "Linux Programmer's Manual"
354fd38d
MK
26.SH NAME
27pthread_setconcurrency, pthread_getconcurrency \- set/get
28the concurrency level
29.SH SYNOPSIS
30.nf
31.B #include <pthread.h>
dbfe9c70 32.PP
354fd38d
MK
33.BI "int pthread_setconcurrency(int " new_level );
34.BI "int pthread_getconcurrency(void);
68e4db0a 35.PP
354fd38d 36Compile and link with \fI\-pthread\fP.
6030f2d8 37.fi
354fd38d
MK
38.SH DESCRIPTION
39The
40.BR pthread_setconcurrency ()
41function informs the implementation of the application's
42desired concurrency level, specified in
43.IR new_level .
33a0ccb2 44The implementation takes this only as a hint:
354fd38d
MK
45POSIX.1 does not specify the level of concurrency that
46should be provided as a result of calling
47.BR pthread_setconcurrency ().
847e0d88 48.PP
354fd38d
MK
49Specifying
50.I new_level
51as 0 instructs the implementation to manage the concurrency level
52as it deems appropriate.
847e0d88 53.PP
354fd38d
MK
54.BR pthread_getconcurrency ()
55returns the current value of the concurrency level for this process.
56.SH RETURN VALUE
57On success,
58.BR pthread_setconcurrency ()
59returns 0;
c7094399 60on error, it returns a nonzero error number.
847e0d88 61.PP
354fd38d
MK
62.BR pthread_getconcurrency ()
63always succeeds, returning the concurrency level set by a previous call to
64.BR pthread_setconcurrency (),
65or 0, if
66.BR pthread_setconcurrency ()
67has not previously been called.
68.SH ERRORS
69.BR pthread_setconcurrency ()
70can fail with the following error:
71.TP
72.B EINVAL
73.I new_level
74is negative.
75.PP
5f339bd9 76POSIX.1 also documents an
354fd38d
MK
77.BR EAGAIN
78error ("the value specified by
79.I new_level
80would cause a system resource to be exceeded").
81.SH VERSIONS
82These functions are available in glibc since version 2.1.
3ef3728c 83.SH ATTRIBUTES
6e469d9d
PH
84For an explanation of the terms used in this section, see
85.BR attributes (7).
86.TS
87allbox;
88lbw25 lb lb
89l l l.
90Interface Attribute Value
91T{
92.BR pthread_setconcurrency (),
3ef3728c 93.BR pthread_getconcurrency ()
6e469d9d
PH
94T} Thread safety MT-Safe
95.TE
354fd38d 96.SH CONFORMING TO
5f339bd9 97POSIX.1-2001, POSIX.1-2008.
354fd38d
MK
98.SH NOTES
99The default concurrency level is 0.
847e0d88 100.PP
33a0ccb2 101Concurrency levels are meaningful only for M:N threading implementations,
354fd38d
MK
102where at any moment a subset of a process's set of user-level threads
103may be bound to a smaller number of kernel-scheduling entities.
104Setting the concurrency level allows the application to
105give the system a hint as to the number of kernel-scheduling entities
106that should be provided for efficient execution of the application.
847e0d88 107.PP
354fd38d
MK
108Both LinuxThreads and NPTL are 1:1 threading implementations,
109so setting the concurrency level has no meaning.
110In other words,
111on Linux these functions merely exist for compatibility with other systems,
112and they have no effect on the execution of a program.
113.SH SEE ALSO
114.BR pthread_attr_setscope (3),
115.BR pthreads (7)